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 / script_test.js
Created October 9, 2011 19:00 — forked from billywhizz/script_test.js
testing vm script functionality in node.js
var vm = require('vm'),
code = 'var square = n * n;',
fn = new Function('n', code),
script = vm.createScript(code),
sandbox;
n = 5;
sandbox = { n: n };
benchmark = function(title, funk) {
@cheeyeo
cheeyeo / test.as
Created December 7, 2011 20:57
test actionscripyt
import fl.text.TLFTextField;
var tlfTxt:TLFTextField = new TLFTextField();
tlfTxt.border = true;
tlfTxt.text = "The quick brown fox jumps over the lazy dog.";
tlfTxt.x = tlfTxt.y = 20;
addChild(tlfTxt);
@cheeyeo
cheeyeo / gist:1657718
Created January 22, 2012 17:14 — forked from jugyo/gist:1646320
an example of auth for facebook
require 'thread'
require 'facebook_oauth'
require 'launchy'
require 'sinatra/base'
callback_uri = URI.parse('http://localhost:6789/')
fb_client = FacebookOAuth::Client.new(
:application_id => 'XXXXXXXXXXXX',
:application_secret => 'XXXXXXXXXXXXXXXXXXXXXXXX',
# Set the number of connections AR pool
#
# place in an initializer such as: config/connection_pool.rb
Rails.application.config.after_initialize do
ActiveRecord::Base.connection_pool.disconnect!
ActiveSupport.on_load(:active_record) do
config = Rails.application.config.database_configuration[Rails.env]
config['pool'] = ENV['DB_POOL'] || 6
heroku pgbackups:capture
curl -o latest.dump `heroku pgbackups:url`
pg_restore --verbose --clean --no-acl --no-owner -h localhost \
-U `whoami` -d `ruby -e "require 'yaml' ; File.open( 'config/database.yml' ) { |file| puts YAML::load(file)['development']['database'] }"` latest.dump
rm latest.dump
@cheeyeo
cheeyeo / gist:5892464
Created June 29, 2013 20:02
Error when installing Rolify with ActiveAdmin and Mongoid
`<class:User>': undefined method `image_accessor' for User:Class (NoMethodError)
from /Users/chee/rails3apps/socialmarket/app/models/user.rb:3:in `<top (required)>'
from /Users/chee/.rvm/gems/ruby-1.9.3-p362@socialmart/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:469:in `load'
from /Users/chee/.rvm/gems/ruby-1.9.3-p362@socialmart/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:469:in `block in load_file'
from /Users/chee/.rvm/gems/ruby-1.9.3-p362@socialmart/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:639:in `new_constants_in'
from /Users/chee/.rvm/gems/ruby-1.9.3-p362@socialmart/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:468:in `load_file'
from /Users/chee/.rvm/gems/ruby-1.9.3-p362@socialmart/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:353:in `require_or_load'
from /Users/chee/.rvm/gems/ruby-1.9.3-p362@socialmart/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:502:in `load_missing_constant'
from /Users/chee/.
@cheeyeo
cheeyeo / mongoex-elixir.ex
Created July 22, 2013 14:38
Connecting to MongoHQ using Elixir on Heroku
# uses the mongoex plugin
if System.get_env("MONGOHQ_URL") !== nil do
connection = URI.parse( System.get_env("MONGOHQ_URL") )
host = '#{connection.host}'
port = connection.port
userinfo = String.split( connection.userinfo, ":" )
username = Enum.at(userinfo,0)
password = Enum.at(userinfo,1)
pool = 4
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} !(Chrome\/[0-8]|Android\s[0-3])\.
RewriteCond %{HTTP_USER_AGENT} Chrome [OR]
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond %{DOCUMENT_ROOT}/$1.webp -f
RewriteRule (.+)\.(jpe?g|png)$ $1.webp [T=image/webp,E=accept:1]
</IfModule>
<IfModule mod_headers.c>
@cheeyeo
cheeyeo / gist:6156380
Last active December 20, 2015 15:48
Ruby array to hash
tst=["GBP","USD","EUR"]
tst.each_with_object({}) do |item, memo|
memo[item] = item.downcase
end
@cheeyeo
cheeyeo / example.js
Created September 4, 2013 11:11
Rails 3.2 jquery 'live' action being updated with 'on' for UJS.
var like_enter = function(){
$(".already_liked").find('.title').text('Unlike It');
$(".already_liked").find('i.icon-circle').addClass('unliked-circle');
$(".already_liked").find('i.icon-light').removeClass('icon-heart').addClass('icon-remove');
}
var like_leave = function(){
$(".already_liked").find('.title').text('Like It');
$(".already_liked").find('i.icon-circle').removeClass('unliked-circle');
$(".already_liked").find('i.icon-light').removeClass('icon-remove').addClass('icon-heart');