Skip to content

Instantly share code, notes, and snippets.

@Timmmm
Timmmm / layout.rs
Created July 30, 2025 14:33
Prettier Layout Algorithm
use std::fmt::Write;
// The layout algorithm works as follows.
//
// 1. You walk through the AST and build up a LayoutNode tree (see test for example).
// 2. We walk through the LayoutNode tree. For each Group we check if can be laid
// out over a single line. If so do that, otherwise splay it over multiple lines.
// 3. Each time we get to a Nested node, increase the indentation level.
//
// This works pretty well, but it suffers from one issue: splayed lines can
@Timmmm
Timmmm / python_best_practices.md
Last active July 12, 2025 12:02
Python Best Practices

Python Best Practices

No code at global scope

Except for:

  • imports
  • constant definitions
  • function definitions
  • class definitions
@Timmmm
Timmmm / gist:85acf0ab3f00c9a1780579946823d1bb
Created November 16, 2023 09:03
riscv-tests targets (patch)
rv32ui-p-srl
rv64ui-v-simple
rv64ui-v-ori
rv64ua-p-lrsc
rv64uf-p-fmin
rv64ui-v-srlw
rv32uzfh
rv32uf-p-fcvt_w
rv32si-p-ma_fetch
rv64mi-p-access
@Timmmm
Timmmm / gist:519aeee5f24658855f2f6fb9359643e3
Created November 16, 2023 09:02
riscv-tests targets (regex)
GNUMAKEFLAGS :
.SHELLFLAGS :
COMPILER_SUPPORTS_rv64uzfh :
COMPILER_SUPPORTS_rv32uf :
CURDIR :
COMPILER_SUPPORTS_rv32si :
COMPILER_SUPPORTS_rv64ua :
$$($(1)_p_tests): $(1)-p-%:
$$($(1)_v_tests): $(1)-v-%:
.PHONY:
// AppleScript to reload a Chrome tab.
function run(argv) {
if (argv.length !== 1) {
console.log("Please supply a (partial) URL to reload");
return;
}
console.log("Trying to reload: " + argv[0]);
let a = Application("Google Chrome");
for (let i = 0; i < a.windows.length; i++) {
@Timmmm
Timmmm / Privacy.md
Created April 6, 2017 10:24
Egg Timer Privacy Policy

Egg Timer Privacy Policy

No information is ever collected by this app, personal or otherwise.

/**
* Copyright 2016 Alex Yanchenko
*
* Extracted from DroidParts by Tim Hutt, 1/8/2016.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0

Tomato Installation

This page describes how to install Tomato on an Asus RT-N16 router (and possibly others) in Linux.

Note that the original Tomato is no longer developed. There are two maintained mods, as of 2016 - Toastman and Shibby.

Choosing an Image

There are loads of different version to download. The information about which to choose isn't very clear. There is some information here, here, here and here.

@Timmmm
Timmmm / sshd.go
Last active August 16, 2016 12:00
// An SSH and SFTP server. It doesn't support 'exec' commands yet (WIP).
package main
import (
"crypto/rand"
"crypto/rsa"
"encoding/binary"
"fmt"
"io"
"io/ioutil"
@Timmmm
Timmmm / gist:7f57c09132514d674181
Last active August 29, 2015 14:24
Arduino vs mBed

Arduino vs mBed

ArduinomBed
Basic GPIO
void foo()