Skip to content

Instantly share code, notes, and snippets.

Avatar

Erik Terpstra eterps

View GitHub Profile
@eterps
eterps / optiontest.gleam.rs
Last active May 21, 2020
Testing the Option type in Gleam
View optiontest.gleam.rs
import gleam/list
import gleam/result
import gleam/string
type PersonalName {
PersonalName(
first_name: String,
middle_initial: result.Option(String),
last_name: String,
)
@eterps
eterps / reasonml
Created Jan 16, 2020
Run a ReasonML file
View reasonml
#!/bin/bash
set -e
realpath() {
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
}
SRC=$(realpath "$1")
if ! [ -e bsconfig.json ]; then
@eterps
eterps / instructions.sh
Last active Dec 29, 2019
Attempt to deploy something simple to zeit.co
View instructions.sh
mkdir rubytest
cd rubytest
mkdir api
cat <<END >api/index.rb
require 'cowsay'
Handler = Proc.new do |req, res|
res.status = 200
res['Content-Type'] = 'text/plain'
@eterps
eterps / app.js
Created Jul 19, 2019 — forked from dergachev/app.js
Manual JS prettification of enterprisewiki.co. See http://news.ycombinator.com/item?id=4933049
View app.js
// https://github.com/EightMedia/hammer.js/blob/master/hammer.js
function toId(t) {
return t.toLowerCase().replace(/[^a-z]/gi, "-").replace(/-+/gi, "-")
}
function toc() {
var t = $("#sidebar").html("");
$("h1,h2,h3").each(function() {
var e = $(this).clone(), n = $(this).offset().top;
"#" != e.html() && (e.is("h3") && e.html("&dash; " + e.html()), t.append(e), e.on("click", function() {
$("body").animate({scrollTop: n}, 200)
View do_sequentially.nim
# Currently doesn't work
import macros
macro do_sequentially(idx: int, statements: varargs[untyped]): untyped =
result = nnkStmtList.newTree()
do_sequentially(1):
do: echo "Foo"
do: echo "Bar"
View oberon0_fragment.ohm
Oberon0 {
Module = "MODULE" ident ";" "BEGIN" StatSeq "END" ident "."
StatSeq = statement (";" statement)*
statement = procedureCall?
procedureCall = ident (actualParameters | "*")?
actualParameters = "(" integer ("," integer)* ")"
integer = digit+
ident = letter alnum*
}
View io.mod
MODULE IO; (*for Oberon0 NW 29.4.2017*)
IMPORT Texts,Oberon;
VAR S: Texts.Scanner; W: Texts.Writer;
PROCEDURE OpenInput*;
BEGIN Texts.OpenScanner(S, Oberon.Par.text, Oberon.Par.pos); Texts.Scan(S)
END OpenInput;
PROCEDURE ReadInt*(VAR x: LONGINT);
BEGIN x := S.i; Texts.Scan(S)
@eterps
eterps / reasoneq.re
Created Apr 19, 2019
ReasonML equality
View reasoneq.re
type customerId =
| CustomerId(int);
type orderId =
| OrderId(int);
let cid = CustomerId(42);
let oid = OrderId(42);
cid == oid;
View Samsung Smart-TV Blocklist Adlist (for PiHole)
# This is a blocklist to block samsung smart tv's sending meta data at home.
# Please help to collect domains!
# It could be that the TV does not receive any more updates or other services no longer work. Please report such an incident.
# https://gist.github.com/Perflyst/315f86393712a0c2107ee8eb58c6acee
0.0.0.0 device-metrics-us.amazon.com
0.0.0.0 samsungacr.com
0.0.0.0 samsungcloudsolution.com
0.0.0.0 samsungcloudsolution.net
0.0.0.0 pavv.co.kr
@eterps
eterps / setup_sway
Created Dec 7, 2018
Install Sway (a tiling Wayland compositor) on Ubuntu
View setup_sway
#!/bin/bash
set -e
# Based on: https://gist.github.com/concatime/265fa14d260f3aa237ddf991d58dd639
mkdir /tmp/setup_sway
cd /tmp/setup_sway
# === Helpers ===
You can’t perform that action at this time.