Skip to content

Instantly share code, notes, and snippets.

View swalberg's full-sized avatar

Sean Walberg swalberg

View GitHub Profile
require 'nokogiri'
require 'open-uri'
doc = Nokogiri::HTML(open('http://en.wikipedia.org/wiki/List_of_The_Price_Is_Right_pricing_games'))
puts doc.css('h4 span.mw-headline').map(&:inner_text).sample
bob:tmp $ strace -e trace=file ruby ./test.rb |& grep foo
open("/tmp/foo.rb", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 7
open("/tmp/foo.rb", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 7
lstat64("/tmp/foo.rb", {st_mode=S_IFREG|0644, st_size=20, ...}) = 0
bob:tmp $ echo "require './foo'" >> test.rb
bob:tmp $ strace -e trace=file ruby ./test.rb |& grep foo
open("/tmp/foo.rb", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 7
open("/tmp/foo.rb", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 7
lstat64("/tmp/foo.rb", {st_mode=S_IFREG|0644, st_size=20, ...}) = 0

Before:

mysql> explain SELECT galleryid, COUNT(*) as counter , `options`.`option_value` AS 'custom_post_id', GROUP_CONCAT(CONCAT_WS('@@', meta_key, meta_value)) AS 'extras' FROM `ngg_pictures` LEFT OUTER JOIN `options` ON `options`.option_name = CONCAT('ngg_pictures_', ngg_pictures.pid) LEFT OUTER JOIN `postmeta` ON `postmeta`.`post_id` = `options`.`option_value`  WHERE (`galleryid` IN (1746, 1747, 1749, 1748, 1750, 1751, 1752, 1753, 1745, 1754)) GROUP BY galleryid, ngg_pictures.pid;
+----+-------------+--------------+------+---------------+---------+---------+----------------------------+-------+----------------------------------------------+
| id | select_type | table        | type | possible_keys | key     | key_len | ref                        | rows  | Extra                                        |
+----+-------------+--------------+------+---------------+---------+---------+----------------------------+-------+----------------------------------------------+
|  1 | SIMPLE      | ngg_pictures | ALL  |
require 'nokogiri'
require 'open-uri'
def to_minutes(string)
(hr, min) = string.split(/\s?:\s?/)
hr.to_i * 60 + min.to_i
end
doc = Nokogiri::HTML(open('http://www.wrha.mb.ca/wait-times/'))
rbenv_gem "pg" do
ruby_version "2.0.0-p247"
options "--with-pg-config=/usr/pgsql-9.2/bin/pg_config"
end
$ dig +trace airbrake.io
; <<>> DiG 9.8.3-P1 <<>> +trace airbrake.io
;; global options: +cmd
. 100957 IN NS a.root-servers.net.
. 100957 IN NS f.root-servers.net.
. 100957 IN NS d.root-servers.net.
. 100957 IN NS b.root-servers.net.
. 100957 IN NS j.root-servers.net.
. 100957 IN NS h.root-servers.net.
@swalberg
swalberg / capistrano.txt
Last active December 14, 2015 20:59
What's the difference between cap deploy and cap deploy:migrations, and where do I hook in?
NB: deploy:symlink is deprecated, don't hook into it!
https://github.com/capistrano/capistrano/blob/master/lib/capistrano/recipes/deploy.rb
deploy:migrations
update_code
strategy.deploy!
finalize_update
migrate
create_symlink <-- hook in here
restart <-- or here
alias update_bashrc='curl https://raw.github.com/gist/xxxxxxxx/gistfile1.txt > ~/.bashrc'
#include <IRremote.h>
IRsend irsend;
void setup()
{
Serial.begin(9600);
}
unsigned long code;
# /etc/lirc/hardware.conf
#
#Chosen Remote Control
REMOTE="Windows Media Center Transceivers/Remotes (all)"
REMOTE_MODULES="lirc_dev mceusb"
REMOTE_DRIVER=""
REMOTE_DEVICE="/dev/lirc0"
REMOTE_SOCKET=""
REMOTE_LIRCD_CONF="mceusb/lircd.conf.mceusb"
REMOTE_LIRCD_ARGS=""