Skip to content

Instantly share code, notes, and snippets.

View philpoore's full-sized avatar
🏠
Working from home

Phil Poore philpoore

🏠
Working from home
View GitHub Profile
// these are the same
// as a function
var square = function (a){
return a * a;
}
// as a lamda function
var square = (a) => {
return a * a;
@philpoore
philpoore / a.js
Last active March 18, 2016 09:37 — forked from anonymous/a.js
function Animal(name, numLegs) {
this.name = name;
this.numLegs = numLegs;
};
Animal.prototype.sayName = function() {
console.log('Hi my name is ' + this.name);
};
var penguin = new Animal("Captain Cook", 2);
@philpoore
philpoore / 123.js
Last active March 5, 2016 22:06 — forked from anonymous/123.js
function list() {
contacts.map(printPerson);
};
list();
Inside of the loop, add code to call printPerson, passing in the element of the array that the loop is currently at.
At the very bottom of the file, call the list function. The list function should then loop through every member of the contacts array and print its information.
@philpoore
philpoore / delayPromise.js
Last active January 17, 2016 18:22
Javascript Delay Promise with Arguments
// Delay a JS Promise by a number
// of miliseconds. Preserves arguments.
const delayPromise = (duration) => {
return (...args) => {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve(...args);
}, duration);
});
};
@philpoore
philpoore / index.js
Created December 7, 2015 09:06 — forked from chrisbuttery/index.js
Control the flow of asynchronous calls with ES6 generator functions
/**
* get - XHR Request
*/
let get = function (url) {
return function (callback) {
let xhr = new XMLHttpRequest();
xhr.open('GET', url);
xhr.onreadystatechange = function() {
let response = xhr.responseText;
<html>
<head>
<title>Canvas Test</title>
</head>
<body>
<canvas id='myGame'></canvas>
<script src='main.js'></script>
</body>
</html>
XSS Example
===========
Okay so an example of one way that websites can be insecure is XSS.
By all means read more on wiki.
XSS == Cross Site Scripting
It works like this....
Examples of loops in diffrent languages
Each example prints the numbers 0 --> 9 inclusive.
// Javascript
for (var i = 0; i < 10; i += 1){
console.log(i);
}
@philpoore
philpoore / gist:e018a3cb5b683b64988e
Last active August 29, 2015 14:20
Update Mongo 2.4 to 2.6
#!/bin/bash
service mongod stop
echo > /etc/yum.repos.d/mongodb-org-2.6.repo
echo "[mongodb-org-2.6]" >> /etc/yum.repos.d/mongodb-org-2.6.repo
echo "name=MongoDB 2.6 Repository" >> /etc/yum.repos.d/mongodb-org-2.6.repo
echo "baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/" >> /etc/yum.repos.d/mongodb-org-2.6.repo
@philpoore
philpoore / Dockerfile
Last active August 29, 2015 14:20
Dockerfile - nodejs
FROM node:0.10
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package.json /usr/src/app/
RUN npm install
COPY . /usr/src/app