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
module APIExposable | |
def expose_api(mod = nil, &block) | |
if mod.nil? | |
if block.nil? | |
raise "Either a module or a block that's used to create a module is required." | |
else | |
mod = Module.new(&block) | |
end | |
elsif mod && block | |
raise "Only a module *or* is required, not both." |
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
git=`sh /etc/profile; which git` | |
version=`$git describe --tags --always` | |
count=`$git rev-list --all | wc -l` | |
touch InfoPlist.h | |
echo -e "#define GIT_VERSION $version\n#define GIT_COMMIT_COUNT $count" > InfoPlist.h |
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 Base64 | |
def self.encode64(string) | |
result = NSData.alloc.initWithData(string).base64EncodedString | |
result = result.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion:true) | |
NSString.alloc.initWithData(result, encoding:NSUTF8StringEncoding) | |
end | |
def self.decode64(string) | |
data = NSData.dataFromBase64String(string) | |
NSString.alloc.initWithData(data, encoding:NSUTF8StringEncoding) |
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
Pod::Spec.new do |s| | |
s.name = 'KIF' | |
s.version = '0.0.1' | |
s.platform = :ios | |
s.license = 'Apache License, Version 2.0' | |
s.summary = 'Keep It Functional - iOS Test Framework' | |
s.homepage = 'https://github.com/square/KIF' | |
s.author = { 'Square' => 'kif-framework@googlegroups.com' } | |
s.source = { :git => 'https://github.com/square/KIF', |
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
// Omitted is a NSDictionary category which adds -[NSDictionary merge:dict] | |
@interface PersonFactory : Factory | |
@end | |
@implementation PersonFactory | |
- (NSDictionary *)validAttrs; | |
{ | |
return @{ @"name":@"Test Person %d", @"email":@"person-%d@example.com" }; |
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
Payment = Object.new | |
def Payment.new(who_cares); self; end | |
def Payment.fee_amount; self; end | |
def Payment.==(really_who_cares); true; end | |
describe Payment, "#fee_amount" do | |
it "returns 2.9% of $10 + $0.15 ($0.44)" do | |
payment = Payment.new(10.00) | |
payment.fee_amount.should == 0.44 | |
end |
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
#import <Cocoa/Cocoa.h> | |
#import "opencv2/imgproc/imgproc_c.h" | |
#import "opencv2/highgui/highgui_c.h" | |
#import "opencv2/objdetect/objdetect.hpp" | |
@interface OpenCV : NSObject { | |
int scale; | |
CvCapture* camera; |
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
# The problem: | |
# I wanted to test check_gem, which needs to be called | |
# in the initializer (well, *I* need it to be called in | |
# the initializer) | |
# | |
class Delicious < Base | |
def initialize username, password | |
check_gem | |
# ... |
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
=== Pure ruby | |
--------------------------------------------- | |
ChunkyPNG (0.10.2) decoding benchmark (n=20) | |
--------------------------------------------- | |
Rehearsal --------------------------------------------------------- | |
PNG - no filtering 2.290000 0.630000 2.920000 ( 1.643999) | |
PNG - UP filtering 4.470000 0.740000 5.210000 ( 2.775279) | |
PNG - PAETH filtering 6.210000 0.680000 6.890000 ( 3.806639) |
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
A backup of http://sites.google.com/site/redcodenl/creating-shazam-in-java-1 just in case | |
Why is this necessary? Read http://sites.google.com/site/redcodenl/patent-infringement | |
Please fork, tweet about, etc. | |
---- | |
Creating Shazam in Java | |
A couple of days ago I encountered this article: How Shazam Works | |
This got me interested in how a program like Shazam works… And more importantly, how hard is it to program something similar in Java? |