Skip to content

Instantly share code, notes, and snippets.

View andrewgiessel's full-sized avatar
🧬
hackhackhack

andrew giessel andrewgiessel

🧬
hackhackhack
View GitHub Profile
@andrewgiessel
andrewgiessel / ezp1_proxy_bookmarklet.js
Last active August 29, 2015 14:00
bookmarklet to automatically proxify a page for harvard's library system
// most recent update: 04/22/2014
// one liner
javascript:function go(){var asdf = window.location.host.replace(/\./g, "-");window.location = window.location.protocol+'//'+asdf+'.ezp1.harvard.edu'+window.location.pathname+window.location.search;}go();void(0);
// expanded
function go() {
var asdf = window.location.host.replace(/\./g, "-"); // replace all the periods with dashes (uses regexp)
window.location = window.location.protocol+'//' +
@andrewgiessel
andrewgiessel / gist:7fc86d805f694e33b779
Created August 1, 2014 17:30
linear de-trend using curve_fit and sigma
from scipy.optimize import curve_fit
def linear(x, m, b):
return m*x + b
x = np.arange(0,400,1)
y = linear(x, -0.2, 3)
yn = y + np.random.normal(size=len(x))*2
yn[50:350] *= np.random.normal(size=300)
@andrewgiessel
andrewgiessel / gist:01fb27f936345bc78225
Last active August 29, 2015 14:06
make literal ephus pulse
function makePulses(frameLengthsMS, orderedOdors)
global state
sample_rate = getGlobal(progmanager, 'sampleRate', 'ephys', 'ephys');
trace_length_in_samples = round(sum(frameLengthsMS) * length(orderedOdors) * sample_rate/1000);
if trace_length_in_samples == 0
return
end
stim_literal_pulse = zeros(1, trace_length_in_samples);
import pyproj
wgs84 = pyproj.Proj('+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')##4326
geocentric= pyproj.Proj('+proj=geocent +datum=WGS84 +units=m +no_defs') ##4978
for x, y in coords:
x2, y2, z2 = pyproj.transform( wgs84, geocentric, x, y, 0)
import pandas as pd
import numpy as np
df = pd.DataFrame.from_csv('temp.csv')
old_index = df.index
new_index = old_index.union(pd.DatetimeIndex([old_index[5] + np.timedelta64(1,'s')]))
df.reindex(new_index)
@andrewgiessel
andrewgiessel / gist:b04e6e91a8470f84480c
Created June 15, 2015 15:34
datetime to timestamp
import datetime
(datetime.datetime.utcnow() - datetime.datetime(1970, 1, 1)).total_seconds()
import numpy as np
import base64, zlib, struct
from IPython.display import HTML
def write_png(buf, width, height):
""" buf: must be bytes or a bytearray in py3, a regular string in py2. formatted RGBARGBA... """
# reverse the vertical line order and add null bytes at the start
width_byte_4 = width * 4
raw_data = b''.join(b'\x00' + buf[span:span + width_byte_4]
/* required styles */
.leaflet-map-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-pane,
.leaflet-tile-container,
.leaflet-overlay-pane,
.leaflet-shadow-pane,
/*
Leaflet 1.0.0-beta.2 (81e71fe), a JS library for interactive maps. http://leafletjs.com
(c) 2010-2015 Vladimir Agafonkin, (c) 2010-2011 CloudMade
*/
!function(t,e,i){function n(){var e=t.L;o.noConflict=function(){return t.L=e,this},t.L=o}var o={version:"1.0.0-beta.2"};"object"==typeof module&&"object"==typeof module.exports?module.exports=o:"function"==typeof define&&define.amd&&define(o),"undefined"!=typeof t&&n(),o.Util={extend:function(t){var e,i,n,o;for(i=1,n=arguments.length;n>i;i++){o=arguments[i];for(e in o)t[e]=o[e]}return t},create:Object.create||function(){function t(){}return function(e){return t.prototype=e,new t}}(),bind:function(t,e){var i=Array.prototype.slice;if(t.bind)return t.bind.apply(t,i.call(arguments,1));var n=i.call(arguments,2);return function(){return t.apply(e,n.length?n.concat(i.call(arguments)):arguments)}},stamp:function(t){return t._leaflet_id=t._leaflet_id||++o.Util.lastId,t._leaflet_id},lastId:0,throttle:function(t,e,i){var n,o,s,r;return r=function(){n=!1,o&&(s.apply(i,o
@andrewgiessel
andrewgiessel / Python Install with Macports
Created October 30, 2011 16:30 — forked from alexbw/PythonInstallwithMacports
Python installation w/ MacPorts
# Install Macports
# We'll install a relatively high-level package first, with a lot of dependencies,
# so that we pick up everything along the way
# Chaco is an enthought plotting package that'll
sudo port install py26-chaco
sudo port select python python26
sudo port install py26-ipython