Skip to content

Instantly share code, notes, and snippets.

Giles gilesbowkett

Block or report user

Report or block gilesbowkett

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:15317
#!/usr/bin/python
import gdata.youtube
import gdata.youtube.service
youtube_service = gdata.youtube.service.YouTubeService()
# randomly selected, mostly funny, some just stupid and lame
video_ids = ["6d26GGXkzR0", "21OH0wlkfbc", "PbeMwl_PA6A", "aSk0KDAc1gs"]
video_ids += ["JfXDAUIc9Xc", "hPPmLZ9dcRA", "frO6AC6wAc0", "0_fPV13lKm4"]
View ruby_conf_vids.rb
require "rubygems"
require "hpricot"
require "open-uri"
url = "http://feeds.feedburner.com/Rubyconf2008-Confreaks"
(Hpricot(open url)/:enclosure).map {|x| x.attributes["url"]}.uniq.each do |vid|
filename = vid.gsub(/http:.+\//, '')
filename.gsub!(/-/, "_")
next if File.exist?(filename)
View ruby_conf_vids.rb
require "rubygems"
require "hpricot"
require "open-uri"
url = "http://feeds.feedburner.com/Rubyconf2008-Confreaks"
(Hpricot(open url)/:enclosure).map {|x| x.attributes["url"]}.uniq.each do |vid|
# File.exist?(vid.split("/").last) ? next : `curl #{vid}`
filename = vid.gsub(/http:.+\//, '')
filename.gsub!(/-/, "_")
View gist:57952
# hip-hop
probabilities[36] = [1.0, 0.0, 0.5, 0.25, 0.0, 0.6, 0.0, 0.9, 0.9, 0.0, 1.0, 0.0, 0.5, 0.0, 0.3, 0.0]
probabilities[37] = [0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.3, 0.0, 1.0, 0.0, 0.0, 0.0]
# d&b
# probabilities[36] = [1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0]
# probabilities[37] = [0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0]
# both
probabilities[38] = [0.2, 0.0, 0.3, 0.0, 0.3, 0.1, 0.3, 0.4, 0.0, 0.0, 0.2, 0.0, 0.4, 0.0, 0.0, 0.0]
View in some functional test.rb
# How does that session value get set!?
class << @response.session
def []=(k,v)
puts "Setting session[#{k.inspect}] = #{v.inspect} (#{caller[0]})"
super
end
end
View gist:100820
# http://gilesbowkett.blogspot.com/2009/04/unshiftfiledirnamefile.html
class File
class << self
def here(__file__, string)
expand_path(dirname(__file__)) + string
end
end
end
# usage
View gist:104149
def rubyurl(original_url)
/<permalink>(h.+)<\/permalink>/.match(
RestClient.post("http://rubyurl.com/api/links",
:link => {:website_url => original_url})
)[1]
end
View gist:122071
# http://www.jamesbritt.com/2007/12/18/sending-mail-through-gmail-with-ruby-s-net-smtp
# http://d.hatena.ne.jp/zorio/20060416
require "openssl"
require "net/smtp"
Net::SMTP.class_eval do
private
def do_start(helodomain, user, secret, authtype)
raise IOError, 'SMTP session already started' if @started
View gist:145758
# title (from "Mac OS X For Unix Geeks")
set_title() {
case $TERM in
*term | xterm-color | rxvt | vt100 | gnome* )
echo -n -e "\033]0;$*\007" ;;
*) ;;
esac
}
View gist:224612
for repo in `ls`
do
cd $repo;
echo $repo;
git pull;
cd ~/dev/work/project_name
done
You can’t perform that action at this time.