Skip to content

Instantly share code, notes, and snippets.

@silasb
silasb / gist:6356516
Last active December 21, 2015 19:49
Get Shitty_Watercolour's awesome images.
require 'rss'
require 'open-uri'
url = 'http://www.reddit.com/user/Shitty_Watercolour.rss'
open(url) do |rss|
feed = RSS::Parser.parse(rss.read)
feed.items.each do |item|
if item.description =~ /(http:\/\/i\.imgur\.com\/\S+[.jpg])/
`curl -O #{$1}`
@silasb
silasb / gist:5816203
Created June 19, 2013 17:35
Create XML file from programs.xml
require 'open-uri'
require 'nokogiri'
require 'pry'
doc = Nokogiri::XML(File.open('/tmp/programs.xml'))
doc.css('link').each do |link_el|
href = link_el.attr('href')
if href =~ /(.html)+$/
@silasb
silasb / deploy.rb
Last active December 14, 2015 14:39 — forked from mlangenberg/deploy.rb
namespace :log do
desc "Downloads application logs to ./log/deploy/<RAILS_ENV>/<TIMESTAMP>/"
task :fetch, :roles => :app do
source = "#{shared_path}/log/#{rails_env}.log"
files_per_host = {}
run "ls #{source}" do |channel, stream, data|
files_per_host[channel[:xserver]] = data.split("\n").map(&:split)
end
destination = File.join('log', 'deploy')
# Maintainer: Eugeni Dodonov <[email protected]>
pkgname=glamor-git
pkgver=20121214
pkgrel=1
pkgdesc='OpenGL based 2D rendering acceleration library '
arch=('i686' 'x86_64')
url='http://cgit.freedesktop.org/xorg/driver/glamor/'
license=('custom')
depends=('glibc' 'mesa' 'libdrm' 'xorg-server-devel' 'libx11' 'xf86driproto' 'glproto' 'libegl')
(type.ps) runlibfile
(unit.ps) runlibfile
(IsoLatin.enc) runlibfile
/default_encoding IsoLatin def
<< /Duplex false /Tumble false >> setpagedevice
/pagesize [612 792] def
/margin 3 dict def margin begin /top 1 cm def /right 1 cm def /bottom 1 cm def /left 1 cm def end
(paper.ps) runlibfile
[ /Producer (Ruby Ghostscript - RGhost v0.8.7) /DOCINFO pdfmark /rows_per_page 80 def /count_pages 10 def /row_height 0.4 cm def /row_padding 0.1 cm def (basic.ps) runlibfile
(cursor.ps) runlibfile
oxy:include silas$ brew doctor
Warning: Your Homebrew is not installed to /usr/local
You can install Homebrew anywhere you want, but some brews may only build
correctly if you install in /usr/local. Sorry!
oxy:include silas$ brew --config
HOMEBREW_VERSION: 0.9.3
HEAD: 251ff3ceb5eb41d9724be16e1416f46874d03a6b
HOMEBREW_PREFIX: /Users/silas/opt
HOMEBREW_CELLAR: /Users/silas/opt/Cellar
1.9.2p320 :039 > Redemption.includes(:referral_discount_code)
Redemption Load (0.3ms) SELECT `redemptions`.* FROM `redemptions`
ReferralDiscountCode Load (0.2ms) SELECT `discount_codes`.* FROM `discount_codes` WHERE `discount_codes`.`type` IN ('ReferralDiscountCode') AND `discount_codes`.`id` IN (38, 36, 37)
=> [#<Redemption id: 1, customer_id: 1, discount_code_id: 38, created_at: "2012-08-23 14:34:03", updated_at: nil>, #<Redemption id: 2, customer_id: 1, discount_code_id: 36, created_at: "2012-08-23 14:34:03", updated_at: nil>, #<Redemption id: 3, customer_id: 1, discount_code_id: 37, created_at: "2012-08-23 14:34:03", updated_at: nil>]
1.9.2p320 :040 > Redemption.includes(:referral_discount_code)
<?PHP
header( 'HTTP/1.1 301 Moved Permanently' );
header( 'Location: http://bedrocklinux.org' );
?>
#!/usr/bin/env perl
print "Status: 301 Moved Permanently\nLocation: http://bedrocklinux.org\n\n";
# using this for testing.
sudo -u postfix ~rails/bin/receive_email.sh < ~rails/apps/WebApp1/test/fixtures/test_email_1.eml