Skip to content

Instantly share code, notes, and snippets.

View cjlarose's full-sized avatar

Chris LaRose cjlarose

View GitHub Profile
@cjlarose
cjlarose / genome_browser.js
Last active January 2, 2016 18:39
GenomeBrowser iRODS Web Context Example
define(['datastore', 'backbone', 'jquery', 'underscore'], function(Datastore, Backbone, $, _) {
var GenomeBrowser = {
Views: {}
};
GenomeBrowser.URL_PLACEHOLDER = '$my_url';
GenomeBrowser.Views.MainView = Backbone.View.extend({
tagName: 'div',
initialize: function() {
@cjlarose
cjlarose / version_number.py
Last active January 3, 2016 04:29
Django VersionNumberField
import struct
from django.db import models
from south.modelsinspector import add_introspection_rules
add_introspection_rules([], ["^core\.fields\.version_number\.VersionNumberField"])
class VersionNumber(object):
def __init__(self, major, minor=0, patch=0, build=0):
self.number = (int(major), int(minor), int(patch), int(build))
def __str__(self):
@cjlarose
cjlarose / Dockerfile
Created February 16, 2014 07:56
Thrift Dockerfile
FROM base:ubuntu-12.10
RUN apt-get update
RUN apt-get install -y thrift-compiler
ENTRYPOINT ["/usr/bin/thrift"]
@cjlarose
cjlarose / Vagrantfile
Created March 7, 2014 18:37
Minimal Vagrantfile for Docker development
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
end
@cjlarose
cjlarose / check_vmstat.py
Created March 11, 2014 01:54
vmstat Nagios plugin
#!/usr/bin/env python
import subprocess
import sys
class PerformanceData:
def __init__(self):
self.data = {}
def __setitem__(self, key, value):
@cjlarose
cjlarose / keybase.md
Last active August 29, 2015 14:01
keybase.md

Keybase proof

I hereby claim:

  • I am cjlarose on github.
  • I am cjlarose (https://keybase.io/cjlarose) on keybase.
  • I have a public key whose fingerprint is 0111 205E B8EC C042 816C 0D2F AFB8 B897 5C69 8338

To claim this, I am signing this object:

@cjlarose
cjlarose / my_cool_model.rb
Created September 18, 2014 22:46
Rails 4.1 filtering by enums
class MyCoolModel < ActiveRecord::Base {
enum :status => [:started, :in_progress, :completed]
# What I'd like to work
scope :not_completed -> { where('status' => [:in_progress, :started]) }
# Hacky workaround
scope :not_completed -> { where('status' => MyCoolModel.statuses.values_at(:in_progress, :started)) }
}
@cjlarose
cjlarose / integer_test.c
Last active August 29, 2015 14:09
MIN_INT fail
void printint(int);
int f() {
int n;
n = -2147483648;
printint(n);
return n;
}
OPENCLC=/System/Library/Frameworks/OpenCL.framework/Libraries/openclc
BUILD_DIR=./build
EXECUTABLE=main
.SUFFIXES:
KERNEL_ARCH=i386 x86_64 gpu_32 gpu_64
BITCODES=$(patsubst %, mykernel.cl.%.bc, $(KERNEL_ARCH))
$(EXECUTABLE): $(BUILD_DIR)/mykernel.cl.o $(BUILD_DIR)/main.o $(BITCODES)
clang -framework OpenCL -o $@ $(BUILD_DIR)/mykernel.cl.o $(BUILD_DIR)/main.o
@cjlarose
cjlarose / download.sh
Created July 18, 2015 18:53
Download KGS game recrods
wget -r -l1 -H -t1 -nd -N -A.bz2 -erobots=off http://u-go.net/gamerecords/
for f in *.tar.bz2; do tar xf $f; done