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 / .zshrc
Created January 29, 2014 15:42 — forked from SlexAxton/.zshrc
gifify() {
if [[ -n "$1" ]]; then
if [[ $2 == '--good' ]]; then
ffmpeg -i $1 -r 10 -vcodec png out-static-%05d.png
time convert -verbose +dither -layers Optimize -resize 600x600\> out-static*.png GIF:- | gifsicle --colors 128 --delay=5 --loop --optimize=3 --multifile - > $1.gif
rm out-static*.png
else
ffmpeg -i $1 -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > $1.gif
fi
else
@cheeyeo
cheeyeo / Procfile
Created January 29, 2014 15:46 — forked from ismasan/Procfile
web: bundle exec rails server puma -p $PORT -e $RACK_ENV
critical: env HEROKU_PROCESS=critical bundle exec sidekiq -c 2 -q critical,4
default: env HEROKU_PROCESS=default bundle exec sidekiq -c 4 -q default,2
low: env HEROKU_PROCESS=low bundle exec sidekiq -c 1 -q low,1
# MOTIVATION: As rails apps are growing, people are noticing the drawbacks
# of the ActiveRecord pattern. Several apps I have seen, and several
# developers I have spoken to are looking towards other patterns for object
# persistence. The major drawback with ActiveRecord is that the notion
# of the domain object is conflated with what it means to store/retrieve
# it in any given format (like sql, json, key/value, etc).
#
# This is an attempt to codify the Repository pattern in a way that would
# feel comfortable to beginner and seasoned Ruby developers alike.
#
@cheeyeo
cheeyeo / gist:8848716
Created February 6, 2014 17:25
Run sub command in bash shell - below opens up the gem specified in a Gemfile within sublime

subl $(bundle show ac_platform)

@cheeyeo
cheeyeo / gist:8997948
Created February 14, 2014 09:01 — forked from orend/gist:5134300
require 'csv'
def memstats
size = `ps -o size= #{$$}`.strip.to_i
end
memstats #4900
CSV.open('visitors.csv', headers: true) do |csv|
visitors = csv.each # Enumerator
memstats # 5164
var tweet = "Currently chilling out at W1B 2EL, then on to WC2E 8HA or maybe even L1 8JF! :-)";
// Here's a simple regex that tries to recognise postcode-like strings.
// See http://en.wikipedia.org/wiki/Postcodes_in_the_United_Kingdom#Validation
// for the rules on how UK postcodes are formatted.
var postcode_regex = /[A-Z]{1,2}[0-9][0-9A-Z]?\s?[0-9][A-Z]{2}/g;
var postcodes = tweet.match(postcode_regex);
console.log(postcodes);
@cheeyeo
cheeyeo / callback.rb
Created February 19, 2014 21:27
Ruby example of caller specified callback
require 'ostruct'
require 'open-uri'
require 'json'
class TemperatureApiError < StandardError
end
class CheeError < StandardError
end
@cheeyeo
cheeyeo / episode.rb
Created March 3, 2014 17:27
Example of ghost loading pattern
class Episode
def self.lazy_accessor(*names)
names.each do |name|
attr_writer name
define_method(name) do
load
instance_variable_get("@#{name}")
end
end
end
@cheeyeo
cheeyeo / fizzbuzz.rb
Created March 14, 2014 15:10
Example of FizzBuzz in Ruby using procs
MULTIPLE_OF_3 = ->(n){ (n % 3).zero? }
MULTIPLE_OF_5 = ->(n){ (n % 5).zero? }
MULTIPLE_OF_3_AND_5 = ->(n){ MULTIPLE_OF_3[n] && MULTIPLE_OF_5[n] }
(1..100).each do |num|
case num
when MULTIPLE_OF_3_AND_5
puts "FizzBuzz"
when MULTIPLE_OF_3
puts "Fizz"
@cheeyeo
cheeyeo / search.rb
Created March 19, 2014 13:58
Ruby: calling included classes within parent module
module Search
@children = []
def self.included(base)
@children << base
end
def self.query(val)
@children.each do |child|
child.query(val)