Skip to content

Instantly share code, notes, and snippets.

View hellwolf's full-sized avatar

Miao ZhiCheng hellwolf

View GitHub Profile
@hellwolf
hellwolf / activate.sh
Created March 9, 2024 00:28
macos gnu coreutils wrappers
PATH=~/Applications/gnu-coreutils-wrappers/bin:$PATH
@hellwolf
hellwolf / toggle-sticky-terminal.sh
Created September 5, 2023 20:41
Toogle sticky gnome terminal
#!/usr/bin/env bash
# Usage: toggle-sticky-terminal.sh [above|below]
set -x
STATUS_FILE=$XDG_RUNTIME_DIR/sticky-terminal-status.json
setup() {
gnome-terminal --profile=scratchpad
@hellwolf
hellwolf / Dockerfile
Created August 6, 2023 09:44
docker-image-urbit
FROM nixos/nix
RUN nix-channel --update
RUN nix-env -i urbit
CMD ["sh", "-c", "urbit -t /var/lib/urbit"]
@hellwolf
hellwolf / hello_world.hs
Last active July 24, 2023 20:02
Hypothetical hscript
#!/usr/bin/env hsh
-- a. The file name should probably be ".hs", but it's nice to have all the syntax highlitng for free using ".hs".
-- b. it works by having a shell running as a separate process, while the hscript process piping stuff from these quasi-quote
-- template haskell outputs to the shell.
-- c. `hsh` preprocessor reduces some boiler plate, so it is extremely terse to start your helloworld program!
-- d. Otherwise it all looks your regular Haskell program, feel free to add 20+ more GHC extensions.
banner s = "hello world, " <> s
@hellwolf
hellwolf / gist:12cb9de7c7487496217afcf988f6739f
Created July 24, 2023 17:55
Find all the libraries with external/public functions
$ git grep -lE '^library' contracts/ | while read i;do grep -E 'public|external' -lE $i | xargs grep -hoE '^library\s+\w+';done | sort | uniq
@hellwolf
hellwolf / trace-symlink
Created March 27, 2023 11:58
Nix Helpers: trace-symlink & trace-which
@hellwolf
hellwolf / bash-pipe-recursion
Last active January 6, 2023 13:17
Recursive unix pipes, bash functional?
$ f () { if [ $1 -gt 0 ];then less | f $(( $1 - 1 ));else less;fi; }
$ cat /dev/random | xxd | f 100
$ ps aux| grep less | wc -l
102
@hellwolf
hellwolf / SuperfluidToken.js
Created January 2, 2023 12:31
Superfluid Constant Flow Toy Model
let currentTime = parseInt(Date.now()/1000); // current unix time in seconds
class SuperfluidToken {
accounts = {};
cfaAgreements = {}
_getAccount(owner) {
let acc = this.accounts[owner];
if (!acc) {
@hellwolf
hellwolf / nix-tip__.home.nix.txt
Last active December 19, 2022 20:24
[Nix Tip]: install specific haskell compiler version and its hls & Agda
## ghc 9.4.x, HLS and Agda built with it
[ haskell.compiler.ghc94
haskell.packages.ghc94.haskell-language-server
haskell.packages.ghc94.Agda
]
## alternative way of building HLS with ghc versions included
(haskell-language-server.override {
haskellPackages = haskell.packages.ghc92;
supportedGhcVersions = [
@hellwolf
hellwolf / nixos-tip__.gitconfig
Last active February 10, 2023 16:21
[NixOS Tip]: configure git credential to use libsecret on NixOS
[user]
email = your email
name = your name
signingkey = xxxxxxxx
[credential]
helper = /run/current-system/sw/bin/git-credential-libsecret
# make sure you have gitFull installed on NixOS