Skip to content

Instantly share code, notes, and snippets.

@pjaspers
pjaspers / gist:241847
Created November 24, 2009 12:40
A class to generate a Haiku in ruby (prototype for haikuherman.eu)
require 'lingua/en/readability'
class Haiku
def initialize(text)
@report = Lingua::EN::Readability.new(text)
@used_words = Array.new
end
def get_most_used_words(words)
top_words = Array.new
words.sort{|a,b| a[1]<=>b[1]}.slice(words.length/2..words.length).each do |a|
@pjaspers
pjaspers / gist:241851
Created November 24, 2009 12:48
Beech · Tweet from your homerow
# A quick way to tweet from the command line
# As for the name: http://itunes.com/app/oak by @10to1
# Added 'oak' as source.
function beech(){
# Twitter != Rocket Science, so security is not that much of an issue
TWITTER_BEECH_USER="username"
TWITTER_BEECH_PASS="password"
if [ $# -ge 1 ]; then
@pjaspers
pjaspers / gist:247182
Created December 2, 2009 13:05
Simple script to get the links to all of Steve Yegge's articles
require 'rubygems'
require 'hpricot'
require 'open-uri'
# Steve's *cough* new blog
doc = open("http://steve-yegge.blogspot.com/") { |f| Hpricot(f) }
steves_new_blog = Array.new()
(doc/"ul.posts").each { |post|steves_new_blog << post.search("li/a").collect { |a| a.attributes['href']}}
# Steves old blog
@pjaspers
pjaspers / Random Yegge Bookmarklet
Created December 2, 2009 13:09
Bookmarklet to get a random post from one of Steve yegge's blogs
// javascript:var%20yegge_posts%20=%20new%20Array(%22http://steve-yegge.blogspot.com/2009/05/programmers-view-of-universe-part-3.html%22,%20%22http://steve-yegge.blogspot.com/2009/04/have-you-ever-legalized-marijuana.html%22,%20%22http://steve-yegge.blogspot.com/2009/03/story-time.html%22,%20%22http://steve-yegge.blogspot.com/2008/12/programmers-view-of-universe-part-2.html%22,%20%22http://steve-yegge.blogspot.com/2008/12/fable-ii-arguably-better-than-getting.html%22,%20%22http://steve-yegge.blogspot.com/2008/11/ejacs-javascript-interpreter-for-emacs.html%22,%20%22http://steve-yegge.blogspot.com/2008/10/programmers-view-of-universe-part-1.html%22,%20%22http://steve-yegge.blogspot.com/2008/10/universal-design-pattern.html%22,%20%22http://steve-yegge.blogspot.com/2008/09/bellic-school-of-management-training.html%22,%20%22http://steve-yegge.blogspot.com/2008/09/programmings-dirtiest-little-secret.html%22,%20%22http://steve-yegge.blogspot.com/2008/08/business-requirements-are-bullshit.html%22,%20%22http://steve-y
@pjaspers
pjaspers / rinari
Created February 16, 2010 10:28
Restart passenger form emacs
;; As seen on
;; http://lucky-dip.net/articles/2009/08/06/restart-passenger-from-emacs-using-rinari/
;; Anyway, here is a small snippet of emacs lisp to easily restart the
;; Passenger server for the project you are currently working on. It
;; assumes you have Rinari installed.
(defun restart-passenger ()
"Restart passenger using the current rinari root" (interactive)
(shell-command (concat "touch " (rinari-root) "tmp/restart.txt"))
(message "Passenger restarted"))
@pjaspers
pjaspers / words.rails
Created March 10, 2010 22:20
A list of RoR keywords to use with typespeed.
Rails
after_create
after_destroy
after_filter
after_save
after_update
after_validation
after_validation_on_create
after_validation_on_update
alias
@pjaspers
pjaspers / my_recipe.rb
Created March 11, 2010 23:49
Notify Campfire of a deploy
require 'etc'
require 'broach'
Capistrano::Configuration.instance(:must_exist).load do
task "notify campfire" do
source_repo_url = repository
deployer = Etc.getlogin
deploying = `git rev-parse HEAD`[0,7]
begin
deployed = previous_revision[0,7]
def connection(connection, didSendBodyData:bytesWritten, totalBytesWritten:totalBytesWritten, totalBytesExpectedToWrite:totalBytesExpectedToWrite)
puts "Written: #{bytesWritten} TotalBytesWritten: #{totalBytesWritten} TotalBytesExpectedToWrite: #{totalBytesExpectedToWrite}"
puts "Double: #{totalBytesWritten / (totalBytesExpectedToWrite/100)}"
progress_bar.setDoubleValue(totalBytesWritten / (totalBytesExpectedToWrite/100))
end
@pjaspers
pjaspers / junkiesxl.zsh
Created April 16, 2010 13:14
Autocomplete zsh projects folder
function go() {
if [[ -e ~/development/rails/$1 ]]; then
cd ~/development/rails/$1
elif [[ -e ~/development/sinatra/$1 ]]; then
cd ~/development/sinatra/$1
elif [[ -e ~/development/objc/$1 ]]; then
cd ~/development/objc/$1
elif [[ -e ~/development/php/$1 ]]; then
cd ~/development/php/$1
elif [[ -e ~/development/ruby/$1 ]]; then