Skip to content

Instantly share code, notes, and snippets.

View SanderSpies's full-sized avatar
🐫
wasm

Sander SanderSpies

🐫
wasm
View GitHub Profile
@SanderSpies
SanderSpies / gist:b3218e861e12ed6477eb
Created April 2, 2015 15:03
React Style Syntax with media query example
var ApplicationStyles = StyleSheet.create`
.normalStyle {
background-color: white;
font-size: 10pt;
padding: 1em;
margin: 10px;
}
.childStyle {
open ReactDOM
module MyComponent = struct
(* Component Properties *)
type props = {count: int}
(* Hey, state can be any type! *)
type state = string
(* Initializer *)
let context = createGlobalContext null in
let script = createStringWithUTF8CString "(function(){return 'Hi OCaml, this is your friend JavaScriptCore.';})();" in
let valueref = evaluateScript context script null null 0 null in
let result = valueToString context valueref null in
let ocaml_str = toOCamlString result in (
print_string ocaml_str;
releaseString script;
releaseGlobalContext context;
releaseOCamlString ocaml_str);;
@SanderSpies
SanderSpies / Example.js
Last active March 30, 2016 07:26
React pattern matching braindumb
const test = (props) => (
<div>
{match(props).with(
(String) => <div>Should work {props}</div>,
({bar = '1', test: {x = false}}) => <div>Super cool {bar}</div>,
({bar = '5', test: {y = true}}) => <div>Mega cool {test.y} {y}</div>,
([a = 3, {x = 4}, z]) =>
<nesting>
{match(z).with(
({bar = '5', test: {y = true}}) =>