Skip to content

Instantly share code, notes, and snippets.

View kukula's full-sized avatar
🇺🇦

Tolik kukula

🇺🇦
View GitHub Profile
@kukula
kukula / Quicksort.rb
Last active January 2, 2020 21:00
Quicksort in Ruby 2.7 using pattern matching
def quicksort(list)
case list
in []
[]
in [first, *rest]
smaller, larger = rest.partition { |x| x < first }
quicksort(smaller) + [first] + quicksort(larger)
end
end
puts quicksort [7, 3, 2, 4, 5, 9, 1, 6]

Pry Cheat Sheet

Command Line

  • pry -r ./config/app_init_file.rb - load your app into a pry session (look at the file loaded by config.ru)
  • pry -r ./config/environment.rb - load your rails into a pry session

Debugger

@kukula
kukula / hello_world.md
Last active June 29, 2017 18:38
web "hello world".

Sinatra - Ruby

require 'sinatra'

get '/' do
  'Hello world!'
end
bigdecimal (1.2.6)
io-console (0.4.3)
json (1.8.1)
minitest (5.4.3)
power_assert (0.2.2)
psych (2.0.8)
rake (10.4.2)
rdoc (4.2.0)
test-unit (3.0.8)
initdb /usr/local/var/postgres -E utf8
createdb `whoami`
psql
@kukula
kukula / pr.md
Last active August 29, 2015 14:24 — forked from tregusti/pr.md

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	url = git@github.com:joyent/node.git
	fetch = +refs/heads/*:refs/remotes/origin/*

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

ctags -R --languages=ruby --exclude=.git --exclude=log . $(bundle list --paths)
@kukula
kukula / gist:620858cde70a74a378ae
Created October 31, 2014 01:52
install npm gobaly
npm config set prefix ~/npm
export PATH="$PATH:$HOME/npm/bin"
@kukula
kukula / .rspec
Created September 16, 2014 15:07
I recommend to put it in root of your rails app
--drb --color --format documentation
.blah span:after {
content: " | ";
}
.blah span:last-child:after {
content: none;
}