Skip to content

Instantly share code, notes, and snippets.

@rebyn
rebyn / ember-resources.md
Last active December 16, 2015 04:18
Ember.js resources to get started

Coming from Rails background (which seems traditional and old schooled in this case), I find Javascript frameworks highly confusing. After navigating a bit around, these resources prove to be really helpful for entry learners like me. So I compiled them together in this list. Feel free to suggest more in the comments!

Love At First Sight

Getting Into Ember.js

@rebyn
rebyn / gist:5795585
Created June 17, 2013 08:58
use Active Support in irb
Came across a case today in which I had to use a few Active Support's methods. Here's how:
$ irb
> require 'active_support'
> ActiveSupport::Inflector.singularize('inflections')
> ActiveSupport::Inflector.humanize('humanize_me')
@rebyn
rebyn / require.rb
Last active December 18, 2015 17:49
irb: Require .rb file in current directory
$ irb
>> require './file_to_be_used' #without .rb
=> true
defaults: &defaults
adapter: postgresql
encoding: unicode
pool: 5
host: localhost
user: admin
password: password
development:
<<: *defaults
// Solving Knapsack problem using Branch and Bound - Tu Hoang - rebyn@me.com
// The sole question of this problem is: If you have a backpack of capacity C (weight) and you have a list of items which weigh differently (w1, w2, etc) and have different values (p1, p2, etc), which is the best combination of items to meet these requirements:
// 1. the total weight of items doesn't exceed C,
// 2. the total profit is the most possible maximal.
// Simply speaking, if you are a thief and you are stealing stuff from a store, which items should you choose to carry with you in order that you gain the most?
#include <iostream>
#include <iomanip>
#include <fstream>
#define CAPACITY 16
@rebyn
rebyn / vm-setup.sh
Last active August 29, 2015 14:15 — forked from nf/vm-setup.sh
#!/bin/bash -e
echo '
PATH=$HOME/go/bin:$PATH
export GOPATH=$HOME
export CDPATH=.:$HOME/src/golang.org/x:$HOME/go/src:$HOME/src/github.com:$HOME/src/github.com/nf:$HOME/src/github.com/adg
export EDITOR=vim
' >> ~/.profile
sudo apt-get update
# Before
def self.send_request_to_path(request)
request.execute(target_base_url)
rescue Intercom::ServiceUnavailableError => e
if endpoints.length > 1
retry_on_alternative_endpoint(request)
else
raise e
end
end
@rebyn
rebyn / database.yml.erb
Last active August 29, 2015 14:27 — forked from franckverrot/database.yml.erb
Heroku database.yml
<%
require 'cgi'
require 'uri'
begin
uri = URI.parse(ENV["DATABASE_URL"])
rescue URI::InvalidURIError
raise "Invalid DATABASE_URL"
end
@rebyn
rebyn / 1_singlehost.go
Last active September 17, 2015 07:14 — forked from justinas/1_singlehost.go
Go middleware samples for my blog post. http://justinas.org/writing-http-middleware-in-go/
package main
import (
"net/http"
)
type SingleHost struct {
handler http.Handler
allowedHost string
}
@rebyn
rebyn / latency.txt
Created September 24, 2015 08:06 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms
Read 4K randomly from SSD* 150,000 ns 0.15 ms