Steve Spencer sspencer

View sql.js
1 2 3 4 5 6 7 8 9 10
// 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
View negative_lookahead.js
1 2 3 4
var crappy_xml = "<tag>some forget to encode & others &lt;do not&gt;</tag>";
 
// negative lookahead
crappy_xml.replace(/&(?!(\S+;))/g, '&amp;')
View closure.sh
1 2 3 4
closurejs()
{
curl -s --data output_info=compiled_code --data-urlencode js_code@${1} http://closure-compiler.appspot.com/compile
}
View repl.js
1 2 3 4 5 6 7 8 9 10
// 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());
View SomeNetworkOperation.m
1 2 3 4 5 6 7 8 9
// 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
View FormatThousandsSeparator.m
1 2 3
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
[formatter setNumberStyle:NSNumberFormatterDecimalStyle];
NSLog(@"formatted: %@", [formatter stringFromNumber:[NSNumber numberWithInt:1234567]]);
View unitedstates.php
1 2 3 4 5 6 7 8 9 10
$UnitedStates = array(
"AL" => "Alabama",
"AK" => "Alaska",
"AZ" => "Arizona",
"AR" => "Arkansas",
"CA" => "California",
"CO" => "Colorado",
"CT" => "Connecticut",
"DE" => "Delaware",
"FL" => "Florida",
View unitedstates.html
1 2 3 4 5 6 7 8 9 10
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DE">Delaware</option>
<option value="FL">Florida</option>
<option value="GA">Georgia</option>
View location.sql
1 2 3 4 5 6 7 8 9 10
--
-- Mysql Functions and Idea from http://www.xarg.org/2009/12/people-near-you-with-mysql/
-- Stored procedures from Steve.
-- Not using `point`, could leave out field from location table.
--
 
CREATE TABLE IF NOT EXISTS `location` (
`vendor_id` INT unsigned NOT NULL,
`lat` decimal(10,6) NOT NULL,
`lon` decimal(10,6) NOT NULL,
View keep_current_file_open.sh
1 2 3 4 5 6 7 8 9 10
#! /bin/sh
 
# On alternate invocations, this script
# saves the path of the source file currently open in Xcode
# and restores the file at that path in Xcode.
#
# By setting Xcode (in Behaviors) to run this script when "Run Starts"
# and when "Run Completes", you can prevent it from switching to main.m
# when a run finishes.
# See http://stackoverflow.com/questions/7682277/xcode-4-2-jumps-to-main-m-every-time-after-stopping-simulator
Something went wrong with that request. Please try again.