This file contains hidden or 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/env ruby | |
| # Small desktop app for viewing the webcam at http://tjeld.uib.no/ | |
| # Written in Shoes. Works on at least Linux and OSX, | |
| # should be fine on Windows as well. | |
| require "open-uri" | |
| INTERVAL = 10 | |
| WIDTH = 240 |
This file contains hidden or 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
| # In Ruby 1.8 | |
| irb(main):008:0> "" + Errno::ENOENT.new | |
| => "No such file or directory" | |
| irb(main):009:0> "" + Errno::ENOENT.new.to_s | |
| => "No such file or directory" | |
| # In Ruby 1.9 | |
| irb(main):002:0> "" + Errno::ENOENT.new | |
| TypeError: can't convert Errno::ENOENT into String |
This file contains hidden or 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
| namespace :heroku do | |
| desc "Populates the .gems manifest file, to be used with Heroku" | |
| task :gems => :environment do | |
| File.open(File.join(RAILS_ROOT, ".gems"), "w") do |f| | |
| Rails.configuration.gems.each do |dep| | |
| f.puts dep.send(:install_command)[1..-1].join(' ') | |
| end | |
| end | |
| end | |
| end |
This file contains hidden or 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/zsh | |
| # -*- Abstract -*- | |
| # Backup the database from your Heroku webapp. 7 day rotating daily backup, | |
| # stores a weekly copy every week (on sundays). | |
| # | |
| # The latest version of this script is available from http://gist.github.com/111804 | |
| # Code by Bjørn Arild Mæland [github.com/Chrononaut] | |
| # | |
| # -*- Requirements and usage -*- |
This file contains hidden or 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/env python | |
| # Simple algorithm for clustering WordNet synsets. Requires Python 2.5 or 2.6, | |
| # in addition to the NLTK toolkit which is available at http://www.nltk.org/. | |
| import nltk | |
| from nltk.corpus import wordnet as wn | |
| from nltk.corpus import wordnet_ic | |
| def cluster_senses(word, treshold = 0.30, |
This file contains hidden or 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 "yaml" | |
| # Parser for Debian Control Files (http://www.debian.org/doc/debian-policy/ch-controlfields.html) | |
| # Piggybacks on the stdlib YAML parser, so this only works as long as there is a | |
| # space after the field names (this is a stated DCF convention). You'll encounter problems if | |
| # there are unescaped colons in the values. | |
| # | |
| # I've also built a full Treetop grammar for DCF: http://github.com/Chrononaut/treetop-dcf | |
| module Dcf |
This file contains hidden or 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
| # Copy `n Paste from IRB, based on http://judofyr.net/posts/copy-paste-irb.html | |
| # Requires xclip for clipboard interaction. Stick in .irbrc: | |
| def copy(str) | |
| IO.popen('xclip -i', 'w') { |f| f << str.to_s } | |
| end | |
| def paste | |
| `xclip -o` | |
| end |
This file contains hidden or 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
| # lib/github_gem.rb | |
| module Rails | |
| class Configuration | |
| def github_gem(name, options = {}) | |
| options[:source] = 'http://gems.github.com' | |
| options[:lib] = name.sub(/[^-]+-/, '') unless options.has_key?(:lib) | |
| self.gem(name, options) | |
| end | |
| end | |
| end |
This file contains hidden or 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/env python | |
| import nltk | |
| ## Tom Sawyer, by Mark Twain. | |
| ## Available from the Gutenberg Project: | |
| ## http://www.gutenberg.org/files/74/74.txt | |
| reader = nltk.corpus.reader.PlaintextCorpusReader('.', 'twain-tomsawyer.txt') | |
| words = reader.words('twain-tomsawyer.txt') # List of all the words in the text |
This file contains hidden or 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
| ## Usage: | |
| ## db <- Database("http://208.78.99.54:5984/", "packages") | |
| ## | |
| ## Insert(key, value, db) | |
| ## | |
| ## Note that values are automatically converted to JSON. | |
| source("curr.R") | |
| # The DB is created if it doesnt exist |