Skip to content

Instantly share code, notes, and snippets.

View wegry's full-sized avatar

Zach Wegrzyniak wegry

  • Northeastern University
  • Boston
  • 02:10 (UTC -04:00)
View GitHub Profile
@wegry
wegry / rebuild_restart.sh
Created July 27, 2018 11:34
Rebuild and restart specific docker-compose containers without restarting docker-compose entirely
rebuild_restart () {
if [ -n "$1" ]
then
echo "Rebuilding and restarting $@"
docker-compose up --build --no-deps -d "$@"
else
echo "You need a container name (e.g. rebuild_restart my-container other-container)"
fi
}
let range: (int, int) => array(int) = [%bs.raw
(a, b) => {j|
const ranger = {};
ranger[Symbol.iterator] = function* () {
let current = a;
while (a <= b) {
yield a++;
}
}
@wegry
wegry / Tree.purs
Created June 10, 2018 18:48
Purescript binary tree codegen
module Main where
import Prelude
data Tree a = Empty | Leaf a | Node a (Tree a) (Tree a)
depthFirstTraversal x =
case x of
Empty -> []
Leaf a -> [a]
@wegry
wegry / Tree.bs.js
Last active June 10, 2018 17:50
Toy example of reason codegen
// Generated by BUCKLESCRIPT VERSION 2.2.3, PLEASE EDIT WITH CARE
import * as Block from "stdlib/block";
import * Belt_Array from "stdlib/belt_Array";
function depthFirstTraversal(param) {
if (typeof param === "number") {
return /* array */[];
} else if (param.tag) {
var match = param[0];
@wegry
wegry / Main.elm
Created May 24, 2018 19:30
Lucrative Hangman app
module Main exposing (..)
import Char
import Set
import Html exposing (Html, pre, text, div, h1, img, button, span)
import Html.Attributes exposing (src)
import Html.Events exposing (onClick)
---- MODEL ----
@wegry
wegry / PropTypes.bs.js
Last active May 15, 2018 06:56
Bucklescript FFI bindings with Reason for prop-types
import * as PropTypes from "prop-types";
var shape = PropTypes.default.shape();
var arrayOf = PropTypes.default.arrayOf();
var Internal = /* module */[
/* shape */shape,
@wegry
wegry / Generic.fsproj
Created April 25, 2018 12:39
Extract XLSX into JSON
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>
@wegry
wegry / import.re
Created February 28, 2018 10:34
ReasonML import of FFI module with a different name
[@bs.module "./i18n"]
external modelNameI18n: string =
"MODEL_NAME";
@wegry
wegry / JsonConfig.fs
Last active November 12, 2017 12:51
F# Enum Style Discriminated Unions serialized to strings with Json.NET for DUs with empty cases
// Fsharp 4.1.0
open System
open Newtonsoft.Json // 10.0.3
open Newtonsoft.Json.Converters
type ToStringJsonConverter () =
inherit JsonConverter()
override this.CanConvert objectType = true;
override this.WriteJson (writer: JsonWriter, value: obj, serializer: JsonSerializer): unit =
[format]
pretty = %Cblue%h%Creset %Cgreen[%ar]%Creset (%an) %s
[alias]
a = add
c = commit
co = checkout
d = diff
f = fetch
fmm = !git fetch origin master && git merge origin master