Skip to content

Instantly share code, notes, and snippets.

View dylanvee's full-sized avatar

Dylan Vassallo dylanvee

View GitHub Profile
@dylanvee
dylanvee / mz-scheme.rb
Created December 4, 2011 07:14
mz-scheme 372
require 'formula'
class MzScheme < Formula
url 'http://download.plt-scheme.org/bundles/372/mz/mz-372-src-unix.tgz'
homepage 'http://plt-scheme.org/'
md5 'c755f4ba7191636c5eb587745e4c6a67'
version '4.2.5'
fails_with_llvm "Unsupported inline asm", :build => 2335
@dylanvee
dylanvee / server.js
Created February 15, 2012 22:39 — forked from mixonic/server.js
Node.js + Socket.io + Bash. A collaborative terminal for your browser.
//
// This server will start a bash shell and expose it
// over socket.io to a browser. See ./term.html for the
// client side.
//
// You should probably:
//
// npm install socket.io
// curl -O https://github.com/LearnBoost/Socket.IO/raw/master/socket.io.min.js
//
@dylanvee
dylanvee / gist:2315649
Created April 6, 2012 01:06
gem install camellia
dylan@dmv-vmware:~$ gem install camellia
Fetching: camellia-2.7.0-x86-linux.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing camellia:
ERROR: Failed to build gem native extension.
/home/dylan/.rvm/rubies/ruby-1.9.3-p125/bin/ruby extconf.rb
Unzipping Camellia library...
Configuring Camellia library...
Compiling and installing Camellia library...
@dylanvee
dylanvee / gist:2407930
Created April 17, 2012 18:14
EBImage build failure with clang
> source("http://bioconductor.org/biocLite.R")
BiocInstaller version 1.4.3, ?biocLite for help
> biocLite("EBImage")
BioC_mirror: http://bioconductor.org
Using R version 2.15, BiocInstaller version 1.4.3.
Installing package(s) 'EBImage'
trying URL 'http://www.bioconductor.org/packages/2.10/bioc/src/contrib/EBImage_3.12.0.tar.gz'
Content type 'application/x-gzip' length 4738660 bytes (4.5 Mb)
opened URL
==================================================
@dylanvee
dylanvee / gist:3392923
Created August 19, 2012 06:49
SSH *.lxc
# based on http://www.stgraber.org/2012/07/17/easily-ssh-to-your-containers-and-vms-on-ubuntu-12-04-lts/
Host *.lxc
User ubuntu
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
ProxyCommand nc $(host $(echo %h | sed "s/.lxc//g") 10.0.3.1 | tail -1 | awk '{print $NF}') %p
@dylanvee
dylanvee / gist:3408404
Created August 20, 2012 22:10
db/ndb query example
from google.appengine.ext import db, ndb
class OldBananaStand(db.Model):
contains_money = db.BooleanProperty()
class NewBananaStand(ndb.Model):
contains_money = ndb.BooleanProperty()
old_ones = OldBananaStand.all()
old_ones.filter('contains_money = True') # => ok!
@dylanvee
dylanvee / gist:3409230
Created August 20, 2012 23:27
ndb reference property
from google.appengine.ext import ndb
class ReferenceProperty(ndb.KeyProperty):
def _validate(self, value):
if not isinstance(value, ndb.Model):
raise TypeError('expected an ndb.Model, got %s' % repr(value))
def _to_base_type(self, value):
return value.key
@dylanvee
dylanvee / gist:3409403
Created August 20, 2012 23:54
db/ndb protocol buffer serialization
from google.appengine.ext import db, ndb
from google.appengine.datastore import entity_pb
def db_entity_to_protobuf(e):
return db.model_to_protobuf(e).Encode()
def protobuf_to_db_entity(pb):
# precondition: model class must be imported
return db.model_from_protobuf(entity_pb.EntityProto(pb))
@dylanvee
dylanvee / gist:3410076
Created August 21, 2012 00:50
conditionally async tasklet decorator
from google.appengine.ext import ndb
def tasklet(func):
"""Tasklet decorator that lets the caller specify either async or sync
behavior at runtime.
If make_sync is False (the default), the tasklet returns a future and
can be used in asynchronous control flow from within other tasklets
(like ndb.tasklet). If make_sync is True, the tasklet will wait for its
results and return them, allowing you to call the tasklet from synchronous
@dylanvee
dylanvee / gist:3410107
Created August 21, 2012 00:58
tasklet control flow example
# from https://developers.google.com/appengine/docs/python/ndb/async
@ndb.tasklet
def get_cart_async(acct):
cart = yield CartItem.query(CartItem.account == acct.key).fetch_async()
yield ndb.get_multi_async([item.inventory for item in cart])
raise ndb.Return(cart)
@ndb.tasklet
def get_offers_async(acct):