Skip to content

Instantly share code, notes, and snippets.

View mytrile's full-sized avatar

Dimitar Kostov mytrile

View GitHub Profile
@mytrile
mytrile / user.rb
Created January 8, 2009 19:00 — forked from tokumine/user.rb
# Username or email login for restful_authentication in user.rb model
def self.authenticate(login, password)
return nil if login.blank? || password.blank?
u = find_in_state :first, :active, :conditions => ["email = ? OR login = ?",login,login] # need to get the salt
u && u.authenticated?(password) ? u : nil
end
# run by doing:
# rake locales:compile LANG_TARGET=pt-BR
namespace :locales do
desc "Compare locale files and get differences and missing keys"
task :compile do
ENV['LANG_SOURCE'] = 'en' if ENV['LANG_SOURCE'].nil?
if ENV['LANG_TARGET'].nil?
puts "define the target language using the LANG_TARGET environment variable\nrake locales:compile LANG_TARGET=pt-BR"
exit(1)
end
# mongo_template.rb
# remove unneeded defaults
run "rm public/index.html"
run "rm public/images/rails.png"
run "rm public/javascripts/controls.js"
run "rm public/javascripts/dragdrop.js"
run "rm public/javascripts/effects.js"
run "rm public/javascripts/prototype.js"
➜ tmp ./tilt_test.sh
### SETUP
ruby 1.8.7 (2011-02-18 patchlevel 334) [x86_64-linux]
Initialized empty Git repository in /tmp/tilt_tests/.git/
remote: Counting objects: 1481, done.
remote: Compressing objects: 100% (673/673), done.
remote: Total 1481 (delta 909), reused 1039 (delta 617)
Receiving objects: 100% (1481/1481), 210.99 KiB, done.
Resolving deltas: 100% (909/909), done.
b8587ff2a99a888dd8c6575d008ef91f7888d75b refs/remotes/origin/HEAD
@mytrile
mytrile / hack.sh
Created March 31, 2012 10:32 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@mytrile
mytrile / hack.sh
Created August 6, 2012 11:49 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@mytrile
mytrile / memo-dyn.txt
Created August 24, 2012 19:13 — forked from fogus/memo-dyn.txt
Memoization vs dynamic programming
Memoization is fundamentally a top-down computation and dynamic
programming is fundamentally bottom-up. In memoization, we observe
that a computational *tree* can actually be represented as a
computational *DAG* (the single most underrated data structure in
computer science); we then use a black-box to turn the tree into a
DAG. But it allows the top-down description of the problem to remain
unchanged.
In dynamic programming, we make the same observation, but construct
the DAG from the bottom-up. That means we have to rewrite the
@mytrile
mytrile / 0-readme.md
Created November 23, 2012 22:07 — forked from burke/0-readme.md
ruby-1.9.3-p327 cumulative performance patch for rbenv

ruby-1.9.3-p327 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.

package main
import (
"encoding/json"
"fmt"
"github.com/gorilla/sessions"
"io/ioutil"
"log"
"net/http"
"net/url"