Skip to content

Instantly share code, notes, and snippets.

Joël Cox joelcox

View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am joelcox on github.
  • I am joelcox (https://keybase.io/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
joelcox / promise-chained.js
Last active Aug 29, 2015
Chained promises
View promise-chained.js
promise.then(function(response) {
console.log(response);
return promise;
}).then(function(anotherResponse) {
console.log(anotherResponse);
}).catch(function(error) {
console.error(error);
});
@joelcox
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
joelcox / promise-parallel.js
Last active Aug 29, 2015
Parallel promises
View promise-parallel.js
actions: {
submitForm: function() {
var model = this.store.createRecord('post');
this.resolveKeywords(controller.get('postKeywords')).then(function(keywords) {
model.get('keywords').pushObjects(keywords);
return model.save();
}).then(function() {
controller.transitionToRoute('post', model);
});
@joelcox
joelcox / resource-action.json
Last active Aug 29, 2015
Resource action request
View resource-action.json
PATCH http://localhost:5000/comments/1
{
"favorite": true
}
@joelcox
joelcox / resource-download.json
Created Feb 23, 2015
Resource download request
View resource-download.json
GET http://localhost:5000/articles/8
Content-Type: application/pdf
@joelcox
joelcox / resource-options.json
Created Feb 23, 2015
Resource options request
View resource-options.json
GET http://localhost:5000/orders/4
{
"status": "shipped"
}
OPTIONS http://localhost:5000/orders/4
{
"PUT": {
"description": "Modify the status of a shipped order",
"parameters": {
@joelcox
joelcox / schedule.md
Last active Aug 29, 2015
Cycling calendar 2015
View schedule.md

Spring classics

  • Feb 28 (Sat) - Omloop Het Nieuwsblad
  • Paris – Nice
  • Mar 22 (Sun) - Milan – San Remo
  • Mar 27 (Fri) - E3 Harelbeke
  • Mar 29 (Sun) - Gent–Wevelgem
  • Apr 5 (Sun) - Tour of Flanders
  • Apr 12 (Sun) - Paris – Roubaix
@joelcox
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 <name@domain.com>"
# Set a global .gitignore
git config --global core.excludesfile ~/.gitignore
@joelcox
joelcox / post-receive
Created May 11, 2011
Add commit hash constant
View post-receive
#!/bin/bash
# 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"`
You can’t perform that action at this time.