View gist:15317
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for repo in `ls` | |
do | |
cd $repo; | |
echo $repo; | |
git pull; | |
cd ~/dev/work/project_name | |
done |
OlderNewer