This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"".join([chr(ord(l)-(i+1)) for i, l in enumerate("TWSIWTPVSK")]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from splunk import auth, entity | |
from remoteobjects import fields, RemoteObject | |
class SplunkObject(RemoteObject): | |
@classmethod | |
def get_path(cls): | |
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Javascript variant | |
var ListingsController = { | |
"index": function(req, res) { | |
var listings = listing.Listing.find({}, function(err, docs) { | |
res.send(docs); | |
}); | |
}, | |
"create": function(req, res) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo | |
constructor: -> | |
name: -> | |
@bar = 'foo' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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({}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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], |
This simple bar chart is constructed from a TSV file storing the frequency of letters in the English language. The chart employs conventional margins and a number of D3 features:
- d3.tsv - load and parse data
- d3.format - format percentages
- d3.scale.ordinal - x-position encoding
- d3.scale.linear - y-position encoding
- d3.max - compute domains
- d3.svg.axis - display axes
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:
- d3.csv - load and parse data
- d3.scale.ordinal - x-position encoding and color encoding
- d3.scale.linear - y-position encoding
- d3.format - SI prefix formatting (e.g., “10M” for 10,000,000)
- d3.max - compute domains
- d3.keys - compute column names
- d3.svg.axis - display axes