Skip to content

Instantly share code, notes, and snippets.

View shinzui's full-sized avatar
👨‍💻

Nadeem Bitar shinzui

👨‍💻
  • Los Angeles / San Francisco
  • X @shinzui
View GitHub Profile
@shinzui
shinzui / resolvePromise.js
Created September 24, 2016 18:13 — forked from mjackson/resolvePromise.js
An easy way to do async APIs in JavaScript that support both promises *and* callbacks!
// Here is a function that I use all the time when creating public
// async APIs in JavaScript:
const resolvePromise = (promise, callback) => {
if (callback)
promise.then(value => callback(null, value), callback)
return promise
}
// Sometimes I like to use callbacks, but other times a promise is
@shinzui
shinzui / LazilyLoad.js
Created September 6, 2016 15:44 — forked from iammerrick/LazilyLoad.js
Lazily Load Code Declaratively in React + Webpack
import React from 'react';
const toPromise = (load) => (new Promise((resolve) => (
load(resolve)
)));
class LazilyLoad extends React.Component {
constructor() {
super(...arguments);
import * as Ensure from '../../../../utils/lib/Ensure'
import markdownBlockDelimiter from './markdownBlockDelimiter'
import {BlockTypes, BlockTypeRegExps} from './Types'
import {
CharacterMetadata,
ContentState,
ContentBlock,
EditorState,
genKey,
} from 'draft-js'
#!/usr/bin/env python
# This is a trick, to output the bash commands we need to run in shell, and just execute this script inside an eval within our shell, so it imports what we need
# Possibly tie this in with https://gist.github.com/mbainter/b38a4cb411c0b5c1bae6 for MFA support
# Will need to durably store MFA access tokens, possibly in some other env vars
# Could also store all different keys/info in different vars, to reuse as needed (lots of env vars though, file may be better)
import os
import sys
import getpass
if (
process.env.NODE_ENV === 'production' &&
window.__REACT_DEVTOOLS_GLOBAL_HOOK__ &&
Object.keys(window.__REACT_DEVTOOLS_GLOBAL_HOOK__._renderers).length
) {
window.__REACT_DEVTOOLS_GLOBAL_HOOK__._renderers = {}
}
/**
* Required Variables.
*/
variable "name" {}
variable "port" {}
variable "elb_security_group" {}
variable "elb_subnets" {}
@shinzui
shinzui / postgres-upgrade-recipe.sh
Created January 21, 2016 19:14 — forked from eoinkelly/postgres-upgrade-recipe.sh
Upgrade Postgres to 9.4 using Homebrew on Mac OSX
#!/bin/bash
# This script can be used in "run & hope" mode or you can use it as a recipe to
# do things manually - you probably want the latter if you really care about
# the data in your databases.
# Happy hacking
# /Eoin/
# Tell bash to stop if something goes wrong
set -e
@shinzui
shinzui / FP_Observables.js
Created January 19, 2016 21:20 — forked from yelouafi/FP_Observables.js
Observables with pure FP
// Observable is an Union Type, with the following variants
const Empty = () => ['EMPTY']
const Cons = (head, tail) => ['CONS', head, tail]
const Future = promise => ['FUTURE', promise]
// race between 2 promises; each promise will resolve to a lazy value
const lazyRace = (p1, p2) => Promise.race([p1,p2]).then(lazy => lazy())
// function composition
const compose = (...fns) => (arg) => fns.reduceRight((res, f) => f(res), arg)
@shinzui
shinzui / README.md
Created January 14, 2016 17:36 — forked from Dr-Nikson/README.md
Auth example (react + redux + react-router)
@shinzui
shinzui / fix_postgres.bash
Created November 13, 2015 19:01
Fixing psql autocomplete on OS X
brew install readline
brew link --force readline
brew unlink postgresql
brew install postgreql
#should include readline
otool -L `which psql`