This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"Extensions for making writing classes with accessors a bit less verbose" | |
ClassDescription extend [ | |
accessors: aString [ | |
self readers: aString. | |
self writers: aString. | |
] | |
readers: aString [ | |
aString substrings do: [:ivar | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# prevent the use of `` in tests | |
Spec::Runner.configure do |configuration| | |
backtick = nil # establish the variable in this scope | |
saved_system = nil | |
configuration.prepend_before(:all) do | |
# raise an exception if Kernel#` or Kernel#system is used | |
# in our tests, we want to ensure we're fully self-contained | |
Kernel.instance_eval do | |
backtick = instance_method(:'`') | |
saved_system = instance_method(:system) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Find out a files "creation time" | |
# Source: http://inessential.com/?comments=1&postid=3576 | |
mdls -name kMDItemContentCreationDate -raw #{f} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby -rubygems | |
# Unicode considerations: | |
# Set $KCODE to 'u'. This makes STDIN and STDOUT both act as containing UTF-8. | |
$KCODE = 'u' | |
# Since any Ruby version before 1.9 doesn't much care for Unicode, | |
# patch in a new String#utf8_length method that returns the correct length | |
# for UTF-8 strings. | |
UNICODE_COMPETENT = ((RUBY_VERSION)[0..2].to_f > 1.8) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(eval-after-load "yasnippet-bundle" | |
'(defadvice yas/expand (around mkhl-yas/expand-or-indent) | |
(let ((in-indentation? (looking-back (rx bol (0+ blank))))) | |
(if in-indentation? | |
(funcall (or (lookup-key (current-local-map) yas/trigger-key) | |
(lookup-key (current-global-map) yas/trigger-key))) | |
ad-do-it)))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Getting Loaded | |
// Source: http://googlemac.blogspot.com/2006/11/getting-loaded.html | |
@implementation Foo (FooBarAdditions) | |
... | |
@end | |
@interface Foo (FooBarAdditionsPrivateMethods) | |
+ (void) initializeBar; | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Define a protocol MyProtocol that inherits from the NSObject protocol. | |
// This way, calls to NSObject messages (release, retain, …) don’t warn. | |
// Source: http://www.mobileorchard.com/idprotocol-retainrelease-and-protocol-inheritance/ | |
@protocol MyProtocol<NSObject> | |
- (void)someMessage; | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Source: http://www.dribin.org/dave/blog/archives/2008/09/24/proper_kvo_usage/ | |
// Define a static object; strings are easily readable, which is a plus | |
static NSString *const kOpeningBalanceChanged = @"openingBalance changed"; | |
// Use it for the `context` parameter when adding KVO | |
[object addObserver:observer | |
forKeyPath:@"openingBalance" | |
options:options | |
context:kOpeningBalanceChanged]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby -wKU -rubygems | |
require "nokogiri" | |
def to_action(text) | |
doc = Nokogiri::XML(text) | |
doc.xpath('/action-recipes/snippet').each do |node| | |
txt = node.at('text') | |
txt.remove | |
snippet = txt.content |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Patch to `/usr/libexec/path_helper` to prevent hangs with long `PATH`s. | |
--- path_helper_bak 2009-05-07 15:54:37.000000000 +0200 | |
+++ path_helper 2009-06-04 10:51:39.000000000 +0200 | |
@@ -15,7 +15,7 @@ | |
for f in "$DIR" "$DIR".d/* ; do | |
if [ -f "$f" ]; then | |
for p in $(< "$f") ; do | |
- [[ "$NEWPATH" = *(*:)${p}*(:*) ]] && continue | |
+ egrep -q "(^|${SEP})${p}($|${SEP})" <<<"$NEWPATH" && continue | |
[ ! -z "$NEWPATH" ] && SEP=":" |