Skip to content

Instantly share code, notes, and snippets.

View romac's full-sized avatar
🔮
λ

Romain Ruetschi romac

🔮
λ
View GitHub Profile
@sainoe
sainoe / local-testnet-permissionless-equivocation.sh
Last active September 20, 2024 08:02
ICS Permissionless testnet
#!/bin/bash
set -eux
## Prerequisites:
# * ICS v6.x
# * Hermes v1.10.3+45a29cc00
# User balance of stake tokens
USER_COINS="100000000000stake"
# Amount of stake tokens staked
@kubukoz
kubukoz / .scalafmt.conf
Last active February 1, 2025 19:53
How to disable significant indentation in Scala
runner.dialect = scala3
runner.dialectOverride.allowSignificantIndentation = false
# allows `if x then y`
runner.dialectOverride.allowQuietSyntax = true
@heaths
heaths / workspace-dependencies.rs
Last active February 27, 2024 09:27
Rust script to verify that package dependencies are inherited from single workspace.
#!/usr/bin/env -S cargo +nightly -Zscript
---
[package]
edition = "2021"
[dependencies]
cargo-util-schemas = "0.1.0"
serde = { version = "1.0.197", features = ["derive"] }
serde_json = "1.0.114"
toml = "0.8.10"
@o11c
o11c / every-vm-tutorial-you-ever-studied-is-wrong.md
Last active April 15, 2025 22:13
Every VM tutorial you ever studied is wrong (and other compiler/interpreter-related knowledge)

Note: this was originally several Reddit posts, chained and linked. But now that Reddit is dying I've finally moved them out. Sorry about the mess.


URL: https://www.reddit.com/r/ProgrammingLanguages/comments/up206c/stack_machines_for_compilers/i8ikupw/ Summary: stack-based vs register-based in general.

There are a wide variety of machines that can be described as "stack-based" or "register-based", but not all of them are practical. And there are a lot of other decisions that affect that practicality (do variables have names or only address/indexes? fixed-width or variable-width instructions? are you interpreting the bytecode (and if so, are you using machine stack frames?) or turning it into machine code? how many registers are there, and how many are special? how do you represent multiple types of variable? how many scopes are there(various kinds of global, local, member, ...)? how much effort/complexity can you afford to put into your machine? etc.)

  • a pure stack VM can only access the top elemen
@gelisam
gelisam / MutuCheckInfer.hs
Last active September 4, 2024 21:32
A recursion scheme for mutually-recursive types
-- Defining a custom recursion scheme to manipulate two mutually-recursive
-- types, in the context of a toy bidirectional type checker.
{-# LANGUAGE DerivingStrategies, GeneralizedNewtypeDeriving, ScopedTypeVariables #-}
module Main where
import Test.DocTest
import Control.Monad (when)
import Data.Bifunctor (Bifunctor(bimap))
import Data.Bifoldable (Bifoldable(bifoldMap), bitraverse_)
@sainoe
sainoe / change_voting_period
Last active October 17, 2022 15:59
testnet-scripts
#!/bin/bash
set -eux
```
tee ${PROV_NODE_DIR}/change-voting-period.json<<EOF
{
"title": "Change voting period",
"description": "Voting period",
"changes": [
@HipHopHuman
HipHopHuman / incremental-game-loop.md
Last active April 20, 2025 12:32
How to make a game loop for your idle game

How do I make a game loop for my Idle Game?

Interval-Based Resource Generators

So, you want to build an idle/incremental game in JavaScript and you’ve read on the internet that setInterval is the way to go when it comes to handling resources that automatically generate over time.

You get started, you write down your setInterval function, you set it to trigger once every 1000 milliseconds, and every time it triggers, you add 1 to the player’s total resource count. Perfect. It works.

Uh-oh.

@piperswe
piperswe / build_push_and_run.sh
Created April 17, 2021 01:53
Build multi-architecture Docker images with Nix
#!/bin/sh
# Required on macOS because cctools is marked as broken
export NIXPKGS_ALLOW_BROKEN=1
nix run -f image.nix -c push
docker run ghcr.io/piperswe/hello
@SergeiMeza
SergeiMeza / macOS_ChatApp_Main.swift
Last active June 21, 2023 09:31
Chat App Client (UI) for macOS in SwiftUI
// Main
@main
struct ChatApp_macOSApp: App {
var body: some Scene {
WindowGroup {
Home()
}
// Hiding Title Bar...
.windowStyle(HiddenTitleBarWindowStyle())
@tomslominski
tomslominski / README.md
Last active March 30, 2025 11:17
Avahi alias systemd service

Instructions

The first file is the script to be run, which you can store in your home directory. The second file is the systemd unit file which goes in /etc/systemd/system. Make sure on line 6 it references the location of the first file, and that you run systemctl daemon-reload after editing the unit file.

To run the service automatically on boot, run sudo systemctl enable avahi-alias@[domain], followed by sudo systemctl start avahi-alias@[domain] to start it immediately.