- GitHub Staff
- https://josh.black
- @josh.black
- @__joshblack
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
/** | |
* Write a function that generates a unique class name every time | |
* that it's called. The class name should follow the following | |
* pattern: | |
* | |
* fn(); // returns 'a' | |
* fn(); // returns 'b' | |
* ... | |
* fn(); // returns 'z' | |
* fn(); // returns 'aa' |
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
/** | |
* Write a function that returns a list of size n, | |
* containing random, distinct numbers using the | |
* function given below. | |
*/ | |
/** | |
* Generates a random number from 1 -> [ceil] | |
* | |
* @param {Number} ceil |
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
class Foo { | |
@log | |
bar(a, b) { | |
console.log(`Adding ${a} and ${b} gives us ${a + b}`); | |
} | |
} | |
function log(target, name, descriptor) { | |
let fn = descriptor.value; | |
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
# Don't forget that Makefiles need tabs not spaces! | |
BIN = "./node_modules/.bin" | |
patch: | |
$(call release,patch) | |
minor: | |
$(call release,minor) |
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'; | |
import Parser from './parser'; | |
import styles from './styles'; | |
Parser(styles); | |
// Output: | |
{ | |
h1: { |
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
// Given a certain object that represents a file system, create a function that | |
// returns the path to every file in the system. | |
// Assumptions: | |
// * All keys are valid paths with a trailing slash. | |
// * Values of keys can either be objects that represent folders, or they can be | |
// an array of files. | |
// * Every path terminates in an array containing a single file or multiple files. | |
var path = { | |
'/': { |
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
var assign = require('object-assign'); | |
// Get all the data nodes of an object | |
function flatten(obj) { | |
return Object.keys(obj).reduce(function (prev, key) { | |
return isObject(obj[key]) | |
? assign(prev, flatten(obj[key])) | |
: (prev[key] = obj[key], prev); |
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
var http = require('http'), | |
express = require('express'), | |
app = express(), | |
cookieParser = require('cookie-parser'), | |
httpProxy = require('http-proxy'); | |
var proxy = httpProxy.createProxyServer({}); | |
var proxyOptions = { | |
'host': 'http://127.0.0.1', |
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"; | |
const Schema = require('schema'); | |
const Migration = require('migration'); | |
// Migration builder | |
let CreateUsersTable = Object.create(Migration); | |
CreateUsersTable.prototype.up = function up() { |
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
el.addEventListener('click', function (e) { | |
e.target.style.display = 'none'; | |
}); | |
// Instead of using jQuery's $('selector') for grabbing an element, just use these | |
var elem = document.querySelector('selector'); // Returns a DOM Node | |
var elems = document.querySelectorAll('selector'); // Returns a nodelist | |
// Then for event listeners it's just: | |
elem.addEventListener('click', function (e) { |