Skip to content

Instantly share code, notes, and snippets.

View dylanvee's full-sized avatar

Dylan Vassallo dylanvee

View GitHub Profile
[
{ "keys": ["super+left"], "command": "prev_view" },
{ "keys": ["super+right"], "command": "next_view" }
]
if (status == CL_BUILD_PROGRAM_FAILURE) {
// Determine the size of the log
size_t log_size;
clGetProgramBuildInfo(program, devices[0], CL_PROGRAM_BUILD_LOG, 0, NULL, &log_size);
// Allocate memory for the log
char *log = (char *) malloc(log_size);
// Get the log
clGetProgramBuildInfo(program, devices[0], CL_PROGRAM_BUILD_LOG, log_size, log, NULL);
Sometimes you learn from Codecademy; sometimes you learn from real-life experience. Yesterday, Codecademy was offline for almost 24 hours. We want to apologize and explain what happened.
What happened?
At 1:09AM EST on Wednesday 2/13, we took Codecademy down to deal with a database migration issue we were facing. We tweeted about it at 1:30. Then we spent the next 24 hours behind the scenes to iron out the issue.
How did it happen?
Like most web applications, Codecademy stores its information — everything from your submissions in exercises to new accounts — in a database. We use a technology called MongoDB (by our friends at 10gen) to do this. Our databases have hundreds of millions of items in them and are growing larger by the second. We've been working to change the configuration of our databases so that we can migrate our data to new database structures, laying a solid foundation for future developments and features.
@dylanvee
dylanvee / jruby_mina_sshd_example.rb
Created October 3, 2012 05:58
JRuby + Apache MINA SSHD
# First, download a binary distribution from
# http://mina.apache.org/sshd/sshd-070.html
# and copy lib/*.jar to your cwd
# Load all the jar files
require 'java'
Dir['./*.jar'].each {|jar| require jar }
# Import some Java classes
java_import java.util.EnumSet
@dylanvee
dylanvee / jruby_mina_sshd_publickey_example.rb
Created October 3, 2012 06:11
JRuby + Apache Mina SSHD public key
require 'net/ssh'
class CustomPublickeyAuthenticator
include PublickeyAuthenticator
def authenticate(username, key, session)
key = String.from_java_bytes(key.getEncoded)
key = [OpenSSL::PKey::RSA.new(key).to_blob].pack('m0')
# The key is now a string
# Your public key authentication magic here
@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):
@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: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: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: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