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
| Book -inurl:htm -inurl:html intitle:"index of" +("/ebooks"|"/book") +(chm|pdf|zip) +"For Dummies" | |
| APK -inurl:htm -inurl:html intitle:”index of” apk |
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 sessionDebugger
| convert -strip -interlace Plane -gaussian-blur 0.05 -quality 85% source.jpg result.jpg |
| 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 |
| 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 |
| # 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 |
| 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( |
| 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 |
| " _ _ " | |
| " _ /|| . . ||\ _ " | |
| " ( } \||D ' ' ' C||/ { % " | |
| " | /\__,=_[_] ' . . ' [_]_=,__/\ |" | |
| " |_\_ |----| |----| _/_|" | |
| " | |/ | | | | \| |" | |
| " | /_ | | | | _\ |" | |
| It is all fun and games until someone gets hacked! |