Skip to content

Instantly share code, notes, and snippets.

@epitron
epitron / irish-wotd.rb
Created April 6, 2014 19:55
Get a word of the day in Modern Irish Gaelic!
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
require 'nokogiri'
require 'pp'
doc0 = %{
<p>Hello <b>DOM!</b></p>
}
doc1 = %{
<div>
<p>Hello <b>DOM!</b></p>
@epitron
epitron / gist:10345271
Last active August 29, 2015 13:58
OpenSSL codebase statistics.
[01:32 AM] epi@rebar :: ~/src/openssl-1.0.1g $ cloc .
2354 text files.
2135 unique files.
762 files ignored.
http://cloc.sourceforge.net v 1.60 T=11.68 s (127.0 files/s, 45241.9 lines/s)
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
C 915 32949 68512 234936
@epitron
epitron / webcam-rng.md
Last active August 29, 2015 14:00
A webcam CCD noise random number generator
@epitron
epitron / .motion.conf
Created May 29, 2014 21:20
Config file for 'motion', a program to record videos whenever there's motion (I used it for watching my birdfeeder with a webcam.)
# Rename this distribution example file to motion.conf
#
# This config file was generated by motion 3.2.12
############################################################
# Daemon
############################################################
# Start in daemon (background) mode and release terminal (default: off)
@epitron
epitron / gist:887914c6877f4069eb63
Created June 5, 2014 05:48
Things that depend on GnuTLS...
$ apt-cache rdepends libgnutls26 | grep -v lib
Reverse Depends:
aiccu
vino
qemu-kvm
exim4-daemon-light
exim4-daemon-heavy
cups
xen-utils-4.1
wine1.4-amd64
@epitron
epitron / tz
Last active August 29, 2015 14:03
#!/bin/bash
#
# by Sairon Istyar, 2012
# distributed under the GPLv3 license
# http://www.opensource.org/licenses/gpl-3.0.html
#
# Source:
# https://github.com/saironiq/shellscripts/blob/master/torrentz_eu/torrentz_eu.sh
#
### CONFIGURATION ###
@epitron
epitron / hanoi.rb
Created August 15, 2014 22:01
Crazy 3-line tower of Hanoi solver.
puts "How many disks? "
n = STDIN.gets.to_i
x = 1
while (x < (1 << n))
puts "move from pole #{(x&x-1)%3} to pole #{((x|x-1)+1)%3}"
x += 1
end
@epitron
epitron / unfiglet-dorei-slow.rb
Last active August 29, 2015 14:05
Figlet-based CAPTCHA breaker (for IRC bots) -- accelerated!
require 'epitools'
figlet_left = File.readlines('./figlet.input')
def get_first_char(i, arr)
arr.map { |x| x[0..i] }
end
def remove_first_char(i, arr)
arr.map { |x| x.slice(i..-1) }
@epitron
epitron / lstat_pyramid.txt
Last active August 29, 2015 14:07
Ruby's "lstat pyramid" (this is executed for every file it attempts to open)
lstat("/usr", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/usr/lib", {st_mode=S_IFDIR|0755, st_size=200704, ...}) = 0
lstat("/usr/lib/ruby", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/usr/lib/ruby/gems", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/usr/lib/ruby/gems/2.1.0", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/usr/lib/ruby/gems/2.1.0/gems", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/usr/lib/ruby/gems/2.1.0/gems/slop-3.6.0", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/usr/lib/ruby/gems/2.1.0/gems/slop-3.6.0/lib", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/usr/lib/ruby/gems/2.1.0/gems/slop-3.6.0/lib/slop.rb", {st_mode=S_IFREG|0644, st_size=19793, ...}) = 0
open("/usr/lib/ruby/gems/2.1.0/gems/slop-3.6.0/lib/slop/option.rb", O_RDONLY|O_CLOEXEC) = 7