This file contains 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
@interface TestClass : NSObject { | |
#if NS_BLOCKS_AVAILABLE | |
void (^blk)(void); | |
#endif | |
} | |
- (id)initWithBlock:(void (^)(void))block; | |
- (void)exec; | |
@end | |
@implementation TestClass |
This file contains 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
# Add your own tasks in files placed in lib/tasks ending in .rake, | |
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. | |
require File.expand_path('../config/application', __FILE__) | |
require 'rake' | |
################################ | |
# fixes rake 0.9 bug w/ rails | |
################################ | |
module ::RailsAppNameHere |
This file contains 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
^((29\/0?2(?=\/(\d{2}(0[48]|[13579][26]|[2468][048])| | |
([13579][26]|[2468][048])00))|([01]?\d|2[0-8])\/(0?\d|1[0-2])| | |
(29|30)\/(0?[13-9]|1[0-2])|31\/(0?[13578]|1[02]))\/\d{4})$ |
This file contains 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 GB_ALLOW_LOG 1 | |
#if GB_ALLOW_LOG | |
#define GB_LOG(fmt, ...) NSLog(fmt, ##__VA_ARGS__) | |
#else | |
#define GB_LOG(fmt, ...) | |
#endif |
This file contains 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
Dir['**/*.rb', '**/*.rake'].each { |f| | |
s = open(f).read | |
awesome_rx = /(?<!return)(?<!:)(?<!\w)(\s+):(\w+)\s*=>/ | |
count = s.scan(awesome_rx).length | |
next if count.zero? | |
s.gsub!(awesome_rx, '\1\2:') | |
puts "#{count} replacements @ #{f}" | |
open(f, 'w') { |b| b << s } | |
} |
This file contains 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
class Array | |
def pinject(memo, &block) | |
inject(memo) { |all, curr| block.call(all, curr); all } | |
end | |
def hash_by | |
return {} unless block_given? | |
pinject({}) { |all, curr| | |
# yield = block to extract key from an item |
This file contains 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
# usage: ge devise | |
ge() { | |
gem=`bundle show $1` | |
if [[ "$gem" =~ ^/ ]]; | |
then | |
echo "$gem" | |
`subl $gem` | |
else | |
echo "gem not found" |
This file contains 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
@mixin high_pixel_ratio { | |
@media screen and | |
(-webkit-min-device-pixel-ratio: 2), | |
(min--moz-device-pixel-ratio: 2), | |
(min-resolution: 2dppx), | |
(min-resolution: 192dpi) { | |
@content; | |
} | |
} |
This file contains 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
class Array | |
DESC_RX = /\s*desc$/i | |
ASC_DESC_RX = /\s*(?:asc|desc)$/i | |
def order(by) | |
by = by.split(',').map(&:strip) | |
sort do |a, b| | |
by_is_desc = by.map { |col| col =~ DESC_RX } | |
by_cols = by.map { |col| col.sub(ASC_DESC_RX, "") } |
This file contains 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
// app.js | |
var config = require("config/app"); | |
console.log(config.dbProvider); |
OlderNewer