Skip to content

Instantly share code, notes, and snippets.

@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:

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':
function MathPrint() {
var x = 10;
var y = 100;
var multiply = function(a, b) {
return a * b;
};
var printToConsole = function (text) {
console.log(text);
@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'});
@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
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 / 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++) {
@chrislaughlin
chrislaughlin / LoopPref
Created June 29, 2014 18:29
Loop Performance
var array = [];
for (var i = 0; i < 100; i++) {
array.push(i);
}
console.time('loop ++i');
for(var i = 0; i < array.length; ++i) {
var a = array[i];
}
console.timeEnd('loop ++i');
describe('Login', function() {
beforeEach(function() {
// Browse to index page
browser.get('/');
});
it('should provide login button', function() {
expect(element('a[href="#/login"]').getText()).toEqual("Login");
})
@chrislaughlin
chrislaughlin / gist:8751213
Created February 1, 2014 11:45
Using Object Create
var map = Object.create(null);
var key = 'toString';
map[key] == undefined; //outputs true as expected