- Dynamic Dispatch
- Dynamic Method
- Ghost Methods
- Dynamic Proxies
- Blank Slate
- Kernel Method
- Flattening the Scope (aka Nested Lexical Scopes)
- Context Probe
- Class Eval (not really a 'spell' more just a demonstration of its usage)
- Class Macros
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://help.github.com/articles/changing-author-info/ | |
#!/bin/sh | |
# remove backup | |
rm -f .git/refs/original/refs/heads/master | |
git filter-branch --env-filter ' | |
OLD_EMAIL="[email protected]" | |
CORRECT_NAME="Your Name" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" _ _ " | |
" _ /|| . . ||\ _ " | |
" ( } \||D ' ' ' C||/ { % " | |
" | /\__,=_[_] ' . . ' [_]_=,__/\ |" | |
" |_\_ |----| |----| _/_|" | |
" | |/ | | | | \| |" | |
" | /_ | | | | _\ |" | |
It is all fun and games until someone gets hacked! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def anagram? a, b | |
counts = ->(word) { word.each_char.with_object(Hash.new(0)) { |c, h| h[c] += 1 unless c =~ /\s/} } | |
counts[a] == counts[b] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Carousel | |
class Reorder | |
extend Dry::Initializer | |
include Dry::Monads::Either::Mixin | |
param :scope, reader: :private | |
param :params, reader: :private | |
def call | |
context = OpenStruct.new( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# kill by port | |
sudo kill -9 $(lsof -i :3000 -t) | |
# wget with range | |
wget --user user --password password http://example.com/{0..n}.jpg | |
# scp | |
scp [email protected]:projects/dev.log /home/dev/dev.log | |
# Bulk rename |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
group.admins << user | |
user.admin? # => true | |
user.editor? # => false | |
class Group < ActiveRecord::Base | |
has_many :memberships | |
has_many :users, :through => :memberships | |
has_many :admins, :through => :memberships, :source => :user, | |
:conditions => "memberships.role = 'admin'" do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Class | |
def new(*args, &block) | |
obj = allocate | |
obj.initialize(*args, &block) | |
# actually, this is obj.send(:initialize, …) because initialize is private | |
obj | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
convert -strip -interlace Plane -gaussian-blur 0.05 -quality 85% source.jpg result.jpg |
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
NewerOlder