Skip to content

Instantly share code, notes, and snippets.

@chrislaughlin
chrislaughlin / addSub
Created June 29, 2014 19:06
Increment and Decrement
var add = 0;
console.time('add');
for (var i = 0; i < 100; i++) {
add++;
}
console.timeEnd('add');
var sub = 0;
console.time('sub');
for (var i = 0; i < 100; i++) {
var request = require('request');
request('http://www.google.com', function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log(body) // Print the google web page.
}
})
@chrislaughlin
chrislaughlin / pizza
Created July 15, 2014 20:30
Commander
Usage: pizza [options]
Options:
-V, --version output the version number
-p, --peppers Add peppers
-P, --pineapple Add pineapple
-b, --bbq Add bbq sauce
-c, --cheese <type> Add the specified type of cheese [marble]
-h, --help output usage information
@chrislaughlin
chrislaughlin / Code
Created August 3, 2014 13:46
Worker Queue Example
WorkerQueue.createQueue('PrintPeople', function(person) {
console.log('Time: ' + new Date());
console.log(person.name);
console.log(person.location);
}, 1000);
WorkerQueue.pushItem('PrintPeople', {name: 'Peter', location: 'london'});
WorkerQueue.pushItem('PrintPeople', {name: 'Paul', location: 'Belfast'});
WorkerQueue.pushItem('PrintPeople', {name: 'John', location: 'Dublin'});
function MathPrint() {
var x = 10;
var y = 100;
var multiply = function(a, b) {
return a * b;
};
var printToConsole = function (text) {
console.log(text);
var Link = React.createClass({
getClassFromLinkType: function(linkType) {
switch(linkType) {
case 'github':
return 'fa fa-github-alt fa-3x';
case 'facebook':
return 'fa fa-facebook-square fa-3x';
case 'linkedin':
return 'fa fa-linkedin-square fa-3x';
case 'twitter':
@chrislaughlin
chrislaughlin / keybase.md
Created August 15, 2014 20:43
keybase.md

Keybase proof

I hereby claim:

  • I am chrislaughlin on github.
  • I am chrislaughlin (https://keybase.io/chrislaughlin) on keybase.
  • I have a public key whose fingerprint is 8273 5B59 B29C 81CC 6C2C C3E1 657B A750 B5B3 32D7

To claim this, I am signing this object:

@chrislaughlin
chrislaughlin / gist:a96b139c77119d256d6b
Last active August 29, 2015 14:05
function with callback
special: {
ready: {
// Make sure the ready event is setup
setup: jQuery.bindReady,
teardown: jQuery.noop
}
@chrislaughlin
chrislaughlin / gist:e04c2a34ee2a263745d5
Last active August 29, 2015 14:05
call back with noop
jQuery.fn.someAjaxStyleFunc = function(url, complete) {
return jQuery.ajax(url || this.url)
.complete(complete || jQuery.noop);
};
promiseFunction(inputData).then(function() {
});
//Can be changed to
promiseFunction(inputData).then($.noop());