Skip to content

Instantly share code, notes, and snippets.

Avatar
👨‍💻

Nadeem Bitar shinzui

👨‍💻
  • Los Angeles / San Francisco
  • Twitter @shinzui
View GitHub Profile
View test.csv
propertyId agentId
1 123
2 333
@shinzui
shinzui / RecursiveGQLTypes.re
Created Oct 12, 2018 — forked from kgoggin/RecursiveGQLTypes.re
This gist shows how you could go about defining ReasonML types based on a GraphQL schema that reference each other, as well as a recursive decoder function used to parse a JSON response into the correct type.
View RecursiveGQLTypes.re
/* Use Reason's ability to define recursive types with the `and` keyword */
type movie = {
id: option(string),
name: option(string),
rating: option(Js.null(string)),
runTime: option(Js.null(int)),
actors: option(list(actor)),
}
and actor = {
id: option(string),
@shinzui
shinzui / App.re
Created Sep 8, 2018 — forked from jaredly/App.re
ReasonReact Context API Example
View App.re
module StringContext =
Context.MakePair({
type t = string;
let defaultValue = "Awesome";
});
let component = ReasonReact.statelessComponent("Tree");
let make = _children => {
View Dockerfile
FROM ocaml/opam2:alpine-3.7-ocaml-4.06
RUN sudo apk --no-cache add ca-certificates
RUN sudo apk add --update m4 openssh-client
# Setup SSH.
RUN mkdir -p ~/.ssh
ARG SSH_PRIVATE_KEY
RUN echo "${SSH_PRIVATE_KEY}" > ~/.ssh/id_rsa
RUN chmod 600 ~/.ssh/id_rsa
RUN printf "Host github.com\n\tStrictHostKeyChecking no\n" > ~/.ssh/config
@shinzui
shinzui / config
Created Aug 23, 2018 — forked from Khady/config
Opam configuration for both sandbox and compilation cache
View config
pre-install-commands:
["opam-bin-cache.sh" "restore" build-id name] {?build-id}
wrap-build-commands: [
["opam-bin-cache.sh" "wrap" build-id] {?build-id}
["%{hooks}%/sandbox.sh" "build"] {os = "linux"}
]
wrap-install-commands: [
["opam-bin-cache.sh" "wrap" build-id] {?build-id}
["%{hooks}%/sandbox.sh" "install"] {os = "linux"}
]
@shinzui
shinzui / combinators.js
Created Mar 3, 2018 — forked from Avaq/combinators.js
Common combinators in JavaScript
View combinators.js
const I = x => x;
const K = x => y => x;
const A = f => x => f(x);
const T = x => f => f(x);
const W = f => x => f(x)(x);
const C = f => y => x => f(x)(y);
const B = f => g => x => f(g(x));
const S = f => g => x => f(x)(g(x));
const P = f => g => x => y => f(g(x))(g(y));
const Y = f => (g => g(g))(g => f(x => g(g)(x)));
@shinzui
shinzui / resolvePromise.js
Created Sep 24, 2016 — forked from mjackson/resolvePromise.js
An easy way to do async APIs in JavaScript that support both promises *and* callbacks!
View resolvePromise.js
// 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 Sep 6, 2016 — forked from iammerrick/LazilyLoad.js
Lazily Load Code Declaratively in React + Webpack
View LazilyLoad.js
import React from 'react';
const toPromise = (load) => (new Promise((resolve) => (
load(resolve)
)));
class LazilyLoad extends React.Component {
constructor() {
super(...arguments);
View convertMarkdownToEditorState.es
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'
View assume_role.py
#!/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