Skip to content

Instantly share code, notes, and snippets.

vmrun version 1.13.0 build-1331545
Usage: vmrun [AUTHENTICATION-FLAGS] COMMAND [PARAMETERS]
AUTHENTICATION-FLAGS
--------------------
These must appear before the command and any command parameters.
@stevenhuey
stevenhuey / config.m
Created September 9, 2013 15:58
Barista Server Config.
- (void)runWithURL:(NSURL*)serverRoot onPort:(NSUInteger)port
{
_server = [BARServer serverWithPort:port];
[_server addGlobalMiddleware:[MarkdownTemplateRenderer rendererWithViewsDirectoryURL:serverRoot]];
BARRouter *router = [[BARRouter alloc] init];
[_server addGlobalMiddleware:router];
[router addRoute:@"/:view" forHTTPMethod:@"GET" handler:^BOOL(BARConnection *connection, BARRequest *request, NSDictionary *parameters)
@stevenhuey
stevenhuey / barista.m
Created September 9, 2013 15:57
Barista Markdown Demo
-(void)willSendResponse:(BARResponse*)response
forRequest:(BARRequest*)request
forConnection:(BARConnection*)connection
continueHandler:(void (^)(void))handler
{
NSString* viewName = [response customValueForKey:@"BARTemplateView"];
if (viewName)
{
NSURL *viewURL = [[self.viewsDirectoryURL URLByAppendingPathComponent:viewName] URLByAppendingPathExtension:[[self class] templateFileExtension]];
// Instead of writing
STAssertEqualObjects(@"foo", @"foo", @"Expected 'foo', but was....");
// With Expecta we can write
expect(@"foo").to.equal(@"foo);
@stevenhuey
stevenhuey / hrefs.rb
Created May 2, 2013 20:57
Given a page, use the Nokogiri gem to find all the HREFs (links) on the page.
# Given a page use the Nokogiri gem to find all the HREFs (links) on the page
require 'nokogiri'
require 'open-uri'
def getAllHrefsInPage(page)
doc = Nokogiri::HTML(open(page))
links = doc.css('a')
hrefs = links.map {|link| link.attribute('href').to_s}.uniq.sort.delete_if {|href| href.empty?}
@stevenhuey
stevenhuey / SuperDebuggerDemoSetup.sh
Created March 4, 2013 00:16
Steps to clone and setup the Xcode project.
git clone https://github.com/stevenhuey/SuperDebuggerDemo.git
cd SuperDebuggerDemo
git submodule update --init --recursive
open Frameworks/superdb/
@stevenhuey
stevenhuey / ProjectSetup.sh
Created February 18, 2013 14:03
Steps to setup the example project for trying PonyDebugger.
> git clone git://github.com/stevenhuey/UICollectionViewExample.git
> cd UICollectionViewExample
> mkdir Frameworks
> git submodule add -f git://github.com/square/PonyDebugger.git Frameworks/PonyDebugger
> git submodule update --init --recursive
@stevenhuey
stevenhuey / PonyDebuggerSetup.m
Created February 9, 2013 18:25
Our changes to the application:didFinishLaunchingWithOptions: method.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
fDebugger = [PDDebugger defaultInstance];
[fDebugger enableNetworkTrafficDebugging];
[fDebugger forwardAllNetworkTraffic];
[fDebugger enableCoreDataDebugging];
[fDebugger addManagedObjectContext:self.managedObjectContext withName:@"Popular on 500px"];
@stevenhuey
stevenhuey / sugar2.m
Created December 7, 2012 19:29
ObjectiveSugar2
NSArray *cars = [@"Testarossa", @"F50", @"F458 Italia"];
// or NSSet *cars = [NSSet setWithObjects:@"Testarossa", @"F50", @"F458 Italia", nil];
[cars map:^id(id car){
return @([[car substringToIndex:1] isEqualToString:@"F"]);
}];
// NO (Testarossa)
// YES (F50)
// YES (F458 Italia)
@stevenhuey
stevenhuey / sugar.m
Created December 7, 2012 19:25
ObjectiveSugar
[@3 times:^{
NSLog(@"Hello World!");
}];
// Hello World!
// Hello World!
// Hello World!