Skip to content

Instantly share code, notes, and snippets.

shifujun /
Created June 12, 2022 09:52
A brain-burning question about 'mut' keyword in learning Rust

When I learn Rust's mut keyword and references types, everything seemed logical. Basicly without mut decleared, any member of a struct cannot change.

Until I read to this:

    let mut count = 0;
    // A closure to increment `count` could take either `&mut count` or `count`
    // but `&mut count` is less restrictive so it takes that. Immediately
    // borrows `count`.
shifujun / foo.main.kts
Created February 10, 2022 09:06
a kotlin script use ktor client and shell command
#!/usr/bin/env kotlin
import io.ktor.client.*
import io.ktor.client.engine.cio.*
import io.ktor.client.features.*
import io.ktor.client.request.*
shifujun /
Created May 19, 2021 06:23
make a vendor repo with shallow clone
#!/usr/bin/env sh
cd $(mktemp -d)
echo "\n\n"
echo Step1: use temp dir: $(pwd)
echo "\n\n"
echo Step2: init main-repo
mkdir main-repo
shifujun /
Created March 25, 2021 06:35
Background run command and interval check it until finished
sleep 1000 & export job=$! && until ! ps -p $job > /dev/null; do echo running && sleep 2; done && wait $job


  • sleep 1000: a long time no output command.
  • &: put command background.
  • export job=$!: $! is pid of command.
  • ! ps -p $job > /dev/null: if command has finished.
  • echo running && sleep 2: every 2 seconds, output running.