Skip to content

Instantly share code, notes, and snippets.

View pasikonik's full-sized avatar
🍏
Go vegan!

Michał Olejniczak pasikonik

🍏
Go vegan!
  • Poznań
  • 00:06 (UTC -12:00)
View GitHub Profile
@dbourguignon
dbourguignon / proc_composition-2.rb
Last active July 9, 2021 01:16
Proc composition in ruby 2.6
require "bigdecimal"
# List of our individual pricing rules
TAX = ->(val) { val + val*0.05 }
FEE = ->(val) { val + 1 }
PREMIUM = ->(val) { val + 10 }
DISCOUNT = ->(val) { val * 0.90 }
ROUND_TO_CENT = ->(val) { val.round(2) }
# One presenter
PRESENT = ->(val) { val.to_f }
@aloucas
aloucas / rails_binding_pry_on_docker.md
Created September 28, 2017 08:45
Rails binding.pry usage with docker
  1. Initially install your pry-rails to group development on your apps Gemfile
group :development do
  # ..
  gem 'pry-rails'
  # ..
end
@PavloBezpalov
PavloBezpalov / 1 Gist conventions
Last active January 7, 2024 11:55
Deploy Rails 5.0.0.beta3 to VPS(Ubuntu 14.04.4 LTS). Nginx, Puma, Capistrano3, PostgreSQL, RVM.
<<APP>> change this variables
@simlegate
simlegate / custom-error-page
Created October 31, 2014 05:35
Nginx return custom json
error_page 400 404 405 =200 @40*_json;
location @40*_json {
default_type application/json;
return 200 '{"code":"1", "message": "Not Found"}';
}
error_page 500 502 503 504 =200 @50*_json;
location @50*_json {
@damien-roche
damien-roche / rubymethodlookup.md
Last active October 4, 2024 18:23
A Primer on Ruby Method Lookup

A Primer on Ruby Method Lookup

Method lookup is a simple affair in most languages without multiple inheritance. You start from the receiver and move up the ancestors chain until you locate the method. Because Ruby allows you to mix in modules and extend singleton classes at runtime, this is an entirely different affair.

I will not build contrived code to exemplify the more complicated aspects of Ruby method lookup, as this will only serve to confuse the matter.

When you pass a message to an object, here is how Ruby finds what method to call:

1. Look within singleton class

@stevenharman
stevenharman / defaults.rb
Last active July 7, 2021 14:36
A subtle difference between Ruby's Hash.fetch(:key, :default) vs. (Hash[:key] || :default)
h = {
'a' => :a_value,
'b' => nil,
'c' => false
}
h.fetch('a', :default_value) #=> :a_value
h.fetch('b', :default_value) #=> nil
h.fetch('c', :default_value) #=> false
h.fetch('d', :default_value) #=> :default_value
@paulirish
paulirish / gist:5558557
Last active April 18, 2024 14:32
a brief history of detecting local storage

A timeline of the last four years of detecting good old window.localStorage.


Jan Lenhart, bless his heart contributed the first patch for support:

October 2009: 5059daa

@pstachula-dev
pstachula-dev / sublime text 2 - poradnik pl
Last active December 10, 2015 23:48
Mini-poradnik dla edytora Sublime Text 2.
/*
|---------------------------------------------------------------------
| 1. Szybkie zaznaczanie
|---------------------------------------------------------------------
| Ctrl + D - zaznaczanie kolejnych elementow
| ALt + F3 - zaznaczenie wszystkich elementow
| PPm + Shift - zaznaczanie kolumnami
|---------------------------------------------------------------------
| 2. Wyszukiwanie polecen i plikow
|---------------------------------------------------------------------
@salieridk
salieridk / gist:2413139
Created April 18, 2012 12:06
CSS: reset ul
ul
{
list-style: none;
padding: 0;
margin: 0;
}