Skip to content

Instantly share code, notes, and snippets.

View mlambie's full-sized avatar
🇦🇺
$ iex -S mix

Matt Lambie mlambie

🇦🇺
$ iex -S mix
View GitHub Profile
# Recursion
def recursive x
return if x >= 10
puts x
recursive x + 1
end
recursive 0
@mlambie
mlambie / colours.sh
Created June 22, 2009 05:07
Print the rainbow of colours in your terminal
#!/bin/bash
# Credit: http://blog.infinitered.com/entries/show/6
echo -e "\\e[0mCOLOR_NC (No color)"
echo -e "\\e[1;37mCOLOR_WHITE\\t\\e[0;30mCOLOR_BLACK"
echo -e "\\e[0;34mCOLOR_BLUE\\t\\e[1;34mCOLOR_LIGHT_BLUE"
echo -e "\\e[0;32mCOLOR_GREEN\\t\\e[1;32mCOLOR_LIGHT_GREEN"
echo -e "\\e[0;36mCOLOR_CYAN\\t\\e[1;36mCOLOR_LIGHT_CYAN"
echo -e "\\e[0;31mCOLOR_RED\\t\\e[1;31mCOLOR_LIGHT_RED"
@mlambie
mlambie / today.sh
Created July 1, 2009 01:54
An ordered account of the commits made against a git repo since midnight
#!/bin/bash
git log --oneline --reverse --since="midnight" --author="mlambie"
<?php
require_once('FirePHPCore/FirePHP.class.php');
require_once('FirePHPCore/fb.php');
// some reports indicate the output buffering is required
// ob_start();
FB::setEnabled(true);
-- Register to track if we need a new window or not
set tab_count to 0
-- The names of the screen sessions - change as necessary
set screen_names to {"tfg_1", "tfg_2", "tfg_3", "tfg_4"}
-- Make our settings globally available
global tab_count, screen_names
-- Mainline
@mlambie
mlambie / gist:220522
Created October 28, 2009 14:58
Updating an encrypted attribute to an empty string doesn't actually update the attribute
>> c = Factory(:credit_card)
=> #<CreditCard id: 2, first_name: "Royce", last_name: "Ritchie", number: "4ioaILZVhGjVtdV7yJXBUFl8o6c2LeqPQAkRPSnUHl4=\n", month: 10, year: 2010, scheme: "visa", start_month: nil, start_year: nil, issue_number: nil, created_at: "2009-10-28 14:31:10", updated_at: "2009-10-28 14:31:10", friendly_name: nil, token: "f55440238e4dda3298ee9c625c00494ba6608000">
>> c.number.decrypt(PASSWORD)
=> "4242424242424242"
>> c.number = '4242424242424241'
=> "4242424242424241"
>> c.save
=> false
>> c.number.decrypt(PASSWORD)
=> "4242424242424241"
@mlambie
mlambie / survey
Created November 1, 2009 13:37 — forked from radar/survey.md
** What did you do to get good at Rails?
ML: The only thing you can do is cut code. You can read all the books,
watch all the screencasts and subscribe to all the blogs in the world,
but until you start writing your own code, you won't get experience and
you won't become proficient in Rails.
** Who taught you what you know?
ML: Railscasts with Ryan Bates is the obvious one, but lately I've really
mlambie@prowl:~$ grep mlambie /etc/passwd
mlambie:x:1000:1001:Matthew Lambie,,,:/home/mlambie:/bin/bash
mlambie@prowl:~$ grep mlambie /etc/passwd | sed 's/Matthew/Andrew/'
mlambie:x:1000:1001:Andrew Lambie,,,:/home/mlambie:/bin/bash
@mlambie
mlambie / gist:581951
Last active September 23, 2015 16:18
# The desired array
frequencies = ["hourly", "daily", "weekly", "monthly"]
# Shorthand conversion into array
frequencies = %w{hourly daily weekly monthly}
# Note the delimiter is not important, but must match
frequencies = %w"hourly daily weekly monthly"
frequencies = %w|hourly daily weekly monthly|
mencoder -endpos 01:00:00 -ovc copy -oac copy input.avi -o first_hour.avi
mencoder -ss 01:00:00 -oac copy -ovc copy input.avi -o remainder.avi