Skip to content

Instantly share code, notes, and snippets.

@ddribin
ddribin / gist:5745315
Last active December 18, 2015 07:19
My favorite new feature of ack, version 2.
% ack --bar
?IIIIIII7II?????+
~III777II777I?+==++==+:
???I7I???I7II++=====++===
??+??????????+===~~=+++??==+
??+??II??????+==~=~~=+++++==++
I+?????????+?+====~=~==+==++?==?
?????II?????+++++=======?===~~~~==
,?????II????????++++====~===::~~~~:~
I?I??II?+++??+?+++==~~~~:~:~:,:,,:::~
@ddribin
ddribin / gist:5218545
Last active December 15, 2015 06:48
Sick of typing `man git <foo>` and having it not work? Here's a fix (for zsh, at least).
man() { command man "${(j:-:)@}" }
@ddribin
ddribin / gist:5158614
Created March 14, 2013 03:35
Evil KVO context hack using macros + C99 compound literal syntax.
// Building upon: http://www.dribin.org/dave/blog/archives/2008/09/24/proper_kvo_usage/
// Defines a unique KVO context by taking the address of a 2-element string array.
// Using __FILE__ ensures the address is unique across source files, even with link time optimization.
#define DDDefineContext(_X_) static void * _X_ = &(const char *[] ) {#_X_, __FILE__}
// Example Definition
DDDefineContext(MyFooContext);
// Example Usage. No need for &MyFooContext to make it unique.
- (void)startObserving
--------------------- Named Begin ------------------------
**Unmatched Entries**
client 109.230.217.209 query (cache) 'isc.org/ANY/IN' denied: 1 Time(s)
client 176.31.232.211 query (cache) 'isc.org/ANY/IN' denied: 1 Time(s)
client 206.217.209.30 query (cache) 'isc.org/ANY/IN' denied: 2 Time(s)
client 216.121.58.25 query (cache) 'abkkdnaacalxv0000dcaaabaaafbckdj.isc.org/ANY/IN' denied: 1 Time(s)
client 216.121.58.25 query (cache) 'aeohjdaacalxv0000dcaaabaaafbckdj.isc.org/ANY/IN' denied: 1 Time(s)
client 216.121.58.25 query (cache) 'agjgkjaacalxv0000dcaaabaaafbckdj.isc.org/ANY/IN' denied: 1 Time(s)
@ddribin
ddribin / gist:1946836
Created March 1, 2012 02:42
Animating with Autolayout
// Find out where the frames will be with the "after" layout
1. Remove the "before" constraints
2. Add the "after" constraints
3. Call [window layoutIfNeeded], to force the frames to update
4. Grab the frames of all the views I want to animate and save them off
// Go back to what the user sees
5. Remove the "after" constraints
6. Add the "before" constraints
7. Call [window layoutIfNeeded], to force the frames to update
-(IBAction)startWorking:(id)sender {
[self showIndeterminateProgressBar];
self.future = [worker startAsyncWork];
[future onCompletion:^(id result, NSError * error) {
// we got a result!
[self hideIndeterminateProgressBar];
self.future = nil;
}];
#!/bin/sh
# OBJC_HELP=1 causes the Objective-C runtime to spit out help to stderr
# Pulling in osx/cocoa causes the runtime to be loaded via RubyCocoa
# Redirect sterr to stdout so we can pipe the results through pager
OBJC_HELP=1 /usr/bin/ruby -rosx/cocoa -e '' 2>&1
% diceware -nbd -g 4
Generating a 4 word passphrase.
You may need to move the mouse or type in another window to generate entropy.
Dice: 23315 25314 16526 46262
Passphrase: donna fear chord posit
Beale passphrase: dose femur churn propel
module Options
( Options
, parseArgs
) where
import System.Console.GetOpt
import Data.Maybe ( fromMaybe )
data Options = Options
{ optVerbose :: Bool
//
// ViewA.m
// test
//
// Created by Duncan Wilcox on 5/7/11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import "ViewA.h"