This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* What about a HOC that has multiple mixins | |
* The HOC if flattened from mixins | |
* The WrappedComponent is still decoupled from HOC | |
* todo: test | |
*/ | |
function mixinHoc(WrappedComponent, mixins) { | |
mixins = [].concat(mixins) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
/* | |
* Javascript templating system | |
*/ | |
$(document).ready(function() { | |
function loadTemplate(element, path, callback, done) { | |
$.ajax(path).then(function(html) { | |
element.append(html); | |
if (typeof callback === 'function' ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http = require('http'); | |
let server = http.createServer(); | |
server.on('request', (request, response) => { | |
let {method, url, headers} = request; | |
console.log(`Received ${method} request for "${url}".`); | |
for (let headerName of Object.keys(headers)) { | |
let headerValue = headers[headerName]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// object | |
var Person = { | |
name: 'mr smith', | |
profession: 'dandy fella', | |
age: 10000 | |
} | |
// array of keys of Person | |
var properties = Object.keys(Person); | |
console.log(properties); // ['name', 'profession', 'age'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// test local and inherited properties of an object | |
var obj = { name: 'test' }; | |
console.log(obj.name); // 'test' | |
console.log(obj.hasOwnProperty('name')); // true | |
obj.__proto__.age = 10000; // hack to make age an inherited property | |
console.log(obj.age); // 10000 | |
console.log(obj.hasOwnProperty('age')); // false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// iteration using for..in loop and hasOwnProperty | |
var Person = { | |
name: 'mr smith', | |
profession: 'dandy fella', | |
age: 10000, | |
reset: function() { | |
for (var prop in this) { | |
if (prop == 'reset' || !this.hasOwnProperty(prop)) { | |
console.log("leave it alone", prop) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// based on http://stackoverflow.com/a/30882416/255239 | |
function XDate() { | |
// create new Date() with passed in args | |
var date = new (Function.prototype.bind.apply(Date, [Date].concat(Array.prototype.slice.call(arguments)))) | |
date.__proto__ = XDate.prototype; // make XDate.prototype the inherited prototype of our Date instance. | |
return date; | |
} | |
XDate.prototype.__proto__ = Date.prototype; // inherit Date prototype so we can use Date methods |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$filename = './Voters_for_SDC4CRetriever_Official-groupby-email.csv'; | |
$name = null; | |
$entry_fp = null; | |
$entry_arr = []; | |
$fp = fopen($filename, 'r'); | |
while (true) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# **fork repo via github UI** | |
# clone locally | |
git clone <repo-location> | |
# add a remote called "upstream" pointing to original repo location | |
git remote add upstream <repo-location> | |
# now you have two remotes, "origin" which is the forked repo and "upstream" which is the original |