Skip to content

Instantly share code, notes, and snippets.

View JuanitoFatas's full-sized avatar
🐻
Buildkite Engineering

Juanito JuanitoFatas

🐻
Buildkite Engineering
View GitHub Profile
@peterhellberg
peterhellberg / multi_value.rb
Created March 18, 2012 20:30
Support for multiple return values in Ruby 1.9, the way Common Lisp does it… sort of
class MultiValue < BasicObject
attr_reader :secondary
def initialize(obj, *secondary)
@obj, @secondary = obj, secondary
end
def method_missing(sym, *args, &block)
@obj.__send__(sym, *args, &block)
end
@choonkeat
choonkeat / gist:2297910
Created April 4, 2012 05:10
street names of singapore
Abingdon Road
Adam Drive
Adam Park
Adam Road
Adis Road
Admiralty Drive
Admiralty Lane
Admiralty Link
Admiralty Road
Admiralty Road East
@jboner
jboner / latency.txt
Last active July 15, 2025 00:14
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
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 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@henrik
henrik / README.markdown
Created June 26, 2012 07:30
This is how we test that all translation keys match up between locales, in Rails.

This is how we test that all translation keys match up between locales.

Stuff that only goes in one locale (such as an admin section) or that can't be translated yet (if you use external translators) can simply go in files that don't match the path "config/locales/??.yml", like "config/locales/wip.fo.yml".

@happypeter
happypeter / db_backup.sh
Created June 27, 2012 12:04
db backup with git
#!/usr/bin/env bash
ssh linode 'cd local_clone; cd happynewsdb; \
mysqldump --extended-insert=FALSE --complete-insert=TRUE -uroot authlove_development>authlove_development.sql; \
git commit -a -m"i"; \
git push;\
cd ../happyecdb/ ; \
mysqldump --extended-insert=FALSE --complete-insert=TRUE -uroot ec_development>ec_development.sql; \
git commit -a -m"i"; \
git push;\
@rogercampos
rogercampos / spec_utils.rb
Created June 29, 2012 14:07
Capybara helpers
def saop
save_and_open_page
end
def screenshot
page.driver.render("/home/roger/shot.jpg", :full => true)
end
def select_should_have(locator, text)
node = page.find_field(locator)
@unak
unak / history.txt
Last active November 29, 2021 01:40
The History of Ruby
* Only the releases of the stable versions are listed in principle. The releases of the unstable versions especially considered to be important are indicated as "not stable."
* The branches used as the source of each releases are specified, and the branching timing of them are also shown. BTW, before subversionizing of the repository, the term called "trunk" was not used, but this list uses it in order to avoid confusion.
* In order to show a historical backdrop, big conferences (RubyKaigi, RubyConf and Euruko) are also listed. About the venues of such conferences, general English notations are adopted, in my hope.
* ruby_1_8_7 branch was recut from v1_8_7 tag after the 1.8.7 release because of an accident.
* 1.2.1 release was canceled once, and the 2nd release called "repack" was performed. Although there were other examples similar to this, since the re-releases were performed during the same day, it does not write clearly in particular.
* Since 1.0 was released with the date in large quantities, the mi
@jarosan
jarosan / elasticsearch.rake
Created July 16, 2012 20:37
Elasticsearch reindex task
# Run with: rake environment elasticsearch:reindex
namespace :elasticsearch do
desc "re-index elasticsearch"
task :reindex => :environment do
klass = Place
ENV['CLASS'] = klass.name
ENV['INDEX'] = new_index = klass.tire.index.name << '_' << Time.now.strftime('%Y%m%d%H%M%S')
@flaneur2020
flaneur2020 / py-stack.md
Created July 27, 2012 04:15
notes on django

python的环境与ruby还是有很大不同的,而且框架多如牛毛,将遇到的坑记在这里。

ps: django跟屎一样。

virtualenv

直觉上很容易当作virtualenv当作rvm的存在,但实际上python的版本往往并非大问题,更多需要对付的还是三方库。virtualenv其实更多扮演的是Bundler的角色,但在操作上有所不同。

Bundler通过Gemfile列出当前项目需要的gem并将它们安装到系统,在代码中通过Bundler.require(:all)引入gem,并在bundle exec中设置环境变量之类,以选择正确版本的gem。

@hooopo
hooopo / README.markdown
Created August 8, 2012 14:12 — forked from greypants/README.markdown
RAILS 3: nav_link helper for adding 'selected' class to navigation elements

#Behold, the nav_link:

The nav_link helper works just like the standard Rails link_to helper, but adds a 'selected' class to your link (or its wrapper) if certain criteria are met. By default, if the link's destination url is the same url as the url of the current page, a default class of 'selected' is added to the link.

For full usage details, see: http://viget.com/extend/rails-selected-nav-link-helper

Drop nav_link_helper.rb into app/helpers in your Rails 3.x app and enjoy.