Skip to content

Instantly share code, notes, and snippets.

View yadielar's full-sized avatar

Yadiel Arroyo yadielar

View GitHub Profile
const {useCallback, useEffect, useReducer, useRef} = require('react');
let effectCapture = null;
exports.useReducerWithEmitEffect = function(reducer, initialArg, init) {
let updateCounter = useRef(0);
let wrappedReducer = useCallback(function(oldWrappedState, action) {
effectCapture = [];
try {
let newState = reducer(oldWrappedState.state, action.action);
////////////////////////////////////////////////////////////////////////////////
// Create a directory called "pages" next to
// this file, put markdown files in there, and
// then run:
//
// ```
// $ node build.mjs
// ```
//
// Then deploy the "build" directory somewhere.
@yadielar
yadielar / example.jsx
Created August 22, 2018 15:35
Listen for Media Query changes with React & RxJS
import {Observable} from 'rxjs';
const mediaQueries = window.matchMedia('(min-width: 400px)');
const mediaQueryEvent = Observable.create((observer) => {
mediaQueries.addListener(e => observer.next(e));
}).share();
class MyComponent {
@yadielar
yadielar / gist:3900e7954d910dbff191
Created October 30, 2015 22:59 — forked from apinstein/gist:6858299
AngularJS: how to do Ember-style computed properties in angular
// do it live: http://jsfiddle.net/apinstein/2kR2c/1/
// in DOM
<div ng-controller="MyCtrl">
<p ng-click="bumpA()">a: {{a}}</p>
<p ng-click="bumpB()">b: {{b}}</p>
<p>a^2 = {{aSquared}}</p>
<p>a + b = {{aPlusB}}</p>
</div>
@yadielar
yadielar / music-db.md
Last active August 29, 2015 14:27
Personal Music Database

Personal Music Database

Classic Rock

  • The Beatles
  • Rolling Stones
  • The Who
  • The Doors
  • John Lennon
  • Bob Dylan
@yadielar
yadielar / node-reinstall-steps.md
Last active August 29, 2015 14:19
Reinstalling Node

Reinstalling Node

1. Install node-reinstall

$ git clone https://github.com/brock/node-reinstall.git
$ cp node-reinstall/node-reinstall.sh /usr/local/bin/node-reinstall

2. Run node-reinstall

@yadielar
yadielar / csslint-options.json
Created February 13, 2015 16:57
CSSLint Disable Cheatsheet
{
"important": false,
"adjoining-classes": false,
"known-properties": false,
"box-sizing": false,
"box-model": false,
"overqualified-elements": false,
"display-property-grouping": false,
"bulletproof-font-face": false,
"compatible-vendor-prefixes": false,