Skip to content

Instantly share code, notes, and snippets.

@bartimaeus
bartimaeus / Install rvm on Ubuntu
Created October 16, 2010 16:01
Installing rvm on Ubuntu
## Run the following from your terminal ##
# Get git and curl and install rvm
sudo aptitude install curl git-core
bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
sed -i 's/^\[/# [/' ~/.bashrc
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"' >> ~/.bashrc
source ~/.bashrc
# Next, install dependencies for compiling Ruby
@bartimaeus
bartimaeus / palindrome.rb
Created December 7, 2010 20:29
Trying to solve a challenge given to me yesterday to write a script that tests for palindromes on strings with unknown length and no special characters (alphanumeric only)
#!/bin/ruby
# I want to make this a class, but until I get all the
# bugs worked out it will just be a script :-)
#class Palindrome
def isPalindrome(string)
palindrome = true
reverse = string.reverse
@bartimaeus
bartimaeus / 20101208130030_rename_inventories_added_fields.php
Created December 8, 2010 20:02
Example of a CakePHP Migration that changes the database schema
<?php
/**
* @author Eric Shelley <eric@webdesignbakery.com>
*/
class M20101208130030 extends CakeMigration
{
/**
* Migration description
*
* @var string
@bartimaeus
bartimaeus / cake_join.php
Created December 9, 2010 15:49
Example of CakePHP Join
<?php
// Join example
$result = $this->Product->find('all', array(
'fields' => array(
'Product.name',
'ProductCategory.name'
),
'joins' => array(
array(
@bartimaeus
bartimaeus / .bashrc
Created December 23, 2010 17:22 — forked from henrik/.bashrc
# Original: http://henrik.nyh.se/2008/12/git-dirty-prompt
#
# I've modified the prompt to be simple and clean; also, I colored the branch rather than the path
# ~/dev/dir[master]$ # clean working directory
# ~/dev/dir[master*]$ # dirty working directory
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
function parse_git_branch {
git_status="$(git status 2> /dev/null)"
pattern="^# On branch ([^${IFS}]*)"
if [[ ! ${git_status}} =~ "working directory clean" ]]; then
state="*"
fi
# add an else if or two here if you want to get more specific
if [[ ${git_status} =~ ${pattern} ]]; then
branch=${BASH_REMATCH[1]}
@bartimaeus
bartimaeus / company.rake
Created February 18, 2011 14:43
Part of my FatFreeCRM migration rake task. I've added custom fields and roles to this install of FatFreeCRM. The files used by this rake task are generated by another task that downloads them and converts then to csv files using the pipe "|" as the delimi
# Store rake tasks specific to [company]
namespace :[company] do
# Migrate [Company]'s data into the new CRM
namespace :migrate do
require 'progressbar'
desc "Run all [company] migration tasks"
task :all => [:config, :users, :comments, :accounts]
@bartimaeus
bartimaeus / .bashrc
Created February 28, 2011 20:21
Git branch display in console [~/.bashrc]
#!/bin/sh
# Show git status and branch
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}
export PS1='\[\033[0m\]\w\[\033[1;33m\]$(parse_git_branch)\[\033[0m\]$ '
@bartimaeus
bartimaeus / .profile
Created March 31, 2011 21:22
Here's my .profile that I use on my macbook
#!/bin/sh
export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad
#showing git branches in bash prompt
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
@bartimaeus
bartimaeus / .bash_profile
Created July 30, 2011 14:05
Manage Multiple EC2 Accounts
# Custom bash scripts
export PATH=$PATH:~/bin
# AWS Settings
export AWS_HOME=~/.aws
export EC2_HOME=$AWS_HOME/cli_tools/ec2-api-tools
export AWS_AUTO_SCALING_HOME=$AWS_HOME/cli_tools/as-api-tools
export PATH=$PATH:$EC2_HOME/bin:$AWS_AUTO_SCALING_HOME/bin
export EC2_PRIVATE_KEY=$AWS_HOME/pk-ec2.pem
export EC2_CERT=$AWS_HOME/cert-ec2.pem