Skip to content

Instantly share code, notes, and snippets.

Joël Cox joelcox

View GitHub Profile
joelcox / Git cheat sheet
Created Apr 4, 2011
WIP git cheat sheet
View Git cheat sheet
# Various handy commands
# Change the author of the previous commit
git commit --amend --author="Name <>"
# Set a global .gitignore
git config --global core.excludesfile ~/.gitignore
joelcox / post-receive
Created May 11, 2011
Add commit hash constant
View post-receive
# Append the latest commit hash to your PHP constants file after the Git repository received a push.
# Path to constants file
CONST_PATH = ../../application/config/constants.php
# Ask git for the last abbreviated commit hash
HASH = `git log -1 --pretty=format:"%h"`
View gist:1173336
function time_ago($time)
$time = (is_numeric($time) ? $time : strtotime($time));
$delta = time() - $time;
switch (TRUE)
case ($delta < 0):
View gist:1271085


\w get into target mode.


viws<strong> wrap the word under the cursor in tags.

View gist:2621608
import os
import sys
import csv
sys.path.insert(0, os.path.abspath('../miner/'))
import miner.utils
import miner.clustering
def render_to_file(space, clusters):
joelcox / gist:6641424
Last active Dec 23, 2015
Bind to multimedia keys
View gist:6641424

Bind to multimedia keys

Web applications are increasingly taking over the functions of native applications. This year has seen an increase of (streaming) audio web applications, such as Rdio, Spotify, Pandora, etc. These applications are long-running applications and provide multimedia to the user, often while the user is doing something else.

Interaction with this type of application works the same as with other applications: the user brings the tab/window in focus and manipulates the application through mouse, keyboard or other input device. Bringing the application into focus is required in order to interact with the application and thus requires the user to get out of the current workflow.

In native applications this problem is fixed by letting applications bind to specific multimedia buttons situated on the keyboard. These buttons serve as a way to interact with the media player without bringing the application into focus. This is currently impossible for web applications for t


Keybase proof

I hereby claim:

  • I am joelcox on github.
  • I am joelcox ( on keybase.
  • I have a public key whose fingerprint is 95EE 753A 4045 B7C9 510C 12BF 126D 73CE D1E8 5215

To claim this, I am signing this object:

joelcox / promise.js
Created Feb 19, 2015
Dealing with basic promises
View promise.js
var promise = new Ember.RSVP.Promise(function(resolve, reject) {
console.log('Promise is pending');
setTimeout(function() {
if (Math.random() < 0.7) {
resolve({'status': 'ok'});
reject('Whoops, something went wrong');
}, 1000);
joelcox / promise-chained.js
Last active Aug 29, 2015
Chained promises
View promise-chained.js
promise.then(function(response) {
return promise;
}).then(function(anotherResponse) {
}).catch(function(error) {
joelcox / promise-parallel.js
Last active Aug 29, 2015
Parallel promises
View promise-parallel.js
actions: {
submitForm: function() {
var model ='post');
this.resolveKeywords(controller.get('postKeywords')).then(function(keywords) {
}).then(function() {
controller.transitionToRoute('post', model);
You can’t perform that action at this time.