Skip to content

Instantly share code, notes, and snippets.

Avatar

Filip H.F. "FiXato" Slagter FiXato

View GitHub Profile
@FiXato
FiXato / bash_prompt_with_git_and_rbenv.sh
Last active Aug 29, 2015 — forked from kyanny/gist:1668822
Updated original bash prompt with git and rbenv example with a check for the __git_ps1 function instead of existence of a git bash-completion file.
View bash_prompt_with_git_and_rbenv.sh
# rbenv
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
source ~/.rbenv/completions/rbenv.bash
# prompt with ruby version
# rbenv version | sed -e 's/ .*//'
__rbenv_ps1 ()
{
rbenv_ruby_version=`rbenv version | sed -e 's/ .*//'`
View mage.rb
class Mage < Player
def initialize(*args)
super(*args)
@str, @int, @dex = 1, 6, 2
end
def level_up
@str += 1
@int += 6
@dex += 2
@FiXato
FiXato / en.yml
Last active Aug 29, 2015 — forked from henrik/en.yml
View en.yml
# config/locales/en.yml
en:
i18n:
language:
name: 'English'
@FiXato
FiXato / switch2branch.sh
Created Jan 15, 2009
Switch between github branches and change the rails database.yml
View switch2branch.sh
#!/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:/\ /
@FiXato
FiXato / gitgrepper.rb
Created Mar 12, 2009
Iterate through dirs in the current directory and do a `git grep` on the given keyword in each one of them.
View gitgrepper.rb
#!/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}`
@FiXato
FiXato / mysqluser.rb
Created Apr 1, 2009
mysqluser.rb — no more looking up mysql syntax for adding users…
View mysqluser.rb
#!/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|
@FiXato
FiXato / deploy.rb
Created Jun 17, 2009
deploy.rb for UbuntuMachine
View deploy.rb
# 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
@FiXato
FiXato / openttd.rake
Created Jun 18, 2009 — forked from Narnach/openttd.rake
OpenTTD Rakefile
View openttd.rake
# 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"'
@FiXato
FiXato / github_gem.rb
Created Jul 13, 2009 — forked from bmaland/github_gem.rb
github_gem for rails
View github_gem.rb
# 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
@FiXato
FiXato / githubify.rb
Created Jul 31, 2009 — forked from Narnach/githubify.rb
creates/overwrites a file named <username>-<gemspec_file> and updates the s.name in there have the same project name format.
View githubify.rb
#!/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: narnach@gmail.com
# License: MIT-LICENSE
class String