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
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);
}
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....
<html>
<head>
<title>Canvas Test</title>
</head>
<body>
<canvas id='myGame'></canvas>
<script src='main.js'></script>
</body>
</html>
@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;
@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 / 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 / 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);
// these are the same
// as a function
var square = function (a){
return a * a;
}
// as a lamda function
var square = (a) => {
return a * a;
function player_status(health){
if (health == 100){
return "Full Health";
}
if (health > 10){
return "Injured";
}
// manage json objects to js form data
const formData = (obj) => {
let data = new FormData();
for (var key in obj){
if (!obj.hasOwnProperty(key)) { continue; }
let item = obj[key];