Skip to content

Instantly share code, notes, and snippets.

View GeauxEric's full-sized avatar

GeauxEric GeauxEric

  • Nvidia
  • CA USA
  • 12:35 (UTC -07:00)
View GitHub Profile
@GeauxEric
GeauxEric / modules.py
Created August 9, 2016 16:46
modules for data exploration in ipython notebook
%load_ext autoreload
%autoreload 2
%matplotlib inline
%config InlineBackend.figure_format='retina'
# Add this to python2 code to make life easier
from __future__ import absolute_import, division, print_function
from itertools import combinations
import string
with
dau as (
-- This part of the query can be pretty much anything.
-- The only requirement is that it have three columns:
-- dt, user_id, inc_amt
-- Where dt is a date and user_id is some unique identifier for a user.
-- Each dt-user_id pair should be unique in this table.
-- inc_amt represents the amount of value that this user created on dt.
-- The most common case is
-- inc_amt = incremental revenue from the user on dt
@GeauxEric
GeauxEric / Apriori.py
Created June 17, 2016 09:46 — forked from marcelcaraciolo/Apriori.py
Apriori.py
#-*- coding:utf-8 - *-
def load_dataset():
"Load the sample dataset."
return [[1, 3, 4], [2, 3, 5], [1, 2, 3, 5], [2, 5]]
def createC1(dataset):
"Create a list of candidate item sets of size one."
#!/bin/bash
# This script will migrate schema and data from a SQLite3 database to PostgreSQL.
# Schema translation based on http://stackoverflow.com/a/4581921/1303625.
# Some column types are not handled (e.g blobs).
#
# See also:
# - http://stackoverflow.com/questions/4581727/convert-sqlite-sql-dump-file-to-postgresql
# - https://gist.github.com/bittner/7368128
@GeauxEric
GeauxEric / max_osx_org_agenda_notification.el
Created May 26, 2016 04:02
notification pop-up from org-agenda on Mac OSX
;; notification from org-agenda
;; brew install terminal-notifier
(defun djcb-popup (title msg &optional)
"Show a popup with the msg and the sound"
(interactive)
(shell-command (concat "terminal-notifier -message "
" '" msg "' "
"-title "
" '"title"' "
))
@GeauxEric
GeauxEric / pybel_atom_name.py
Created May 7, 2016 02:00
atom name between INT and SYB in pybel
from openbabel import OBAtomAtomIter,OBTypeTable
# setup typetable to translate atom types
typetable = OBTypeTable()
typetable.SetFromType('INT')
typetable.SetToType('SYB')
lig = pybel.readfile('sdf', "xxx.sdf").next()
types = [typetable.Translate(a.type) for a in lig.atoms]
@GeauxEric
GeauxEric / align.py
Created March 2, 2016 21:43 — forked from andersx/align.py
How to align two PDB structures using the Bio.PDB module in Biopython
import Bio.PDB
# Select what residues numbers you wish to align
# and put them in a list
start_id = 1
end_id = 70
atoms_to_be_aligned = range(start_id, end_id + 1)
# Start the parser
pdb_parser = Bio.PDB.PDBParser(QUIET = True)
@GeauxEric
GeauxEric / ipython_notebook_toggle_codecell.py
Created February 19, 2016 19:22
toggle the code cell in the html output of ipython notebook
<!-- thanks to https://github.com/Saynah -->
<script>
var code_show=true; //true -> hide code at first
function code_toggle() {
$('div.prompt').hide(); // always hide prompt
if (code_show){
@GeauxEric
GeauxEric / regx_find_float.py
Created February 19, 2016 16:54
regular expression to find all float number in a string
s = u'(-1.234, 12]'
import re
print re.findall(r'[+-]?\d+\.*\d*', s)
@GeauxEric
GeauxEric / dockedpose.py
Last active February 7, 2022 03:46 — forked from baoilleach/dockedpose.py
Using Open Babel to calculate the symmetry-corrected RMSD of a docked pose from a crystal structure
import math
import pybel
def squared_distance(coordsA, coordsB):
"""Find the squared distance between two 3-tuples"""
sqrdist = sum((a - b)**2 for a, b in zip(coordsA, coordsB))
return sqrdist