Skip to content

Instantly share code, notes, and snippets.

@thepaul
thepaul / .gitconfig
Created January 20, 2011 18:23
i <3 my git xlog
[alias]
xlog = log --graph --pretty=format:\"%C(yellow)%h%Creset %ad %s%C(cyan)%d%Creset %C(green)[%an]%Creset\" --date=short
@thepaul
thepaul / gist:1171296
Created August 25, 2011 17:54
"git find" command
[alias]
; "git find" should work exactly like your system find (BSD or GNU), except for
; two things: one, it will always ignore the current git directory; and two, if
; you don't supply any root paths to search, it defaults to searching from your
; git project toplevel.
;
; paul cannon <p@thepaul.org> 2011
find = "!_() { \
declare -a preargs; \
You can specify the underlying name for a C function the linker/compiler should actually use. If you use an existing
function's name, it will just let you refer to it with your prototype's name. If you define the function, it'll give
it that name. It even complains if a function of that name already exists. Tested with clang on a Mac, but AFAIK also
works in GCC. You can even use special characters in your function names, like you can do in assembly.
// Extend NSWorkspace and add a method to test if the volume is a network mount
@implementation NSWorkspace (Extras)
- (BOOL)checkForNetworkMountAtPath:(NSString*)path {
struct statfs stat;
int err = statfs([path fileSystemRepresentation], &stat);
if (err == 0)
{
return !(stat.f_flags & MNT_LOCAL);
}
return NO;
@laynemoseley
laynemoseley / deploy.sh
Last active October 1, 2019 19:16
Zork deploy script
#!/bin/bash
echo "You enter a dark dungeon. A sign in front of you says: Choose wisely or you'll probably die."
read -p 'staging or production: ' ENV
if [ $ENV != "staging" ] && [ $ENV != "production" ]
then
echo "You go into the wrong hallway, a skeleton comes out and decapitates you. The End."
exit 1
fi
@sharplet
sharplet / KeychainItem.swift
Created April 25, 2020 23:57
A lightweight keychain wrapper for querying the keychain databse
// Copyright (c) 2019–20 Adam Sharp and thoughtbot, inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
@nevyn
nevyn / README.md
Created January 4, 2011 08:37
SPMediaKeyTap is a global event tap for the play/pause, prev and next keys on the keyboard. http://overooped.com/post/2593597587/mediakeys
@davedelong
davedelong / NSLocale.m
Last active October 15, 2022 08:02
Locales
/*
======================================================
THIS CODE IS FOR EDUCATIONAL PURPOSES ONLY.
I'M NOT RESPONSIBLE IF YOU SHIP THIS AND IT BLOWS UP IN YOUR FACE.
IF IT DOES AND YOU COMPLAIN TO ME I WILL LAUGH AT YOU.
@catlan
catlan / README.md
Last active February 27, 2023 16:19 — forked from zrxq/.lldbinit
Execute lldb command and open its output in Kaleidoscope diff

Diff output of two lldb commands

Setup

  1. Copy the contents of the last snippet (lldbinit) from the gist page, and paste into your .lldbinit file. This makes the ksdiff macro known inside lldb.
  2. Put file ksdiff.py in ~/.lldb/
  3. sudo pip install temp
  4. Restart Xcode debug session

Example

(lldb) ksdiff ;

anonymous
anonymous / syncs.d
Created February 9, 2015 00:02
#!/usr/sbin/dtrace -q -s
/*
Overly spammy, mostly covered by the other probes (every "read" or "write" is a "request")
CFPreferencesServer$target:::request {
printf("REQUEST from pid %d at %Y ( domain: %s, user: %s, host: %s, container: %s, managed: %d)\n", arg0, walltimestamp, copyinstr(arg1) != NULL ? copyinstr(arg1) : "(NULL)" ?: "(NULL)", copyinstr(arg2) != NULL ? copyinstr(arg2) : "(NULL)", copyinstr(arg3) != NULL ? copyinstr(arg3) : "(NULL)", copyinstr(arg4) != NULL ? copyinstr(arg4) : "(NULL)", arg5);
}
*/
CFPreferencesServer$target:::write_rejected {
printf("REJECTED WRITE OF KEY %s request from pid %d for reason %s at %Y ( domain: %s, user: %s, host: %s, container: %s)\n", copyinstr(arg1) != NULL ? copyinstr(arg1) : "(NULL)", arg0, copyinstr(arg6) != NULL ? copyinstr(arg6) : "(NULL)", walltimestamp, copyinstr(arg2) != NULL ? copyinstr(arg2) : "(NULL)", copyinstr(arg3) != NULL ? copyinstr(arg3) : "(NULL)", copyinstr(arg4) != NULL ? copyinstr(arg4) : "(NULL)", copyinstr(arg5) != NULL ? copyinstr(arg5)