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
#!/usr/bin/env ruby
cmd = %q[echo '3...'; sleep 1;
echo '2...'; sleep 1;
echo '1...'; sleep 1;
echo 'Liftoff!']
puts '------ beginning command ------'
output_log = []
IO.popen(cmd).each do |line|
# blog post: http://blog.slashpoundbang.com/post/1455548868/memcachemodel-make-any-ruby-object-that-persists-in
# No transactions or exceptions (yet).
module MemcacheModel
def self.included(base)
base.class_eval do
extend ActiveModel::Naming
extend ActiveModel::Translation
extend ActiveModel::Callbacks
extend MemcacheModel::ClassMethods
@cheeyeo
cheeyeo / railssolo.rb
Created September 26, 2014 18:55
Reproduction of strong_parameters error with file upload
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', path: '~/code/rails'
gem 'arel', github: 'rails/arel'
gem 'rack', github: 'rack/rack'
gem 'i18n', github: 'svenfuchs/i18n'
GEMFILE
system 'bundle'
#!/bin/sh
usage ()
{
cat <<EOF
docker-enter -- Enter a running container via boot2docker and nsenter
Usage: docker-enter <container_name_or_ID> [command]
See https://github.com/jpetazzo/nsenter for details.
@cheeyeo
cheeyeo / user.rb
Created August 30, 2014 15:12
Pseudo code for recommendation engine using jaccquard index
class User
def similarity_with(user)
# Array#& is the set intersection operator.
agreements = (self.likes & user.likes).size
agreements += (self.dislikes & user.dislikes).size
disagreements = (self.likes & user.dislikes).size
disagreements += (self.dislikes & user.likes).size
# Array#| is the set union operator
require 'rubygems'
require 'gsl'
users = { 1 => "Ben", 2 => "Tom", 3 => "John", 4 => "Fred" }
m = GSL::Matrix[
#Ben, Tom, John, Fred
[5,5,0,5], # season 1
[5,0,3,4], # season 2
[3,4,0,3], # season 3
[0,0,5,3], # season 4
z = fn
f -> fn
x -> f.(fn y -> x.(x).(y) end)
end.(fn
x -> f.(fn y -> x.(x).(y) end)
end)
end
add_squares = z.(fn
f -> fn
@cheeyeo
cheeyeo / matplotlib_pip.md
Created August 14, 2014 11:43
Installing matplotlib on osx with freetype installed using homebrew

LDFLAGS: -L/usr/local/opt/freetype/lib CPPFLAGS: -I/usr/local/opt/freetype/include

LDFLAGS="-L/usr/local/opt/freetype/lib -L/usr/local/opt/libpng/lib" CPPFLAGS="-I/usr/local/opt/freetype/include -I/usr/local/opt/libpng/include -I/usr/local/opt/freetype/include/freetype2" sudo pip install matplotlib

@cheeyeo
cheeyeo / samples.exs
Last active August 29, 2015 14:05
Try elixir code samples
# Expressions
iex> 40 + 2
iex> "hello" <> " world"
#Basic types
iex> 1 # integer
iex> 0x1F # integer
iex> 1.0 # float
iex> :atom # atom / symbol
iex> "elixir" # string
@cheeyeo
cheeyeo / websockets_raw.ex
Created August 4, 2014 19:05
Raw websockets in elixir
# You can wire up a cowboy specific websocket handler with the following:
defmodule MyRouter do
use Phoenix.Router
dispatch_option "/ws", MyCowboyWebsocketHandler
end
defmodule MyCowboyWebsocketHandler do
@behaviour :cowboy_websocket_handler