View refinement_output.rb
# Our code calling `to_s` on an Integer has been refined
puts CrazyInteger.crazy_string(2)
# => "TWO, ALWAYS TWO!!!!"
puts CrazyInteger.crazy_string(3)
# => "TWO, ALWAYS TWO!!!!"
# Regular calls to Integer.to_s are still safe!
puts 1.to_s
# => "1"
puts 2.to_s
View crazy_integer_refinement.rb
module IntegerRefinements
refine Integer do
def to_s
'TWO, ALWAYS TWO!!!!'
end
end
end
class CrazyInteger
using IntegerRefinements
View integer_refinements.rb
module IntegerRefinements
refine Integer do
def to_s
'TWO, ALWAYS TWO!!!!'
end
end
end
View bad_monkey.sh
irb(main):001:0> 1.class
=> Integer
irb(main):002:0> 1.to_s
=> "1"
irb(main):003:0> class Integer
irb(main):004:1> def to_s
irb(main):005:2> "two"
irb(main):006:2> end
irb(main):007:1> end
=> :to_s
View html_test.html
<a onafterprint="console.log(244599)" onbeforeprint="console.log(309354)" onbeforeunload="console.log(879813)" onerror="console.log(949564)" onhashchange="console.log(575242)" onload="console.log(301053)" onmessage="console.log(976974)" onoffline="console.log(796090)" ononline="console.log(432638)" onpagehide="console.log(504345)" onpageshow="console.log(696619)" onpopstate="console.log(398418)" onresize="console.log(943097)" onstorage="console.log(882233)" onunload="console.log(929443)" onblur="console.log(932104)" onchange="console.log(102339)" oncontextmenu="console.log(761265)" onfocus="console.log(188946)" oninput="console.log(143653)" oninvalid="console.log(304208)" onreset="console.log(318472)" onsearch="console.log(778420)" onselect="console.log(942035)" onsubmit="console.log(603589)" onkeydown="console.log(650647)" onkeypress="console.log(579383)" onkeyup="console.log(821763)" onclick="console.log(284098)" ondblclick="console.log(477370)" ondrag="console.log(439095)" ondragend="console.log(546684)" o
View goodtimes.cr
require "http/client"
class Word
def initialize(word)
raise ArgumentError.new "Not a single word" if word.split(" ").size > 1
@word = word
end
def wiki_title
wiki_page = WikipediaPage.new(@word)
View docker-images-output.sh
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
bloggy_web latest fd72d1901622 10 hours ago 912 MB
<none> <none> a51a0506164a 10 hours ago 903.4 MB
bloggy_square latest 4246ada965f2 10 hours ago 903.4 MB
<none> <none> 6e1e68d610ba 10 hours ago 903.4 MB
docker_square latest 85c7ac711d78 11 hours ago 808.9 MB
postgres 9.4.1 03119fe33f25 4 days ago 213.9 MB
ruby 2.2.1 ef6e4b7dc7cd 3 weeks ago 775.1 MB
kirkdockerized_web latest 83edc1a1d29a 4 months ago 347.8 MB
View heroku_rails_phantomjs.md

#Heroku, Ruby on Rails and PhantomJS

In this post, I’m going to show you how to modify an existing Ruby on Rails app running on Heroku’s Cedar stack to use PhantomJS for screen scraping. If you’ve never heard of PhantomJS, it’s a command-line WebKit-based browser (that supports JavaScript, cookies, etc.).

Let’s get started. This is a high-level overview of the required steps:

  • Modify your app to use multiple Heroku buildpacks.
  • Extend your app to use both the Ruby as well as the PhantomJS buildpacks.
  • Confirm that everything worked.
View developer_machines.sh
# Go to local repo
cd /path/on/your/machine/my-repo
# Just update the remote
git remote set-url origin git@github.com:mario/my-repo.git
View migrate_repo.sh
# Assume we are in your home directory
cd ~/
# Clone the repo from GitLab using the `--mirror` option
$ git clone --mirror git@your-gitlab-site.com:mario/my-repo.git
# Change into newly created repo directory
$ cd ~/my-repo.git
# Push to GitHub using the `--mirror` option. The `--no-verify` option skips any hooks.