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 / memoization_ternary.js
Created March 4, 2014 20:46
Erik's Memoization Example with ternary operators
function addMe(num){
return num+num;
}
function memoMe(fn){
var objs = {};
return function(x){
return (objs[x]) ? objs[x] : (objs[x] = fn.apply(void 0, arguments), objs[x]);
};
}
@peterpme
peterpme / addme_memo.js
Created March 5, 2014 15:06
Javascript: Memoization with Simple Example using addMe function
// 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 / comb.js
Created March 5, 2014 21:30
Javascript: Partial Applications: A combinator that pulls in a function regardless of one or two variables and outputs the answer.
function power(x,y){
var tmp=x;
if (y<1){
return 1;
}
else{
for(var i=0;i<y-1;i++){
tmp=tmp*x;
}
return tmp;
@peterpme
peterpme / SassMeister-input-HTML.html
Created March 10, 2014 16:39
Generated by SassMeister.com.
<div class="container">
<h3>Normal List:</h3>
<ul>
<li>Home</li>
<li>About</li>
<li>Contact</li>
</ul>
<hr>
<h3>Inline List</h3>
<ul class="inline-list">
@peterpme
peterpme / SassMeister-input-HTML.html
Created March 10, 2014 16:42
Generated by SassMeister.com.
<div class="container">Scroll Down (I'm relative)
<div class="absolute">
absolute
</div>
<div class="rel2">So am i</div>
<div class="fixed">fixed</div>
</div>
@peterpme
peterpme / wrap.js
Last active August 29, 2015 13:57
CodeWars Wrap Function
function speak(name){
return "Hello " + name;
}
Function.prototype.wrap = function(fn){
var that = this;
console.log(that);
return function(arg2,arg3){
return fn(that,arg2,arg3);
};
@peterpme
peterpme / SassMeister-input-HTML.html
Created March 12, 2014 23:24
Generated by SassMeister.com.
<div class="green content--search">
<section class="content">
<form action="template-search-results.html" method="post" tabindex="-1">
<div class="dropdown-wrapper">
<input class="" placeholder="Name / Keyword">
<div class="js-industry form--item"><span>Industry</span></div>
<div class="js-practice form--item"><span>Practice</span></div>
<div class="js-newstype form--item"><span>News Type</span></div>
</div>
</form>
@peterpme
peterpme / SassMeister-input-HTML.html
Created March 13, 2014 13:56
Generated by SassMeister.com.
<div class="green content--search">
<section class="content">
<form action="template-search-results.html" method="post" tabindex="-1">
<div class="dropdown-wrapper">
<input class="" placeholder="Name / Keyword">
<div class="js-industry form--item"><span>Industry</span></div>
<div class="js-practice form--item"><span>Practice</span></div>
<div class="js-newstype form--item"><span>News Type</span></div>
</div>
</form>
@peterpme
peterpme / this.js
Created March 13, 2014 14:16
Javascript: This example and Inheritance.
function Obj(name) {
var that = this;
this.name = name || "world";
return {
name : "Peter",
greet1 : function (arg1) {
return arg1 + this.name;
},
greet2 : function (arg1) {
@peterpme
peterpme / mathfun.js
Created March 20, 2014 15:42
Javascript: Calculate Math using numbers as functions. e.g.: five(plus(three())) => 8
function plus(x){
return function(y){
return y+x;
};
}
function minus(x){
return function(y){
return y-x;
};