Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

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

Peter Piekarczyk peterpme

🏠
Working from home
View GitHub Profile
@peterpme
peterpme / SassMeister-input-HTML.html
Created February 25, 2014 22:03
Generated by SassMeister.com.
<button class="one">Click Here For More!</button>
<button class="two">Click Here For More!!</button>
@peterpme
peterpme / composition.js
Last active August 29, 2015 13:56
Javascript: Composition Example
// Javascript Composition
function compose(a,b){
return function(c){
return a(b(c));
};
}
function addIt(num) {
return num + num;
}
@peterpme
peterpme / currying.js
Created March 2, 2014 22:15
Javascript: Currying Example
//Javascript Currying
function boxes(a){
return function(b) {
return "I like " + a + " " + b;
};
}
var myboxes = boxes("my boxes");
var yourboxes = boxes("your boxes");
console.log("my boxes:");
@peterpme
peterpme / decorator.js
Last active August 29, 2015 13:56
Javascript: Function Decorator
// Function Decorator:
// Takes one function as an argument, returns another function. The returned function is a variation of the argument function.
function not (fn) {
return function (argument) {
return !fn(argument);
};
}
@peterpme
peterpme / partialapplication_squared.js
Created March 3, 2014 20:47
Partial Application using Map
// Partial Application using Map and passing in a function
var oldArray = [1,4,9,16,25];
console.log(oldArray);
var newArray = oldArray.map(
function(n){
return n*n;}
);
console.log(newArray);
@peterpme
peterpme / experiments.js
Created March 3, 2014 20:52
Recent Work with Javascript Experiments
console.log("========================");
//Closures
(function(x) {
return function(y) {
return function(z) {
console.log("x "+x);
console.log("y "+y);
console.log("z "+z);
console.log(x + y + 3);
return x + y + z;
@peterpme
peterpme / jsbin.ragefore.js
Last active August 29, 2015 13:56
Messing around with .map and .splice
var imgLoader = {
config: {
container: '.imgContainer',
images : '#images',
imageLoadBtn: '.loadImages',
defaultSplice:4,
url : 'http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?'
},
imgData: [],
@peterpme
peterpme / arraypushpop.js
Created March 4, 2014 17:06
Javascript: Array Push / Pop
//Array push / pop
var oneSet = [1,2,3,4];
var twoSet = [5,6,7,8];
var j=twoSet.length;
for (var i=0;i<j;i++){
oneSet.push(twoSet[i]);
console.log(oneSet);
console.log(twoSet[i]);
}
@peterpme
peterpme / memoization.js
Last active August 29, 2015 13:57
Javascript: Memoization Example
// Simple Memoization - could use some work
function addMe(num){
return num+num;
}
function memoMe(fn){
var objs = {};
return function(x){
if(x in objs)
{
@peterpme
peterpme / memoization2.js
Last active August 29, 2015 13:57
Javascript: Memoization - passing in the function instead of setting objs[x] equal to the arguments.
// Simple Memoization - could use some work
function addMe(num){
return num+num;
}
function memoMe(fn){
var objs = {};
return function(x){
if(x in objs)
{