Skip to content

Instantly share code, notes, and snippets.

pnc / gist:d6f84f65ea1dbc73367d
Created Dec 2, 2014
Build failures on 76c22f4959ff12ecef3c43c11af2394d31bfc8d4,
View gist:d6f84f65ea1dbc73367d
$ ruby --version
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin13.0]
$ bundle exec rake
rm -rf banana-lib && tar zxf banana-lib.tar.gz
Using ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin13.0]
pnc /
Last active May 12, 2020
Using Erlang observer/appmon remotely

Using OTP's observer (appmon replacement) remotely

$ ssh remote-host "epmd -names"
epmd: up and running on port 4369 with data:
name some_node at port 58769

Note the running on port for epmd itself and the port of the node you're interested in debugging. Reconnect to the remote host with these ports forwarded:

$ ssh -L 4369:localhost:4369 -L 58769:localhost:58769 remote-host
pnc / NSInputStreamRead.m
Created Mar 12, 2014
Read NSInputStream and generate SHA of contents
View NSInputStreamRead.m
#import <CommonCrypto/CommonDigest.h>
// From the people who brought you goto fail;
static char PIHexbyteMap[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
static int PIHexbyteMapLen = sizeof(PIHexbyteMap);
/* Utility function to convert nibbles (4 bit values) into a hex character representation */
static char
View gist:9400090
[2014-03-06T21:15:52+00:00] INFO: Forking chef instance to converge...
[2014-03-06T21:15:52+00:00] INFO: *** Chef 11.10.4 ***
[2014-03-06T21:15:52+00:00] INFO: Chef-client pid: 1478
[2014-03-06T21:15:53+00:00] INFO: Setting the run_list to ["recipe[dashboard::default]"] from JSON
[2014-03-06T21:15:53+00:00] INFO: Run List is [recipe[dashboard::default]]
[2014-03-06T21:15:53+00:00] INFO: Run List expands to [dashboard::default]
[2014-03-06T21:15:53+00:00] INFO: Starting Chef Run for saucy
[2014-03-06T21:15:53+00:00] INFO: Running start handlers
[2014-03-06T21:15:53+00:00] INFO: Start handlers complete.
[2014-03-06T21:15:53+00:00] INFO: directory[/var/spool/rsyslog] owner changed to 0
pnc / section.m
Created Feb 1, 2013
Example of using ATV.
View section.m
ATVManagedTableSection *inboxSection = [[ATVManagedTableSection alloc] initWithIdentifier:@"inbox"];
[inboxSection setManagedObjectContext:context andFetchRequest:fetchRequest];
[inboxSection registerNib:@"PIMessageCell" forIdentifier:@"PIMessageCell"];
[inboxSection setCellSource:^UITableViewCell *(ATVTableSection *section, NSUInteger index, id object) {
UITableViewCell *cell = [section dequeueReusableCellWithIdentifier:@"PIMessageCell"];
return cell;
[inboxSection setConfigureCell:^(ATVTableSection *section, UITableViewCell *cell, NSUInteger index, id object) {
PIMessageCell *messageCell = (PIMessageCell *)cell;
[messageCell setMessage:object];
pnc /
Created Nov 8, 2012
Get CocoaPods (almost) to compile xcdatamodel resources as it copies them, like it does XIBs
echo "`basename $1 .xcdatamodel`.mom"
echo "`basename ${1} .xcdatamodel`.mom"
xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename ${1} .xcdatamodel`.mom"
pnc /
Last active Oct 12, 2015
Randomize link quality

Creating an awful Wi-Fi network

  1. Plug an Ethernet cable into your computer. You'll need this for Internet connectivity while your Wi-Fi card is used to create a network.

  2. Enable Internet Sharing in System Preferences.

  3. Get your phone connected to the network you just created and make sure you can browse the web.

  4. Ensure dummynet'd packets are still routed through the normal rules so masquerading works:

     eleos@Nebula ~$ sudo sysctl -w net.inet.ip.fw.one_pass=0
     net.inet.ip.fw.one_pass: 0 -> 0
pnc / NSDictionary+Inflector.h
Created Nov 5, 2012
(Possibly broken) camel-case / underscore inflection in Objective-C
View NSDictionary+Inflector.h
#import <Foundation/Foundation.h>
@interface NSDictionary (Inflector)
- (NSDictionary *)underscoredDictionaryWithPrefix:(NSString *)prefix andSuffix:(NSString *)suffix;
pnc / PCPropertyObserver.c
Created Aug 31, 2012
View PCPropertyObserver.c
// © 2011 Phillip N. Calvin
// For use in a setter.
// Signs up self to receive KVO notifications about given properties
// on any new value and removes self as an observer from the old value.
// For example, to observe properties of a property called customer
// (backed by ivar _customer):
// PCPropertyObserver(customer, @"allowSubscriptionPurchase", @"availableProducts");
// You'd need to write this selector yourself:
pnc / AppDelegate.m.patch
Created Apr 6, 2012
Fix to Marcus Zarra's consecutive migration code
View AppDelegate.m.patch
--- 1.txt 2012-04-06 14:09:33.000000000 -0400
+++ 2.txt 2012-04-06 14:09:45.000000000 -0400
@@ -119,28 +119,35 @@
//See if we can find a matching destination model
NSMappingModel *mappingModel = nil;
You can’t perform that action at this time.