Skip to content

Instantly share code, notes, and snippets.

View sslotsky's full-sized avatar
🌶️
Working from home

Sam Slotsky sslotsky

🌶️
Working from home
View GitHub Profile
import React from "react";
function Counter({ n, inc, dec }) {
return (
<Container>
<Content>{n}</Content>
<Buttons>
<button onClick={dec}>-</button>
<button onClick={inc}>+</button>
</Buttons>
import React from "react";
import { initialize, split } from "apothecary";
import { Bridge, tunnel, fromProps } from "react-apothecary";
import { Container, Buttons, Content } from "./styles";
const store = initialize({ n: 1 });
const increment = step => split(n => n + step, "n");
const decrement = step => split(n => n - step, "n");
extern crate serde_json;
fn main() {
println!("Hello, world!");
}
#[macro_use]
extern crate serde_derive;
extern crate serde;
extern crate serde_json;
use std::os::raw::{c_char};
use std::ffi::CString;
(function() {
function copyCStr(module, ptr) {
let orig_ptr = ptr;
const collectCString = function* () {
let memory = new Uint8Array(module.memory.buffer);
while (memory[ptr] !== 0) {
if (memory[ptr] === undefined) { throw new Error("Tried to read undef mem") }
yield memory[ptr]
ptr += 1
}
function flatten(list = []) {
const [head, ...tail] = list;
if (!head) {
return [];
}
if (Array.isArray(head)) {
return flatten(head).concat(flatten(tail));
}
type parcelModule;
type hot;
[@bs.val] external parcelModule : parcelModule = "module";
[@bs.get] external hot : parcelModule => Js.nullable(hot) = "hot";
[@bs.send.pipe : hot] external accept : unit => unit = "accept";
{
"name": "sparcely-unreasonable",
"version": "0.1.0",
"sources": {
"dir": "src",
"subdirs": true
},
"bs-dependencies": ["reason-react"],
"reason": {
"react-jsx": 2
let component = ReasonReact.statelessComponent("App");
let make = (_) => {
...component,
render: _ => <h1> (ReasonReact.string("Hello Worldy")) </h1>
}
ReactDOMRe.renderToElementWithId(<App />, "root");
type parcelModule;
type hot;
[@bs.val] external parcelModule : parcelModule = "module";
[@bs.get] external hot : parcelModule => Js.nullable(hot) = "hot";
[@bs.send.pipe : hot] external accept : unit => unit = "accept";
switch (Js.Nullable.toOption(parcelModule |> hot)) {
| Some(h) => h |> accept()