Skip to content

Instantly share code, notes, and snippets.

# The OSX Mavericks upgrade installer can totally corrupt group ownership of
# files in user home directories. Typically, it looks like the Mavericks installer
# simply sets (most? all?) of the files to the same gid as your uid, which may be nonsense.
# Specifically, most single-user OS X installs have uid=501 for the default user,
# so gid is typically 501 too.
# Step 0: make sure your user is still part of its group:
dseditgroup -o edit -t user -a <your_user_name> <your_user_name>
# (The second occurence of <your_user_name> is actually the group name)
@davepeck
davepeck / nonsense.m
Last active August 29, 2015 13:56
Strong/Weak/Strong Again
@property (strong, nonatomic) id observer;
// ...
- (void)startListening
{
__weak MyClass *wself = self;
self.observer =
[[NSNotificationCenter defaultCenter] addObserverForName:@"foo" object:nil queue:nil usingBlock:^(NSNotification *note){
MyClass *sself = wself;

Keybase proof

I hereby claim:

  • I am davepeck on github.
  • I am davepeck (https://keybase.io/davepeck) on keybase.
  • I have a public key whose fingerprint is A93D 3832 FDB8 179C 0BDE A8EB 876D DC96 FA1F 58D8

To claim this, I am signing this object:

@davepeck
davepeck / alien_example.txt
Last active August 29, 2015 13:58
Convert black-and-white sprites into... morse code?
Alien in base 16: 183C7EDBFF245AA5
Alien in base 32: 1GF3URFVI8ML5
Alien in base 36: D9NURFZQYYSL
Alien in morse, base 16: ['.----', '---..', '...--', '-.-.', '--...', '.', '-..', '-...', '..-.', '..-.', '..---', '....-', '.....', '.-', '.-', '.....']
Alien in morse, base 32: ['.----', '--.', '..-.', '...--', '..-', '.-.', '..-.', '...-', '..', '---..', '--', '.-..', '.....']
Alien in morse, base 36: ['-..', '----.', '-.', '..-', '.-.', '..-.', '--..', '--.-', '-.--', '-.--', '...', '.-..']
@davepeck
davepeck / interleave.py
Last active August 29, 2015 14:08
Random python iteration toy
def interleave(iterables, cmp=None, key=None, reverse=False):
"""
Given a collection of iterables, walk through them in
parallel, at each step yielding the current value
that comes first in the sort order, and advancing
that single iterator.
If each iterable is already sorted, this will produce
a total ordering. If not, it produces a 'greedy' ordering
@davepeck
davepeck / lev.coffee
Last active August 29, 2015 14:10
Levenshtein Distance in coffeescript
# Levenshtein distance with the ability to reward or punish
# longer contiguous matching runs (set contiguousBonus < 1.0 for rewards)
stringDistance = (s, t, deleteCost=1, insertCost=1, substitutionCost=1, contiguousBonus=1.0) ->
sLength = s.length
tLength = t.length
d = []
for i in [0..sLength]
d[i] = [{score: i, contiguous: 0}]
@davepeck
davepeck / yubnub.sh
Created August 31, 2009 00:05
On OSX, invoke yubnub directly from the command line. (I alias this file to 'y' so, for example, 'y gim dave peck')
#!/bin/bash
open "http://www.yubnub.org/parser/parse?command=$(echo -n "$*")"
#!/bin/sh
## script POMODORO for OSX! ##
# #
# requires the GNU gdate command to format dates #
# it's available through macports, in the coreutils package #
# this script also requires Growl to display notifications #
# #
# Times are coded as follows: #
# @ long break : 30 minutes #
@davepeck
davepeck / git-confusion.md
Created April 29, 2010 01:43
What is git trying to tell me?

I don't understand Git.

Why am I told I'm ahead of origin/master by 1 commit?

Why does it go away after what appears to be a no-op git push?

Here's an example interaction with git:

dave@machine ~/dev/project > git status

@davepeck
davepeck / what.md
Created January 15, 2011 02:27
Neato

Foo bar biz bazz!