Skip to content

Instantly share code, notes, and snippets.

Avatar
🤩
Everything is a hack on top of a hack

David Sancho davesnx

🤩
Everything is a hack on top of a hack
View GitHub Profile
@davesnx
davesnx / AST 4.10.re
Last active Sep 26, 2020
OCaml Migrate Parsetree 4.10 translated to Reason
View AST 4.10.re
/*************************************************************************/
/* */
/* OCaml Migrate Parsetree transformed to Reason */
/* */
/* Frédéric Bour, Facebook */
/* Jérémie Dimino and Leo White, Jane Street Europe */
/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
/* Alain Frisch, LexiFi */
/* Daniel de Rauglaudre, projet Cristal, INRIA Rocquencourt */
/* */
View AstHelpers.re
open Ast;
open Meta;
open Ppxlib;
open Ast_helper;
module T = {
let constructor = (~loc, ~args: option(list(core_type))=?, x) =>
Type.constructor(
~args=?
View ReactDOMRe.re
/* First time reading an OCaml/Reason/BuckleScript file? */
/* `external` is the foreign function call in OCaml. */
/* here we're saying `I guarantee that on the JS side, we have a `render` function in the module "react-dom"
that takes in a reactElement, a dom element, and returns unit (nothing) */
/* It's like `let`, except you're pointing the implementation to the JS side. The compiler will inline these
calls and add the appropriate `require("react-dom")` in the file calling this `render` */
[@bs.val] [@bs.module "react-dom"]
external render: (React.element, Dom.element) => unit = "render";
[@bs.val]
@davesnx
davesnx / React-Native-Shadow-Generator.js
Created Mar 11, 2020
Unify Android and iOS elevations
View React-Native-Shadow-Generator.js
const range = document.getElementById("depth")
, amount = document.getElementById("amount")
, code = document.getElementById("code")
, previewAndroid = document.getElementById("previewAndroid")
, previewIos = document.getElementById("previewIos");
const elevation = document.getElementById("elevation")
, height = document.getElementById("height")
, opacity = document.getElementById("opacity")
, radius = document.getElementById("radius");
@davesnx
davesnx / index.js
Last active Dec 20, 2019
Draft history hook
View index.js
const useHistory = initialValue => {
const [history, setHistory] = useState({ values: [initialValue], pointer: 0 })
const setHistoryPointer = pointer => {
if (pointer >= 0) {
setHistory({ ...history, pointer: pointer })
}
}
return [
@davesnx
davesnx / index.js
Created Jul 23, 2016
Basic compose explained
View index.js
// [IGNORE THIS]
// Clean the console on node(with strict mode!)
console.clear = () => {
process.stdout.write('\x1B[2J\x1B[0f')
}
console.clear()
// [IGNORE THIS]
// Simpler expect method