Skip to content

Instantly share code, notes, and snippets.

View alexmcpherson's full-sized avatar

Alex McPherson alexmcpherson

  • Colorado
View GitHub Profile
@alexmcpherson
alexmcpherson / pr.md
Created October 28, 2014 20:17
PR template explanation

What's this PR do?

This is to get the reviewer in the mood, to understand what part of the app is being touched here

EX: "This PR allows users to upload profile images. It includes S3 code, a worker job for generating thumbnails off-of-web-thread, and tests"

Where should the reviewer start?

This is the most likely file diff to start with, and points you down a road for further investigation of the code living behind the feature.

@alexmcpherson
alexmcpherson / markov.js
Created September 25, 2014 18:15
markov
var util = require('util');
function Markov(){
this.chain = {};
};
Markov.prototype = {
digest: function(corpus) {
var currentWord, words = corpus.split(/\s+/);
@alexmcpherson
alexmcpherson / code-1.js
Last active August 29, 2015 14:04
polymer-presentation
//spoiler: I just copy this from view to view. Bad ergonomics.
attachIncrementors: function() {
var incrementor = new IncrementorView({
attrName : 'difference',
model: this.model.dishwashing_model,
options: Helpers.range(0, 100),
template: JST['components/load_incrementor']
});
@alexmcpherson
alexmcpherson / main.js
Created June 4, 2014 22:53
Scrolling speed effect
var last = 0
var offsets = []
$('#content').css('transition', 'all .1s')
$(window).scroll(function(){
offsets.push(Math.abs(window.scrollY - last))
last = window.scrollY
})
setInterval(function() {
var total = 0
@alexmcpherson
alexmcpherson / main.js
Last active August 29, 2015 13:56
Raw XHR Sample
//executed from api.jquery.com
function reqListener () {
console.log(this.responseText);
}
var oReq = new XMLHttpRequest();
oReq.onload = reqListener;
oReq.open("get", "http://api.jquery.com/robots.txt", true);
oReq.send();
@alexmcpherson
alexmcpherson / main.js
Created February 25, 2014 05:39
Functional scope in javascript
function scopeTest() {
var myVariable = 'Alex'; //var is important, declares it in this scope
console.log(myVariable);
}
scopeTest();
typeof myVariable === "undefined";
@alexmcpherson
alexmcpherson / constructor_scope.js
Created February 25, 2014 05:34
Prototype sample code
function Person(name) {
this.name = name;
}
Person.prototype.whoAmI = function() {
console.log(this.name);
}
var alex = new Person('alex');
@alexmcpherson
alexmcpherson / output
Created February 25, 2014 00:32
Ping main.css properties count
323 content:
295 background-color:
256 color:
235 margin-left:
222 width:
184 display:
177 background-image:
153 background-position:
115 line-height:
100 padding:
@alexmcpherson
alexmcpherson / main.css
Last active August 29, 2015 13:56
Occurrences of properties on the Quickleft.com style sheet
298 color:
293 display:
205 width:
170 background-color:
129 margin-left:
127 padding:
119 font-size:
117 position:
117 height:
114 left:
@alexmcpherson
alexmcpherson / index.html
Last active August 29, 2015 13:56
More advanced selectors
<html>
<head></head>
<body>
<div>
<span>Bold!</span>
<span>Not bold...</span>
</div>
<ul>