Skip to content

Instantly share code, notes, and snippets.

View alloy's full-sized avatar

Eloy Durán alloy

View GitHub Profile
This is basically a dirty hack :) I have no idea if messing with the default OSX apache config this way is frowned upon. My view is that it works now, and if it breaks I'll fix it.
Add any domains you want to blacklist to /etc/hosts, pointing at 127.0.0.1. You need to enable web sharing to get apache running of course.
Changes to the default /etc/apache2/httpd.conf
==============================================
Listen 127.0.0.1:80 # so that the world can't see the list
DocumentRoot "/Library/WebServer/Documents/public" # to fit in with passenger, you need to create the public dir (and maybe /tmp too)
@alloy
alloy / gist:275261
Created January 12, 2010 15:05 — forked from h-lame/gist:275076
##
#
# Automatic
#
class Developer < ActiveRecord::Base
has_many :audit_logs # the macro checks if it can find an obvious inverse_of, but none is found
end
class AuditLog < ActiveRecord::Base
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?
@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)