Skip to content

Instantly share code, notes, and snippets.

require 'benchmark'
def it_fibonacci(n)
fib_arr = [0,1]
(2..(n.to_i) - 1).each do |x|
fib_arr << fib_arr[x-1] + fib_arr[x-2]
end
return fib_arr
end
@corroded
corroded / gist:83930dc472c755bb358634d05373238a
Created July 31, 2017 10:34 — forked from giannisp/gist:b53a76047b07751ed3ade3c1db1d2c51
Upgrade PostgreSQL 9.5.5 to 9.6.1 using Homebrew (macOS)
After automatically updating Postgres to 9.6.1 via Homebrew, the pg_ctl start command didn't work.
The error was something like "database files are incompatible with server".
Database files have to be updated before starting the server, here are the steps that had to be followed:
# need to have both 9.6.1 and latest 9.5.x installed, and keep 9.6.1 as default
brew unlink postgresql
brew install postgresql95
brew unlink postgresql95
brew link postgresql
@corroded
corroded / class_var_ex.rb
Created October 19, 2012 00:50 — forked from sumanmukherjee03/class_var_ex.rb
Messing with class variables in ruby
# Execute this file as follows and compare the results in ruby 1.8.*:
#
# ruby class_var_ex.rb
# ruby class_var_ex.rb "include module"
# ruby class_var_ex.rb "include module" "include global"
# ruby "include global"
@@test = 9 if ARGV.last == "include global"
module X
@corroded
corroded / class_var_ex.rb
Created October 19, 2012 00:50 — forked from sumanmukherjee03/class_var_ex.rb
Messing with class variables in ruby
# Execute this file as follows and compare the results in ruby 1.8.*:
#
# ruby class_var_ex.rb
# ruby class_var_ex.rb "include module"
# ruby class_var_ex.rb "include module" "include global"
# ruby "include global"
@@test = 9 if ARGV.last == "include global"
module X