Skip to content

Instantly share code, notes, and snippets.

View alloy's full-sized avatar

Eloy Durán alloy

View GitHub Profile
@alloy
alloy / Decoding speed
Created October 5, 2010 11:49 — forked from wvanbergen/Decoding speed
On MacRuby 0.7
=== 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)
# 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
# ...
#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;
@alloy
alloy / gist:942181
Created April 26, 2011 12:35 — forked from Manfred/gist:942173
Square job interview exercise
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
@alloy
alloy / factories.m
Created February 21, 2012 17:14 — forked from subdigital/factories.m
A test object factory potential implementation
// 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" };
@alloy
alloy / KIF.podspec
Created February 28, 2012 19:29 — forked from foxyblocks/KIF.podspec
A CocoaPods PodSpec for the KIF framework
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',
@alloy
alloy / gist:2786823
Created May 25, 2012 09:04 — forked from barttenbrinke/gist:2786800
NSDATA+Base64 wrapper UTF8 issue
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)
@alloy
alloy / gist:4257313
Created December 11, 2012 09:32 — forked from steipete/gist:1501754
Use Xcode to automatically set git hash
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
@alloy
alloy / gist:4267777
Created December 12, 2012 13:38 — forked from anonymous/gist:4267712
Define hookable API in module that’s included, this way other clients can include a module that overrides those hooks. Because including modules inserts the methods in the ancestor lookup chain (i.e. the power of Ruby), this allows the use of super etc.
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."
Pod::Spec.new do |spec|
spec.name = 'DTLoupe'
spec.version = '1.3.0'
spec.platform = :ios, '4.3'
spec.license = 'COMMERCIAL'
spec.source = { :git => 'git@git.cocoanetics.com:parts/dtloupe.git', :tag => spec.version.to_s }
spec.source_files = 'Core/Source/*.{h,m}'
spec.frameworks = 'QuartzCore'
spec.requires_arc = true
spec.homepage = 'http://www.cocoanetics.com/parts/dtloupeview/'