Skip to content

Instantly share code, notes, and snippets.

View luislavena's full-sized avatar

Luis Lavena luislavena

View GitHub Profile
@bkeepers
bkeepers / .gitconfig
Created February 19, 2013 14:12
Git aliases to make new commits that fixup or are squashed into previous commits
[alias]
fixup = !sh -c 'REV=$(git rev-parse $1) && git commit --fixup $@ && git rebase -i --autosquash $REV^' -
squash = !sh -c 'REV=$(git rev-parse $1) && git commit --squash $@ && git rebase -i --autosquash $REV^' -
@toolmantim
toolmantim / Procfile
Last active December 12, 2015 09:39
@ddollar's foreman Ruby gem is handy for booting a single app's processes, but you can also use foreman as a booter for mutiple foreman apps! Handy if you have apps that work together in a service-oriented way and you're sick of booting them one-at-a-time (or you're using a harness shell script).
app_1: foreman start --root app_1 --port 3000 --env app_1/.env
app_2: foreman start --root app_2 --port 3100 --env app_2/.env
app_3: foreman start --root app_3 --port 3200 --env app_3/.env

Zero downtime deploys with unicorn + nginx + runit + rvm + chef

Below are the actual files we use in one of our latest production applications at Agora Games to achieve zero downtime deploys with unicorn. You've probably already read the GitHub blog post on Unicorn and would like to try zero downtime deploys for your application. I hope these files and notes help. I am happy to update these files or these notes if there are comments/questions. YMMV (of course).

Other application notes:

  • Our application uses MongoDB, so we don't have database migrations to worry about as with MySQL or postgresql. That does not mean that we won't have to worry about issues with the database with indexes being built in MongoDB or what have you.
  • We use capistrano for deployment.

Salient points for each file:

@dadoonet
dadoonet / geosearch.sh
Created December 26, 2012 13:12
Geo Distance filter with Elasticsearch
curl -XDELETE localhost:9200/geopoint
curl -XPUT "localhost:9200/geopoint" -d '{
"settings" : { "index" : { "number_of_shards" : 1, "number_of_replicas" : 0 }}
}'
curl "localhost:9200/_cluster/health?wait_for_status=green&pretty=1&timeout=5s"
curl -XPUT 'http://localhost:9200/geopoint/tweet/_mapping' -d '
{
@shirosaki
shirosaki / 0-timing_result.md
Created October 14, 2012 13:24
Mingw make patch for parallel build of ruby

30% speed up of make mingw ruby on Windows 7 with Intel Core i5 2.40GHz CPU

Build trunk without ext/tk

$ gnumake clean
$ time gnumake

real    9m14.244s
user 0m0.030s
@stefanobernardi
stefanobernardi / application_controller.rb
Created September 23, 2012 07:07
Multiple omniauth providers and omniauth-identity on the main user model
class ApplicationController < ActionController::Base
protect_from_forgery
protected
def current_user
@current_user ||= User.find_by_id(session[:user_id])
end
def signed_in?
@shirosaki
shirosaki / 1-faster_load.patch
Created August 8, 2012 08:08
Remove short name expansion only on require and load
diff --git a/file.c b/file.c
index 4050067..4c86c27 100644
--- a/file.c
+++ b/file.c
@@ -2883,7 +2883,7 @@ append_fspath(VALUE result, VALUE fname, char *dir, rb_encoding **enc, rb_encodi
}
static VALUE
-file_expand_path(VALUE fname, VALUE dname, int abs_mode, VALUE result)
+file_expand_path_internal(VALUE fname, VALUE dname, int abs_mode, VALUE result, int long_name)
@luislavena
luislavena / 0-proposal.md
Created August 2, 2012 23:54
Improve File.expand_path performance in Windows

Background

While investigating the performance issues of File.expand_path on Windows, Usaku Nakamura and Nobuyoshi Nakada on [ruby-core:39504] pointed out that due security concerns, accessing files on Windows required normalized paths.

This was covered in the security update of March 2008, WEBrick file-access vulnerability.

After closer inspection of WEBrick code (mentioned by the security update),

@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
@wojtekmach
wojtekmach / account_test.rb
Created May 3, 2012 09:45
Writing MiniTest extensions
require 'minitest/autorun'
module MiniTest::Assertions
def assert_changes(obj, method, exp_diff)
before = obj.send method
yield
after = obj.send method
diff = after - before
assert_equal exp_diff, diff, "Expected #{obj.class.name}##{method} to change by #{exp_diff}, changed by #{diff}"