Skip to content

Instantly share code, notes, and snippets.

View itspriddle's full-sized avatar
🤘
clickity clack

Josh Priddle itspriddle

🤘
clickity clack
View GitHub Profile
#!/usr/bin/ruby
# Tested on OS X Leopard only but should work
# for BSDs
start = /\{ sec = ([0-9]+),/.match(`sysctl -n kern.boottime`).captures[0]
uptime_secs = (Time.now.to_f - start.to_f).round
def seconds_to_time(seconds)
<?php
function parse_sdp($packet = '')
{
$out = array();
$lines = explode("\n", $packet);
foreach ($lines as $l)
{
$l = trim($l);
# Create a ~/.twitter/credentials.yml file.
# Example:
# name: twittername
# password: password
require 'rubygems'
require 'rest_client'
path = File.join(File.join(ENV['HOME'], ".twitter"), "credentials.yml")
user = YAML::load_file(path)
@itspriddle
itspriddle / gist:88109
Created March 31, 2009 08:49
~/.input.rc
# allow the use of the Home/End keys
"\e[1~": beginning-of-line
"\e[4~": end-of-line
# allow the use of the Delete/Insert keys
"\e[3~": delete-char
"\e[2~": quoted-insert
# allow ctrl/alt + arrow keys to work
"\e[5C": forward-word
@itspriddle
itspriddle / gist:91536
Created April 7, 2009 23:43
bash_completion
# bash_completion - programmable completion functions for bash 3.x
# (backwards compatible with bash 2.05b)
#
# $Id: bash_completion,v 1.872 2006/03/01 16:20:18 ianmacd Exp $
#
# Copyright (C) Ian Macdonald <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
{
"\UF729" = "moveToBeginningOfLine:"; /* Home */
"\UF72B" = "moveToEndOfLine:"; /* End */
"$\UF729" = "moveToBeginningOfLineAndModifySelection:"; /* Shift + Home */
"$\UF72B" = "moveToEndOfLineAndModifySelection:"; /* Shift + End */
}
/*
Add to ~/Library/KeyBindings/DefaultKeyBinding.dict
Create the directory if it does not exist
@itspriddle
itspriddle / gist:93422
Created April 11, 2009 02:29
perl rename
#!/usr/bin/perl -w
#
# This script was developed by Robin Barker ([email protected]),
# from Larry Wall's original script eg/rename from the perl source.
#
# This script is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
#
# Larry(?)'s RCS header:
# RCSfile: rename,v Revision: 4.1 Date: 92/08/07 17:20:30
echo '.DS_Store' >> ./.gitignore
echo '*.swp' >> ./.gitignore
echo 'config/database.yml' >> ./.gitignore
echo 'config/mailer.yml' >> ./.gitignore
echo '*.sql' >> ./.gitignore
echo 'index/' >> ./.gitignore
echo 'public/system' >> ./.gitignore
echo 'public/tmp/' >> ./.gitignore
echo '[^.]*' > ./log/.gitignore
#!/bin/bash
usage() {
cat <<-EOT
usage: $0 [home|work]
This script starts a Synergy server for home or work.
EOT
}
def valid_card?(num)
odd = true
num.to_s.gsub(/\D/,'').reverse.split('').map(&:to_i).collect { |d|
d *= 2 if odd = !odd
d > 9 ? d - 9 : d
}.sum % 10 == 0
end