Skip to content

Instantly share code, notes, and snippets.

@maxhodak
maxhodak / cities.csv
Last active December 13, 2015 21:49
Transcriptic: Flight Routing
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
city_id x y
a 2 2
b 1 8
c 4 9
d 5 4
e 6 7
f 7 9
g 7 2
h 9 4
i 9 7
<button id="myid">I am a button!</button>
$(document).ready(function() {
$('#myid').click(function() {
// this gets called when you click button#myid
});
import scala.tools.nsc._
import io._
object MkTree {
object Compiler extends Global(new Settings()) {
new Run() // have to initialize the compiler
def parse(code: String) = {
val bfs = new util.BatchSourceFile("<parse>", code)
val unit = new CompilationUnit(new util.ScriptSourceFile(bfs, code.toArray, 0))
def sign(request: String): String = {
val mac = Mac.getInstance("HmacSHA512")
mac.init(new SecretKeySpec(Base64.decodeBase64(encodedSecret), "HmacSHA512"))
Base64.encodeBase64String(mac.doFinal(request.getBytes))
}
val nonce = System.nanoTime() / 1000000
val req = url("https://mtgox.com/api/1/generic/bitcoin/address") <:< Map(
"User-Agent" -> "useragentname",
"Rest-Key" -> apikey,
{
"available": 5852,
"user_id": "1646",
"level": 2,
"itemsseen": 45,
"state": "up",
"leftover": {
"bags": 1,
"tops": 2,
"shoes": 1,
Protocol.new :title => "bacterial transformation" do
plasmid = Storage.get "demo:isolated-plasmid"
vial = Container.new(:centrifuge_15ml)
.add(5.uL, :from => plasmid)
.cool(277.kelvin, :for => 10.minutes)
tube = Container.new(:culture_tube).add(0.5.mL, Chemical.find(:media, :lysogeny_media))
@maxhodak
maxhodak / ringcomp.py
Created September 6, 2011 16:06
ring comparison
from random import randint
def search(ringSetA, ringB, ops_count = 0):
"""
Determines whether two rings are homomorphic in approximately linear time.
Essentially does a prefix search over two randomly-cut rings to shrink the search
space (i.e., possible shifts) as quickly as possible.
match: 4 4 6 2 2 1 ("ring B")
def foo():
mydata = a list of interesting whatever
return {
"aggdata": [
{
"date": x["date"],
"colA": x["something"],
....
} for x in mydata
]
@maxhodak
maxhodak / authors.txt
Created August 18, 2011 01:51
authors
select count(*) as num, substr(firstname, 1, 1) as initial, lastname
from paper_authors
where pmid in (
select pmid
from papers
where journal_id in (1095, 7348, 15276, 994, 6684) and kind like '%Journal Article%'
) and lastname not in (
'Bagla', 'Balter', 'Bhattacharjee', 'Bohannon', 'Clery', 'Cho', 'Cohen', 'Coontz', 'Couzin-Frankel', 'Culotta',
'Enserink', 'Ferber', 'Gibbons', 'Grimm', 'Xin', 'Kaiser', 'Kean', 'Kerr', 'Kintisch', 'Lawler', 'Leslie', 'Mann', 'Marshall',
'Mervis', 'Miller', 'Morell', 'Norman', 'Normile', 'Pennisi', 'Regalado', 'Roberts', 'Service', 'Shulman', 'Stokstad', 'Stone',
ActiveRecord::Schema.define(:version => 20110620010115) do
create_table "users", :force => true do |t|
t.datetime "created_at"
t.datetime "updated_at"
end
end