Skip to content

Instantly share code, notes, and snippets.

View rowanmanning's full-sized avatar
📢
honk

Rowan Manning rowanmanning

📢
honk
View GitHub Profile
@rowanmanning
rowanmanning / shorthand-ternary.php
Created June 21, 2011 13:51
PHP 5.3's shortened ternary operator
<?php
function hello($arg = 'World') {
// sanitize arguments
$arg = $arg ?: 'World';
// return message
return "Hello {$arg}!";
<?php
// looking for the spoiler image mentioned in https://twitter.com/notch/status/84361767962161152
$letters = array_merge(range('a', 'z'), range('A', 'Z'));
foreach ($letters as $letter) {
$image = 'http://i.imgur.com/IKc7' . $letter . '.png';
print '<img src="' . $image . '" alt="Is is this one?" style="display: block; margin: 0 0 20px 0"/>';
}
@rowanmanning
rowanmanning / playing.coffee
Created October 26, 2011 21:18
Just learning a bit of CoffeeScript
# represents a person
class Person
# properties
name: null
alive: true
stomach: 0
bladder: 0
@rowanmanning
rowanmanning / git-pull-push-aliases.sh
Created January 13, 2012 10:38
Git aliases: pull = '-', push = '=', pull+push = '-='. Not using `alias` because I couldn't work out how to make it accept '-' and '='. Tested on Mac OS X 10.7
tmp_prefix="/usr/local/bin/"
echo "git pull;" > $tmp_prefix-;
echo "git push;" > $tmp_prefix=;
echo "git pull && git push;" > $tmp_prefix-=;
chmod 755 $tmp_prefix- $tmp_prefix= $tmp_prefix-=;
@rowanmanning
rowanmanning / README.md
Created January 27, 2012 10:39
Useful Git aliases - run these commands

Pretty log format

Graph with author and commit hash:

git config --global alias.plog 'log --graph --pretty=format:\"%C(yellow)%h%x20%C(green)%an%x20%Creset%s\"'

Standup

@rowanmanning
rowanmanning / example.less
Created June 16, 2012 18:06
LESS Hackery
// Allows specifying default variables in LESS
// Some really sneaky shit that will shoot me in the foot if
// LESS changes too much...
@--lol: ~`"" + ( root._less = root._less || this )`;
@--lol: ~`"" + ( root.getLessVar = function (name) { return root._less[name] ? root._less[name].toJS() : '' } )`;
@--lol: ~`"" + ( root.getLessVarDefault = function (name, def) { return root.getLessVar(name) !== '' ? root.getLessVar(name) : root.getLessVar(def) } )`;
// Example:
@rowanmanning
rowanmanning / instructions.md
Created October 25, 2012 13:31
Git Autocompletion On Mac OS X

Git Autocompletion On Mac OS X

(based on this post which I don't like because they tell you to add a bash file to your home directory)

Run the following commands to begin:

cd /usr/local/bin && curl https://github.com/git/git/raw/master/contrib/completion/git-completion.bash -OL
@rowanmanning
rowanmanning / demo.html
Last active October 12, 2015 15:08
Simple Konami Code with jQuery
<!DOCTYPE html>
<meta charset="utf-8"/>
<title>↑ ↑ ↓ ↓ ← → ← → B A</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="konami.js"></script>
<script>
// On document ready
@rowanmanning
rowanmanning / library.scss
Created January 17, 2013 13:24
Sass defaults example
$foo: 'bar' !default;
// ...do stuff
@rowanmanning
rowanmanning / useful-mac-tools.md
Created March 18, 2013 11:11
Useful Mac tools that I use all the time