Skip to content

Instantly share code, notes, and snippets.

View hserang's full-sized avatar

Haroun Serang hserang

View GitHub Profile

Dane's Meal Plan

Target: 1850cal Carbs 162g Fats 51g Protein 185g

I follow this plan every day. It's based around a 5-6:30pm workout.

Cheat days address two things, eating things you like and getting a variety of

@hserang
hserang / simple-co.js
Created February 3, 2016 17:34 — forked from clark800/simple-co.js
simplified co
'use strict';
function isGenerator(obj) {
return typeof obj.next === 'function' && typeof obj.throw === 'function';
}
// co returns a promise that resolves to the return value of the generator arg
function co(generator) {
return new Promise(resolve => {
function next(result) {
// Node.js CheatSheet.
// Download the Node.js source code or a pre-built installer for your platform, and start developing today.
// Download: http://nodejs.org/download/
// More: http://nodejs.org/api/all.html
// 0. Synopsis.
// http://nodejs.org/api/synopsis.html

If you've reached this page, it's probably because your "parent-based and owner-based contexts differ".

As we've been iterating on React's "context" feature, we've discovered that the parent-based relationship is more useful than the owner-based relationship, so we're migrating to use a parent-based hierarchy.

In short, the owner of a component is whomever creates the component, while the parent of a component is whomever would be the containing ancestor in the DOM hierarchy. To learn more about the owner relationship, see the docs here: http://facebook.github.io/react/docs/multiple-components.html

In many cases, the owner and the parent are the same node, in which case, no further action is necessary. However, if your owner and your parent differ, you should ensure that the context variables you're using aren't going to break when we switch from owner-based contexts to parent-based contexts. If you're seeing the warning, your component may not be ready for the switch.

NOTE: semantically-equal context var

@hserang
hserang / 0_reuse_code.js
Last active August 29, 2015 14:21
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@hserang
hserang / errors.js
Last active August 29, 2015 14:20 — forked from gr0uch/errors.js
// TypedError class which other typed errors subclass from.
class TypedError extends Error {
constructor (message) {
super();
if (Error.hasOwnProperty('captureStackTrace'))
Error.captureStackTrace(this, this.constructor);
else
Object.defineProperty(this, 'stack', {
'use strict';
module.exports = function CustomError(message, extra) {
Error.captureStackTrace(this, this.constructor);
this.name = this.constructor.name;
this.message = message;
this.extra = extra;
};
require('util').inherits(module.exports, Error);