Skip to content

Instantly share code, notes, and snippets.

@chrislaughlin
chrislaughlin / functionScope.js
Created January 2, 2017 22:11
function scope
for (var i = 0; i < 5; i++) {
setTimeout(function () {
console.log(i);
}, 1000);
}
@chrislaughlin
chrislaughlin / functionScopeEs6.js
Created January 2, 2017 22:15
functionScopeES6
for (var i = 0; i < 5; i++) {
setTimeout(console.log.bind(this, i), 1000);
}
@chrislaughlin
chrislaughlin / objectEquality.js
Created January 2, 2017 22:28
Object Equality
const chris1 = {
name: 'Chris',
location: 'Belfast'
}
const chris2 = {
name: 'Chris',
location: 'Belfast'
}
@chrislaughlin
chrislaughlin / objectEqualityAssignment.js
Created January 2, 2017 22:38
objectEqualityAssignment
const chris1 = {
name: 'Chris',
location: 'Belfast'
}
const chris2 = {
name: 'Chris',
location: 'Belfast'
}
@chrislaughlin
chrislaughlin / stringReplace.js
Created January 2, 2017 22:54
String Replace
const myString = "This string has many spaces";
console.log(myString.replace(/ /,""));
//"Thisstring has many spaces"
console.log(myString.replace(/ /g,""));
//"Thisstringhasmanyspaces"
@chrislaughlin
chrislaughlin / nyan.js
Created June 6, 2017 20:30
Nyan Cat Console
//define colors
var c = {
db: "#036", //darkblue
bk: "#000", //black
rd: "#F00", //red
tn: "#FC9", //tan
lp: "#F9F", //lightpink
dp: "#F39", //darkpink
og: "#F90", //orange
const people = [{
"id": 1,
"first_name": "Katleen",
"last_name": "Josefs",
"email": "[email protected]",
"gender": "Female",
"ip_address": "68.36.229.0"
}, {
"id": 2,
"first_name": "Cletus",
@chrislaughlin
chrislaughlin / rotate.js
Created June 6, 2017 21:09
Rotate Images
$('img').css('transform', 'rotate(90deg)');
http://thedyslexicdeveloper.com/#/?_k=tj9n2a
http://pongtest.christopherlaughlin.co.uk/
http://zgrossbart.github.io/jsprofarticle/index1.htm
@chrislaughlin
chrislaughlin / travis.md
Created March 31, 2018 16:20
Using Travis CI with Gatsby

First set out your build scripts In your package.json scripts and install the gh-pages npm module

"build": "gatsby build",
"test": "echo \"no test specified\" && exit 0",
"preDeploy": "gatsby build --prefix-paths",
"deploy": "npm run preDeploy && gh-pages -d public"

Connect Travis CI to your repo and in the repo settings add an enviroment var call GITHUB_TOKEN with the value of your github token from: