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
$UnitedStates = array( | |
"AL" => "Alabama", | |
"AK" => "Alaska", | |
"AZ" => "Arizona", | |
"AR" => "Arkansas", | |
"CA" => "California", | |
"CO" => "Colorado", | |
"CT" => "Connecticut", | |
"DE" => "Delaware", | |
"FL" => "Florida", |
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
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init]; | |
[formatter setNumberStyle:NSNumberFormatterDecimalStyle]; | |
NSLog(@"formatted: %@", [formatter stringFromNumber:[NSNumber numberWithInt:1234567]]); |
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
// Register your NetworkOperation class after creating your network engine | |
// someEngine = [[SomeEngine alloc] initWithHostName:SOME_API customHeaderFields:nil]; | |
// [someEngine registerOperationSubclass:[SomeNetworkOperation class]]; | |
// ------ SomeNetworkOperation.h ------ | |
#import "MKNetworkOperation.h" | |
@interface SomeNetworkOperation : MKNetworkOperation | |
@end |
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
// Simple embedded REPL | |
var repl = require("repl"); | |
repl.start({ | |
prompt: "karma> ", | |
input: process.stdin, | |
output: process.stdout, | |
eval: function(cmd, context, filename, callback) { | |
// cmd comes thru as "(ls\n)", get back to original "ls" | |
callback("You typed: " + cmd.substring(1, cmd.length-1).trim()); |
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
closurejs() | |
{ | |
curl -s --data output_info=compiled_code --data-urlencode js_code@${1} http://closure-compiler.appspot.com/compile | |
} |
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 crappy_xml = "<tag>some forget to encode & others <do not></tag>"; | |
// negative lookahead | |
crappy_xml.replace(/&(?!(\S+;))/g, '&') |
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: http://tomasz.janczuk.org/2013/05/multi-line-strings-in-javascript-and.html | |
function multiline(fn) { | |
return fn.toString().match(/[^]*\/\*([^]*)\*\/\}$/)[1].trim(); | |
} | |
// NOTE: exported objects are Strings, not functions | |
exports.getTour = multiline(function() {/* | |
SELECT | |
* | |
FROM |
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
// MarzulloAlgorithm in JavaScript | |
// | |
// Not quite what I need which is a list of ranges that contain a specified number. | |
// | |
'use strict'; | |
function Point(name, point, type) { | |
this.name = name; | |
this.point = point; | |
this.type = type; |
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
package command | |
import ( | |
"fmt" | |
"net" | |
"os" | |
) | |
const ( | |
message = "This process is already running in SOLO mode." |
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
// Golang UK Conference 2016 - Mat Ryer - Idiomatic Go Tricks | |
func StartTimer(name String) func() { | |
t := time.Now() | |
log.Println(name, "started") | |
return func() { | |
d := time.Now().Sub(t) | |
log.Println(name, "took", d) | |
} | |
} |