Skip to content

Instantly share code, notes, and snippets.

View rmoriz's full-sized avatar
🎭
Everything counts in large amounts

rmoriz

🎭
Everything counts in large amounts
View GitHub Profile
#!/bin/bash
#
# Save in your .bash_profile then: isreg domain.com
function isreg {
dig soa $1 | grep ^$1
}
# examples:
#
@rmoriz
rmoriz / gist:184585
Created September 10, 2009 14:42 — forked from paukul/gist:184559
nokogiri
require 'nokogiri'
require 'open-uri'
require 'tempfile'
image_url = Nokogiri::HTML(open('http://api.cheezburger.com/xml/category/cats/lol/random')).xpath('/html/body/lol/lolimageurl').first.content
file = Tempfile.new('lolcat.jpg')
file.write(open('image_url')
file.close
# Monkey-patch for Passenger to use the EventMachine reactor.
# This allows the use of EM timers, EM.system/popen, and other async libraries (amqp, em-http-request, etc) inside a Rails process.
# This requires EM.watch which was added to EM's git repo recently. Build an EM gem first:
# git clone git://github.com/eventmachine/eventmachine
# cd eventmachine
# gem build eventmachine.gemspec
# sudo gem install eventmachine-0.12.9.gem
# Please do not use this in production =)
# download and git methods swiped from http://github.com/Sutto/rails-template/blob/07b044072f3fb0b40aea27b713ca61515250f5ec/rails_template.rb
require 'open-uri'
def download(from, to = from.split("/").last)
#run "curl -s -L #{from} > #{to}"
file to, open(from).read
rescue
puts "Can't get #{from} - Internet down?"
exit!