Want to create a Gist from your editor, the command line, or the Services menu? Here's how.
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
//http://www.mikeash.com/?page=pyblog/friday-qa-2009-08-14-practical-blocks.html | |
// NSURLConnection | |
@implementation NSURLConnection (BlocksAdditions) | |
+ (void)sendAsynchronousRequest: (NSURLRequest *)request | |
completionBlock: (void (^)(NSData *data, NSURLResponse *response, NSError *error))block | |
{ | |
NSThread *originalThread = [NSThread currentThread]; | |
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
# Config for Nginx to act as a front-end for Riak | |
# The main goal is to proxy all GETs directly to Riak, and disallow anything else (POST, PUT, etc) | |
# Also, disallow use of the map/reduce query links (i.e. /riak/bucket/key/_,_,_) | |
# Config is in /etc/nginx/sites-available/default or somewhere like that | |
# Set up load-balancing to send requests to all nodes in the Riak cluster | |
# Replace these IPs/ports with the locations of your Riak nodes | |
upstream riak_hosts { | |
server 127.0.0.1:8098; |
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
# Config for Nginx to act as a front-end for Riak | |
# The main goal is to proxy all GETs directly to Riak, and disallow anything else (POST, PUT, etc) | |
# Also, disallow use of the map/reduce query links (i.e. /riak/bucket/key/_,_,_) | |
# Config is in /etc/nginx/sites-available/default or somewhere like that | |
# Set up load-balancing to send requests to all nodes in the Riak cluster | |
# Replace these IPs/ports with the locations of your Riak nodes | |
upstream riak_hosts { | |
server 127.0.0.1:8098; |
With Rails 3.0 released a few weeks ago I've migrated a few apps and I'm constantly finding useful new improvements. One such improvement is the ability to log anything in the same way that Rails internally logs ActiveRecord and ActionView. By default Rails 3 logs look slightly spiffier than those produced by Rails 2.3: (notice the second line has been cleaned up)
Started GET "/" for 127.0.0.1 at Mon Sep 06 01:07:11 -0400 2010
Processing by HomeController#index as HTML
User Load (0.2ms) SELECT `users`.* FROM `users` WHERE (`users`.`id` = 3) LIMIT 1
CACHE (0.0ms) SELECT `users`.* FROM `users` WHERE (`users`.`id` = 3) LIMIT 1
Rendered layouts/_nav.html.erb (363.4ms)
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
#ifndef H_UTF8_MAPPED_UTF16_STRING_H_ | |
#define H_UTF8_MAPPED_UTF16_STRING_H_ | |
#import <Foundation/Foundation.h> | |
#import <string> | |
/* | |
* Convert a UTF-16 string to UTF-8, mapping indices to provide low-complexity | |
* range and index lookups. | |
* |
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
# How we store all time views across the entire system for http://gauge.es. | |
# All in one document that gets incremented using MongoDB $inc modifier in | |
# every track. The $inc increments t, year.t, year.month.t, year.month.day.t | |
# so we get to the day numbers. These are in EST, as we are in EST and these | |
# stats are just for us. :) Nothing amazing, but thought I would share. | |
# | |
# >> pp View.all_time | |
{ | |
"_id" => "all_time", | |
"t" => 502352, |
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
# iOS builds for ARMv7 and simulator i386. | |
# Assumes any dependencies are in a local folder called libs and | |
# headers in a local folder called headers. | |
# Dependencies should already have been compiled for the target arch. | |
PROJ=untitled | |
ifeq ($(IOS), 1) | |
ARCH=armv7 | |
DEVICE=OS | |
CC_FLAGS=-arch $(ARCH) |
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
#define _MEMO(iVarName, block) ^{if (!iVarName) {iVarName = (block)();} return iVarName;} | |
- (UIButton *)eatCheeseButton; | |
{ | |
return _MEMO(eatCheeseButton, ^{ | |
return [[UIButton alloc] init]; | |
})(); | |
} |
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/bash | |
# https://gist.github.com/949831 | |
# http://blog.carbonfive.com/2011/05/04/automated-ad-hoc-builds-using-xcode-4/ | |
# command line OTA distribution references and examples | |
# http://nachbaur.com/blog/how-to-automate-your-iphone-app-builds-with-hudson | |
# http://nachbaur.com/blog/building-ios-apps-for-over-the-air-adhoc-distribution | |
# http://blog.octo.com/en/automating-over-the-air-deployment-for-iphone/ | |
# http://www.neat.io/posts/2010/10/27/automated-ota-ios-app-distribution.html |
OlderNewer