Skip to content

Instantly share code, notes, and snippets.

View n8agrin's full-sized avatar
🐢

Nathan Agrin n8agrin

🐢
View GitHub Profile
"".join([chr(ord(l)-(i+1)) for i, l in enumerate("TWSIWTPVSK")])
@n8agrin
n8agrin / filemonitor.py
Created May 14, 2010 08:54
Simple file monitoring in python
import os, time
last_modified = None
def ease_sleep():
now = time.time()
if (now - last_modified) < 1:
print 'sleeping less'
time.sleep(0.001)
else:
time.sleep(1)
from splunk import auth, entity
from remoteobjects import fields, RemoteObject
class SplunkObject(RemoteObject):
@classmethod
def get_path(cls):
return None
@n8agrin
n8agrin / zeroneortwo.rb
Created April 17, 2011 16:36
create a naive generator that returns zero, one or two in even, random distribution
We couldn’t find that file to show.
# Javascript variant
var ListingsController = {
"index": function(req, res) {
var listings = listing.Listing.find({}, function(err, docs) {
res.send(docs);
});
},
"create": function(req, res) {
class Foo
constructor: ->
name: ->
@bar = 'foo'
@n8agrin
n8agrin / myclass.js
Created May 15, 2012 18:12
A simple, if old, class system for Javascript.
// The best javascript class system ever! This is old news to most, but
// more and more I find myself coming back to this. I don't have a vendetta
// against the `new` keyword. I just sometimes want encapsulation in a way
// that doesn't feel like a complete hack.
// Start with a closure
var vehicle = function() {
// Use Object.create
var vehicle = Object.create({});
@n8agrin
n8agrin / kruskal.js
Created September 5, 2012 02:33
Simple Kruskal's implementation
// See http://en.wikipedia.org/wiki/Kruskal's_algorithm
// and http://programmingpraxis.com/2010/04/06/minimum-spanning-tree-kruskals-algorithm/
var _ = require('underscore');
var nodes = ["A", "B", "C", "D", "E", "F", "G"];
var edges = [
["A", "B", 7], ["A", "D", 5],
@n8agrin
n8agrin / README.md
Last active December 11, 2015 02:09 — forked from mbostock/.block
@n8agrin
n8agrin / README.md
Last active December 11, 2015 02:09 — forked from mbostock/.block

This stacked bar chart is constructed from a CSV file storing the populations of different states by age group. The chart employs conventional margins and a number of D3 features: