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 | |
## Setting up files for a new Bundler/RVM Ruby project | |
## $ make_ruby_project some_new_project | |
## | |
## This could be cleaner split into multiple files and seperate templates | |
## But a single file in the your bin directory is easier to manage | |
## | |
## A More mainstream version is part of bundler | |
## bundle gem some_new_project | |
## |
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/bash | |
# Disk level Back up script | |
ARCHIVE_SERVER="192.168.0.30" | |
# Back up drive to target drive on server | |
disk[0]="/Volumes/Terra03/ $ARCHIVE_SERVER:/mnt/kryten/disk1/tank" | |
disk[1]="/Volumes/Terra04/ $ARCHIVE_SERVER:/mnt/kryten/disk2/tank" | |
disk[2]="/Volumes/Terra05/ $ARCHIVE_SERVER:/mnt/kryten/disk3/tank" |
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 'pp' | |
require 'yaml' | |
require 'active_record' | |
@environment = ENV['RACK_ENV'] || 'development' | |
@dbconfig = YAML.load(File.read('config/database.yml')) | |
ActiveRecord::Base.establish_connection @dbconfig[@environment] |
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/bash | |
#VAR is then name of the variable to look for | |
VAR=$1 | |
eval test=\${$VAR} | |
if [ "$test" == "" ] | |
then |
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
class Golf | |
class << self | |
def hole1 a | |
a.reduce :* | |
end | |
def hole2 s | |
s.split.sort_by{|i| i[1] }*' ' | |
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
class Golf | |
class << self | |
def hole1 a | |
a.reduce :* | |
end | |
def hole2 s | |
s.split.sort_by{|i| i[1] }.join ' ' | |
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
pre_add_path() { | |
if [ -s "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then | |
PATH="$1:$PATH" | |
fi | |
} | |
post_add_path() { | |
if [ -s "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then | |
PATH="$PATH:$1" | |
fi | |
} |
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
files = (Dir.glob("*.*")+Dir.glob(".*")).delete_if {|k| File.directory?(k)} |
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
def int_to_hex_binary_position( num, chars=8 ) | |
return "0x#{(2**num).to_s(16).rjust(chars,'0')}" | |
end | |
int_to_hex_binary_position( 0 ) | |
> 0x00000001 | |
int_to_hex_binary_position( 1 ) | |
> 0x00000002 |
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
Dir.chdir( File.dirname( File.expand_path(__FILE__) ) ) |