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
#!/bin/sh | |
# Usage: switch2branch branchname | |
# Easily switch between branches and their databases for Rails projects. | |
# Checks out given branch and copies the branch's database.yml to the active database.yml | |
# Outputs a small list of databases being used. | |
# Make sure you have set up your branch's database.yml in #{RAILS_ROOT}/config/database.branch.#{branchname}.yml | |
git checkout $1 && cp ./config/database.branch.$1.yml ./config/database.yml | |
echo Using: | |
egrep "^\\w+:|database:" config/database.yml | sed s/database:/\ / |
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 | |
# encoding: utf-8 | |
# Your random BOFH excuse calendar. | |
# Based upon the The Bastard Operator From Hell Stories written by Simon Paul Travaglia. | |
# And the list compiled by Jeff Ballard, http://jeffballard.us/ | |
# Get the excuses from http://pages.cs.wisc.edu/~ballard/bofh/excuses | |
fp = File.expand_path('~/bin/bofh/excuses.txt') | |
lines = File.readlines(fp) | |
nr = rand(lines.size) |
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 | |
# Iterate through dirs in the current directory and do a `git grep` on the given keyword in each one of them. | |
# Outputs the command and each result. | |
Dir.glob('*/').each do |dir| | |
string = ARGV.join(' ').gsub(/(\W)/) do |match| | |
'\\%s' % match | |
end | |
cmd = "cd #{dir} && git grep #{string}" | |
output = `#{cmd}` |
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
<?php | |
// Adonis from Chat4All needed a multibyte wordwrap function that support multiple words, | |
// So based on some code from php.net I hacked together the following function. | |
// It's not pretty, but it works. It is supposed to be combined with a simple bbcode parser. | |
/* | |
* Based on code by Matt at newbiewebdevelopment dot idk | |
* http://nl2.php.net/manual/en/function.wordwrap.php#89369 | |
* Adapted to support multiple words by Filip H.F. "FiXato" Slagter, | |
* http://github.com/FiXato |
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 | |
require 'tempfile' | |
case ARGV[0] | |
when nil | |
abort "usage: mysqluser [add|] <arg(s)>" | |
when 'add' | |
abort "usage: mysqluser add <username> <password>" unless ARGV[2] | |
usernames = ["'#{ARGV[1]}'@'localhost'", "'#{ARGV[1]}'@'%'"] | |
mysql_commands = [] | |
usernames.each do |username| |
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
# use the ubuntu machine gem | |
require 'capistrano/ext/ubuntu-machine' | |
# ####################################### | |
# HOSTING PROVIDER CONFIGURATION | |
# Those tasks have been tested with several hosting providers | |
# and sometimes tasks are specific to those providers | |
set :hosting_provider, "slicehost" # currently supported : ovh-rps, ovh-dedie, slicehost |
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
# Rake tasks to install OpenTTD from their Subversion source. | |
# Note: this is used on a Macbook, so the configuration and installation are based on this. | |
def cmd(str) | |
puts str | |
system str | |
end | |
desc 'Configure sources for compilation' | |
task :configure do | |
cmd './configure --with-ccache --enable-strip --disable-universal --with-cocoa MAKEOPTS="-j5" CFLAGS="-pipe" CXXFLAGS="-pipe"' |
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
# Works like :gem for rails, but sets source to github's gem repo. | |
# add to lib/github_gem.rb in your rails project. | |
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 |
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 | |
# Usage: githubify <gemspec_file> [username] | |
# Requires: github.name to be set for the current git project or [username] to be specified | |
# Result: creates/overwrites a file named <username>-<gemspec_file> and updates the s.name in there have the same project name format. | |
# | |
# Author: Wes Oldenbeuving | |
# E-mail: [email protected] | |
# License: MIT-LICENSE | |
class 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
#!/usr/bin/env ruby | |
orig_lines = File.read('24_Hour_Party_People.srt').strip.split("\r\n\r") | |
replacement_lines = File.read('24_Hour_Party_People_utf8.txt').strip.split("\n\n") | |
File.open('24ppl.srt','w') do |f| | |
orig_lines.each_with_index do |l,i| | |
l.strip! | |
srt = l.split("\n") | |
next unless replacement_lines[i] | |
nsrt = replacement_lines[i].split("\n") | |
f.puts(srt[0]) |
OlderNewer