- 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
View reorder.rb
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( |
View rewrite_git_hist.sh
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="old@email.com" | |
CORRECT_NAME="Your Name" |
View anagram.rb
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 |
View Join Attributes on a HMT.rb
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 |
View google-dorks
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! |
View google.it
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
Book -inurl:htm -inurl:html intitle:"index of" +("/ebooks"|"/book") +(chm|pdf|zip) +"For Dummies" | |
APK -inurl:htm -inurl:html intitle:”index of” apk |
View carrierwave
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 |
View class_new.rb
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 |
View examples.sh
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 dev@123.123.123.123:projects/dev.log /home/dev/dev.log | |
# Bulk rename |
View 0. Ruby Meta Programming - spells covered.md
NewerOlder