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
$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
<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> |
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
-- | |
-- 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, |
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
#! /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 |
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
// Given the Star of David, arrange the numbers 1-12 (there are 12 intersections) so that | |
// each line (there are 6 lines and 4 intersections per line) adds up to 26. | |
// | |
// Intersections on array are numbered TDLR, from a0 to a11. | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <time.h> | |
// prototypes |
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 random | |
import sys | |
""" | |
Given the Star of David, arrange the numbers 1-12 (there are 12 intersections) so that | |
each line (there are 6 lines and 4 intersections per line) adds up to 26. | |
Intersections on array are numbered TDLR, from a0 to a11. | |
""" |
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
// using ARC, so no release / autorelease | |
AFHTTPClient *client = [AFHTTPClient clientWithBaseURL:[NSURL URLWithString:@"http://localhost"]]; | |
[client setAuthorizationHeaderWithUsername:@"steve" password:@"mypass"]; | |
NSURLRequest *request = [client requestWithMethod:@"GET" path:@"/auth.php" parameters:nil]; | |
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; | |
[operation | |
setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { | |
NSLog(@"success: %@", operation.responseString); |
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
int rgb = ((r&0x0ff)<<16)|((g&0x0ff)<<8)|(b&0x0ff); | |
int red = (rgb>>16)&0x0ff; | |
int green=(rgb>>8) &0x0ff; | |
int blue= (rgb) &0x0ff; |
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 http = require('http'); | |
// Working multiproxy - can call setTimeout multiple times. | |
function sendRequest(hostname) { | |
var client = http.createClient(80, hostname); | |
client.setTimeout(5000); | |
var req = client.request('GET', '/'); | |
client.addListener('timeout', function (error) { |