Skip to content

Instantly share code, notes, and snippets.

View cheeyeo's full-sized avatar
💭
Researching on use of transformers in computer vision

Chee Yeo cheeyeo

💭
Researching on use of transformers in computer vision
View GitHub Profile
@cheeyeo
cheeyeo / mixpanel.rb
Created April 25, 2014 19:35
Mixpanel generic module as a mixin in AR using ActiveSupport
# using active_support
require 'active_support/core_ext'
module Mixpanel
extend ActiveSupport::Concern
# class methods
included do
mixpanel
end
@cheeyeo
cheeyeo / mixpanel.rb
Last active August 29, 2015 14:00
Mixpanel module as mixin for Activerecord classes
require 'active_support/core_ext'
module Mixpanel
module ClassMethods
def mixpanel(*names)
# Defines both class and instance accessors for class attributes.
class_attribute :mp_attrs
self.mp_attrs = names
end
end
@cheeyeo
cheeyeo / gist:11324200
Created April 26, 2014 16:18
Object.const get
def string_to_constant(constant_name)
constant_name.split("::").inject(Object) { |s,e| s.const_get(e) }
end
class Article; end
string_to_constant("Article")
# Get the 1.0.1 version of SSL
brew install openssl
./configure --disable-hipe --enable-smp-support --enable-threads --enable-kernel-poll --enable-darwin-64bit --with-ssl=/usr/local/opt/openssl
touch lib/wx/SKIP lib/odbc/SKIP
make -j4
sudo make install
@cheeyeo
cheeyeo / readme.md
Created April 26, 2014 20:50
Brew update fails or unresponsive
@cheeyeo
cheeyeo / gist:11354652
Created April 27, 2014 20:14
Microservice
http://martinfowler.com/articles/microservices.html
<table>
<thead>
<tr>
<th>Name</th>
<th>Email></th>
<th>Country</th>
<th></th>
</tr>
</thead>
@cheeyeo
cheeyeo / audit_log.rb
Created April 28, 2014 19:20
Simple decorator pattern
class AuditLog
def record(number, action, amount, balance)
printf(
"%<time>s #%<number>s %<action>s %<amount>.2f (%<balance>.2f)\n",
time: Time.now,
number: number,
action: action,
amount: amount / 100,
balance: balance / 100)
end
@cheeyeo
cheeyeo / endian.m
Created April 28, 2014 19:34 — forked from markd2/endian.m
#import <Foundation/Foundation.h>
// Xcode_3_2_6/usr/bin/gcc -arch ppc -std=c99 -isysroot /Xcode_3_2_6/SDKs/MacOSX10.5.sdk -g -Wall -framework Foundation -o endian-ppc ~/Downloads/endian.m (thanks to Jeremy W. Sherman for the assist)
// clang -arch x86_64 -g -Weverything -framework Foundation -o endian endian.m
int main (void) {
unsigned int values[] = { 1, 387, 8533937 };