Skip to content

Instantly share code, notes, and snippets.

View eterps's full-sized avatar

Erik Terpstra eterps

View GitHub Profile
from dataclasses import dataclass
@dataclass
class UnitQuantity:
value: int
@dataclass
class KilogramQuantity:
@eterps
eterps / app.tsx
Last active December 14, 2023 16:08
/** @jsx jsx */
import { Hono, Context } from "https://deno.land/x/hono/mod.ts";
import { basicAuth } from "https://deno.land/x/hono/middleware.ts";
import { serveStatic } from "https://deno.land/x/hono/middleware.ts";
import { jsx } from "https://deno.land/x/hono/middleware.ts";
import { env } from "https://deno.land/x/hono/helper.ts";
import { getProject, setProject } from './project.ts';
import { renderPrompt } from './prompt.ts';
import { getAIOutput } from './ai.ts';
@eterps
eterps / init.lua
Created November 4, 2023 14:57
Starter neovim configuration
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
'git',
'clone',
'--filter=blob:none',
'https://github.com/folke/lazy.nvim.git',
'--branch=stable', -- latest stable release
lazypath,
})
@eterps
eterps / syscall.rs
Created October 6, 2022 10:26
Call write syscall on x86-64 Linux in Rust
use std::arch::asm;
fn main() {
let str = b"Hello world\n";
unsafe {
let res = syswrite(str.as_ptr() as u64, str.len() as u64);
println!("res: {}", res);
}
}
% bouncing balls
-initialization(main).
main :-
poke(0x4c00, [0x3c, 0x7e, 0xff, 0xff, 0xff, 0xff, 0x7e, 0x3c], D1),
set_colors(0x0ce9, 0x01c0, 0x0ce5, D2),
start(D1, D2).
start([], []) :-
@eterps
eterps / filmvandaag_hide_low_scores.userscript.js
Created February 10, 2022 15:52
Userscript that hides every score below a 6 from filmvandaag.nl movie results
// ==UserScript==
// @name Hide low scores from filmvandaag.nl
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Hides every score below a 6 from filmvandaag.nl movie results
// @author Erik Terpstra
// @match https://www.filmvandaag.nl/*
// @icon https://www.google.com/s2/favicons?domain=filmvandaag.nl
// @grant none
// ==/UserScript==
@eterps
eterps / optiontest.gleam.rs
Last active May 21, 2020 08:40
Testing the Option type in Gleam
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 / app.js
Created July 19, 2019 07:19 — forked from dergachev/app.js
Manual JS prettification of enterprisewiki.co. See http://news.ycombinator.com/item?id=4933049
// 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("‐ " + e.html()), t.append(e), e.on("click", function() {
$("body").animate({scrollTop: n}, 200)
# 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"
Oberon0 {
Module = "MODULE" ident ";" "BEGIN" StatSeq "END" ident "."
StatSeq = statement (";" statement)*
statement = procedureCall?
procedureCall = ident (actualParameters | "*")?
actualParameters = "(" integer ("," integer)* ")"
integer = digit+
ident = letter alnum*
}