Skip to content

Instantly share code, notes, and snippets.

@rlb3
rlb3 / 0. nginx_setup.sh
Created August 11, 2012 18:37 — forked from mikhailov/0. nginx_setup.sh
Nginx+Unicorn
# Nginx+Unicorn best-practices congifuration guide.
# We use latest stable nginx with fresh **openssl**, **zlib** and **pcre** dependencies.
# Some extra handy modules to use: --with-http_stub_status_module --with-http_gzip_static_module
#
# Deployment structure
#
# SERVER:
# /etc/init.d/nginx (1. nginx)
# /home/app/public_html/app_production/current (Capistrano directory)
#
@rlb3
rlb3 / hashes.pl
Created September 8, 2012 14:41
hash of hashes
#!/usr/bin/env perl
my $array = [qw/one two/];
my $hash = {};
my $value = [qw/done and done/];
sub head {
my (@list) = @_;
return shift @list;
}
@rlb3
rlb3 / reduce.pl
Created October 10, 2012 14:44
A reduce sub in perl
sub reduce (&;$@) {
my $code = shift;
my $f = sub {
my $base_val = shift;
my $g = sub {
my $val = $base_val;
for (@_) {
local ( $a, $b ) = ( $val, $_ );
$val = $code->( $val, $_ );
}
@rlb3
rlb3 / disable_framework.md
Created October 17, 2012 12:19 — forked from guilleiguaran/disable_framework.md
Disabling frameworks in Rails 3+

Disabling frameworks in Rails 3+###

Replace in your config/application.rb

require "rails/all"

with:

require "rails"
@rlb3
rlb3 / MiniMetaModel_w_Role.pl
Created October 24, 2012 14:38
MiniMetaModel_w_Role.pl
#!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 13;
## ----------------------------------------------------------------------------
## Mini Meta-Model with Self-Bootstrapping Roles
## ----------------------------------------------------------------------------
@rlb3
rlb3 / wtf.pl
Created October 26, 2012 17:50
wait what?
#!/usr/bin/perl -w
use strict;
use warnings;
{
package DEEP;
sub deeply { "deeply inherited" }
package UNIVERSAL;
@rlb3
rlb3 / vote_count.rb
Created November 3, 2012 16:29
vote count ideas
a = {candidate: "candidate1", weight: 1}
b = {candidate: "candidate1", weight: 1}
c = {candidate: "candidate2", weight: 1}
v = [a, b, c].group_by { |x| x[:candidate] }.map { |k,v| { k => v.inject(0) {|a, h| a + h[:weight]}}}
# => [{"candidate1"=>2}, {"candidate2"=>1}]
h = v.each_with_object({}) { |c,hash|
c.each_pair {|k,v|
@rlb3
rlb3 / friend.rb
Created November 14, 2012 15:10 — forked from codeodor/friend.rb
Friend functions in Ruby
# See http://www.ruby-doc.org/core-1.9.3/Kernel.html#method-i-set_trace_func for docs on this function
require 'ostruct'
module Friendly
def self.included(base)
base.extend(ClassMethods)
end
def method_missing(name, *args, &block)
@rlb3
rlb3 / .irbrc
Created November 16, 2012 16:34
.pryrc
require "awesome_print"
AwesomePrint.irb!
@rlb3
rlb3 / init.el
Created December 6, 2012 18:47 — forked from mig/init.el
Simple Emacs 24 configuration for Rails development
;; emacs configuration
(add-to-list 'load-path "~/.emacs.d/el-get/el-get")
(unless (require 'el-get nil 'noerror)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.github.com/dimitri/el-get/master/el-get-install.el")
(let (el-get-master-branch)
(goto-char (point-max))