This file contains hidden or 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
require 'mechanize' | |
http = Mechanize.new | |
page = http.get("http://www.focloir.ie/") | |
wotd_link = page.at(".wotdEntry a")["href"] | |
page = http.get(wotd_link) | |
puts page.at("#entryContent").text |
This file contains hidden or 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
################################################################### | |
## History | |
PRY_CONFIG_DIR = File.expand_path("~/.pry") | |
Pry.history.loader = proc do |&block| | |
Dir["#{PRY_CONFIG_DIR}/history-*.log"].sort_by { |f| File.mtime f }.last(2).each do |fn| | |
File.foreach(fn) { |line| block.call(line) } | |
end | |
end |
This file contains hidden or 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
[1] pry(main)> module Kernel; alias old_p p; def p(*args); if args.any?; old_p(*args.dup); else; old_p(self); end; nil; end; end | |
=> nil | |
[2] pry(main)> p [1,2,3] | |
[1, 2, 3] | |
=> nil | |
[3] pry(main)> [1,2,3].each(&:p) | |
1 | |
2 | |
3 | |
=> [1, 2, 3] |
This file contains hidden or 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
require 'binding_of_caller' | |
class Object | |
def method_missing(name, *args) | |
if name =~ /^_(\d+)$/ | |
binding.of_caller(2).eval("self").output_array[$1.to_i] | |
else | |
super | |
end | |
end |
This file contains hidden or 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
$ gem install -V pry-plus coolline | |
HEAD https://api.rubygems.org/latest_specs.4.8.gz | |
302 Moved Temporarily | |
HEAD https://s3.amazonaws.com/production.s3.rubygems.org/latest_specs.4.8.gz | |
304 Not Modified | |
HEAD https://api.rubygems.org/specs.4.8.gz | |
302 Moved Temporarily | |
HEAD https://s3.amazonaws.com/production.s3.rubygems.org/specs.4.8.gz | |
304 Not Modified | |
GET https://api.rubygems.org/quick/Marshal.4.8/json-1.5.5-java.gemspec.rz |
This file contains hidden or 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
require 'pp' | |
class ProxyController < ApplicationController | |
# Example headers: | |
# {"GATEWAY_INTERFACE"=>"CGI/1.1", | |
# "PATH_INFO"=>"/proxy/http:/google.com", | |
# "QUERY_STRING"=>"", | |
# "REMOTE_ADDR"=>"127.0.0.1", | |
# "REMOTE_HOST"=>"127.0.0.1", |
This file contains hidden or 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 rle_regexp(s) | |
s.scan(/(.)(\1*)/).map {|c, extra| [c, extra.size+1] } | |
end | |
def rle_each_char(s) | |
result = [] | |
last = nil | |
count = 0 |
This file contains hidden or 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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <unistd.h> | |
#include <fcntl.h> | |
#include <errno.h> | |
#include <linux/input.h> | |
#include <linux/uinput.h> | |
#define die(str, args...) do { \ |
This file contains hidden or 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
// ==UserScript== | |
// @name YouTube: Click a username and see their videos! | |
// @namespace http://github.com/epitron/ | |
// @version 0.1 | |
// @description When you click a username, instead of seeing that lame youtube user's "summary" page, you get their actual list of videos (sorted by date). | |
// @include /^https?://(?:www\.)?(?:youtube\.com)/.*/ | |
// @copyright 2013 epitron | |
// ==/UserScript== | |
(function() { |
This file contains hidden or 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 EpiTest | |
def self.inherited(base) | |
at_exit { base.new.run_my_tests_bitch! } | |
end | |
class Fail < Exception; end | |
def assert(thing) | |
raise Fail.new(caller_locations[0]) unless thing |