Skip to content

Instantly share code, notes, and snippets.

View getify's full-sized avatar
💭
Just coding

Kyle Simpson getify

💭
Just coding
View GitHub Profile
@raganwald
raganwald / fb.es6
Last active December 27, 2017 16:41
An elegant expression of the Fibonacci Sequence using generators https://en.wikipedia.org/wiki/Fibonacci_number
function * zipWith (zipper, ...iterables) {
const iterators = iterables.map(i => i[Symbol.iterator]());
while (true) {
const pairs = iterators.map(j => j.next()),
dones = pairs.map(p => p.done),
values = pairs.map(p => p.value);
if (dones.indexOf(true) >= 0) break;
yield zipper(...values);
@jonathantneal
jonathantneal / README.md
Last active March 19, 2024 23:31
Local SSL websites on macOS Sierra

Local SSL websites on macOS Sierra

These instructions will guide you through the process of setting up local, trusted websites on your own computer.

These instructions are intended to be used on macOS Sierra, but they have been known to work in El Capitan, Yosemite, Mavericks, and Mountain Lion.

NOTE: You may substitute the edit command for nano, vim, or whatever the editor of your choice is. Personally, I forward the edit command to Sublime Text:

alias edit="/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl"
@lygaret
lygaret / index.js
Last active January 18, 2023 17:26
ES6 Quasi-Literal for JSX
define(function(require) {
var React = require('react');
var paramRegex = /__(\d)+/;
var parser = new DOMParser();
var errorDoc = parser.parseFromString('INVALID', 'text/xml');
var errorNs = errorDoc.getElementsByTagName("parsererror")[0].namespaceURI;
// turns the array of string parts into a DOM
// throws if the result is an invalid XML document.
function foo(){}
foo.prototype = 2;
Object.defineProperty(foo,"prototype",{writable:false});
Object.getOwnPropertyDescriptor(foo,"prototype"); // Object {value: 2, writable: false, enumerable: false, configurable: false}
foo.prototype; // 2
function bar(){}
Object.defineProperty(bar,"prototype",{value:2,writable:false});
@smockle
smockle / grips.md
Last active August 29, 2015 14:01
The idea behind Grips is that HTML templating and CSS preprocessing can be pretty much the same. Very neat.

Here are some thoughts I had after reading through the slides and gist:

  1. I don't think I'd often use *prop. I don't keep track of which properties/values need vendor prefixes (or nonstandard code) to work with the browsers I'm targeting. I use Autoprefixer, which uses data from the Can I Use? database.
  2. A command that generates JSON with keys representing the variable names used in a .gcss file would be handy.
  3. I feel like I missed the point of storing style variables in JSON. One benefit is "different site themes"--but most of my projects include a "_variables.scss" file that could be swapped out--oh, but that would require recompiling scss. I see. I think I get it now. Never mind!
// bizarguments is a v8 anomaly
function abc() {
return def();
}
function def() {
return abc.arguments[0] * 2;
}
abc(50); // >> 100
@medikoo
medikoo / es6-shims.md
Last active March 24, 2021 22:29
List of ECMAScript 6 shims

List of ECMAScript 6 shims

Implemented on top of ECMAScript 5

Provided as distinct CJS modules, installable via npm


ECMAScript 5 Built-in Objects extensions

Individual modules of es5-ext package. See ES6 features for usage information.

Array

@rwaldron
rwaldron / array.build.md
Last active January 21, 2021 18:18
Array.build(length, mapFn = undefined)
@nzakas
nzakas / simplemap.js
Created April 3, 2014 17:38
A simple map implementation for JavaScript (not intended to be an ES6 polyfill)
function SimpleMap() {
this._data = {};
}
SimpleMap.prototype = {
get: function(key) {
return this.has(key) ? this._data[key] : null;
},
@WebReflection
WebReflection / Object.getOwnPropertyDescriptors.js
Created March 3, 2014 01:39
A plural ES5 + ES6 friendly version of Object.getOwnPropertyDescriptor
'getOwnPropertyDescriptors' in Object || (
Object.getOwnPropertyDescriptors = function (Object) {
var
gOPD = Object.getOwnPropertyDescriptor,
gOPN = Object.getOwnPropertyNames,
gOPS = Object.getOwnPropertySymbols,
gNS = gOPS ? function (object) {
return gOPN(object).concat(gOPS(object));
} :
gOPN,