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
function pp(object, depth, embedded) { | |
typeof(depth) == "number" || (depth = 0) | |
typeof(embedded) == "boolean" || (embedded = false) | |
var newline = false | |
var spacer = function(depth) { var spaces = ""; for (var i=0;i<depth;i++) { spaces += " "}; return spaces } | |
var pretty = "" | |
if ( typeof(object) == "undefined" ) { pretty += "undefined" } | |
else if ( typeof(object) == "boolean" || | |
typeof(object) == "number" ) { pretty += object.toString() } | |
else if ( typeof(object) == "string" ) { pretty += "\"" + object + "\"" } |
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
#!/usr/bin/env ruby | |
require 'net/http' | |
require 'json' | |
require 'addressable/uri' | |
@debug_messages = false | |
token = '[TOKEN GOES HERE]' | |
user = '[USER NAME GOES HERE}' |
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
412038: A. Lawrence Foster,A. Foster | |
401531: Aaron Bliss | |
401856: Aaron Brown | |
402077: Aaron Burr | |
402697: Aaron Cochrane | |
402968: Aaron Cragin | |
404210: Aaron Ford | |
404891: Aaron Hackley | |
405068: Aaron Harding | |
405086: Aaron Harlan |
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
require 'dm-core' | |
require 'dm-migrations' | |
DataMapper.setup(:default, "mysql://localhost/test") | |
class TotallyContrivedForThisExample | |
include DataMapper::Resource | |
property :id, Serial # already part of the primary key | |
property :plerp, String, :key => true # Adds this to the primary key |
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
# You can get cmudict, a phonetic dictionary of english used for speech recognition purposes, here: http://svn.code.sf.net/p/cmusphinx/code/trunk/cmudict/cmudict.0.7a | |
entries = File.open('/Users/ted/data/cmudict.0.7a.txt').read.split("\n"); '' | |
dict = entries.map{ |e| e.split }.reject{ |e| e.first =~ /^;;;/}; '' | |
results = dict.map do |entry| | |
char_count = entry.first.size | |
phonemes = entry.slice(1,entry.size) | |
phonemes.select{ |p| p =~ /\d/ }.size == 4 ? [entry, char_count] : nil; | |
end.compact.sort_by{ |e| e.last }; results.size |
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
// Fetch and append the current temperature | |
function fetchAndAppendWeather() { | |
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet(); | |
var sheet = spreadsheet.getActiveSheet(); | |
// All the actual work is done in the top row. | |
// We get the link stored in cell A1 (say http://www.wunderground.com/cgi-bin/findweather/getForecast?query=02217 ) | |
var weatherLink = sheet.getRange("A1").getValue(); | |
// we set a formula importing a targeted portion of the web page |
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
grammar SQL | |
rule statement | |
select_statement <Veritas::SQL::Select> | |
| set_operation_statement <Veritas::SQL::SetOperation> | |
| "(" [\s]* statement [\s]* ")" | |
end | |
rule set_operation_statement | |
"(" [\s]* left:select_statement <Veritas::SQL::Select> [\s]* ")" | |
[\s]* set_operator ([\s]+ distinct:`DISTINCT`)? [\s]* |
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
$ lftp -d newftp.epa.gov | |
> user anonymous | |
> set ftp:ssl-allow false | |
> ls | |
> cd GKM_DOCUMENTS | |
> mirror -c FOIA_PROD_7.29.16 |
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
var elide = function(arr) { | |
// assume arr is sorted, or put it through a sort right here. | |
var tokens = []; // this'll be what gets output at the end. | |
var startOfRun = arr[0]; // pretend we have a stack. This is the first value pushed onto the stack. | |
var currentEndOfRun = startOfRun; // this is the top of our pretend stack. | |
var coalesce = function(start, end){ return "" + ((start != end) ? ""+start+"-"+end : start); } | |
// Consider each number in the array and it's relationship to the current run on the stack. | |
for (var i=1; i < arr.length; i++) { | |
// If the nextNumber is adjacent to the value at the top of the stack |
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
# Make sure we've got readline on ubuntu | |
sudo apt-get install libreadline-dev | |
# copied from https://github.com/postmodern/ruby-install | |
wget -O ruby-install-0.3.2.tar.gz https://github.com/postmodern/ruby-install/archive/v0.3.2.tar.gz | |
# might be worth checking the gpg signature of the file you're installing per | |
# postmodern's instructions. Install his key from here: http://postmodern.github.io/contact.html#pgp | |
# and then uncomment the lines below. |
NewerOlder