Skip to content

Instantly share code, notes, and snippets.

@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")
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))
{
"available": 5852,
"user_id": "1646",
"level": 2,
"itemsseen": 45,
"state": "up",
"leftover": {
"bags": 1,
"tops": 2,
"shoes": 1,
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,
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))
<button id="myid">I am a button!</button>
$(document).ready(function() {
$('#myid').click(function() {
// this gets called when you click button#myid
});
@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
@maxhodak
maxhodak / gist:5025643
Last active December 14, 2015 04:08
nested class creation
class A(q: mutable.Set[B])
class B(a: String)(implicit a: A)
val a = A(mutable.Set(
B("a"),
B("b"),
B("c")))
// access the outer A object:
// a.q.head.a
Solution(Set(
Device(Set(
Pipeline(Queue(
Warp(/* ... */),
Warp(/* ... */),
Warp(/* ... */))))),
Device(Set(
Pipeline(Queue(
Warp(/* ... */),
Warp(/* ... */)
This file has been truncated, but you can view the full file.
sendrawtransaction "010000000145a05ea6c56e969b3ccba0722a1a234008be6f6d7034313d8ce014f4e0f11c12000000008b48304502200c0a0c22a89fae473d853583a6c7c4a666f7cd536cc6008458ec7f0f5fbf7e70022100de964f12554d574520660b0c3aa4d569231dfd341341f601797c3454a4fce333014104ea46d3f7e1553f2ce3fc3dabe8e8b57770fd7bd2181c283bb2ffaee7756cf85624529b4a0f7f0ae4d285d3703025e9c5ec0c9a3fba73afbc5080bc82f8d26435ffffffff02753f1051000000001976a914e9e92a5b3d188009bbbc070c61df608f8adc2bb288acb0ad0100000000001976a914d152c289756a6e0cc32e4ee8aba54abe13ceb91888ac00000000"
sendrawtransaction "0100000001b2ed3bf8131908b718278af4c22e4e6fc5dc3758547bb5d98057828b37c82bd8000000008a4730440220543aab6a552442c7da5c6c52a008a1525149af05deca63d7c0a5d4b0c2c2f76b0220227e5c6964b7f697828ef5f8d53c53fac017bd910dca1b7fbd7b415028a291f8014104290fe0305a05ad6c21de7ae7b4ebe0ed03a6725cb99ce1d794eee6bc65e6aeb4803e408c90e79cefbd6edacf6f617a4f9c3c78b3311933ea0def578990052a9dffffffff028919512b000000001976a9142cdec05e67da042ebc3a0ef8fba965f6ac53856e88acc0d40100000000001976a91404e6