Skip to content

Instantly share code, notes, and snippets.

@penglei
penglei / nar-spec.md
Created April 20, 2024 02:33 — forked from jbeda/nar-spec.md
Nix Archive (NAR) file specification

This is taken directly from Figure 5.2 in http://nixos.org/~eelco/pubs/phd-thesis.pdf. It is presented here to be more directly linkable.

serialise(fso) = str("nix-archive-1") + serialise1(fso)

serialise1(fso) = str("(") + seralise2(fso) + str(")")

serialise2(type=Regular, exec, contents) =
  str("type") + str("regular")
 + (
@penglei
penglei / alacritty.yml
Created June 25, 2023 03:03
alacritty config
font:
normal: {}
size: 18.0
hints:
enabled:
- binding:
key: U
mods: Control|Shift
command:
program: /Users/penglei/.local/bin/open-haskell-doc
-----BEGIN PGP PUBLIC KEY BLOCK-----
mDMEZFqvPRYJKwYBBAHaRw8BAQdA3Vgen6Cu8jje4PgglBdd4Zwsyp4YWA7dsUVs
/VZ18ge0G3BlbmdsZWkgPHBlbmdsZWlAeWJ5dGUub3JnPoiQBBMWCgA4FiEENU5u
tuafzaO8obO3s0bUg3byXssFAmRazykCGwEFCwkIBwMFFQoJCAsFFgIDAQACHgUC
F4AACgkQs0bUg3byXsvu6AEA/bG5HdA3w5VnKjqh/6X3IBIqeGD3kgVspSedtOdw
+zUA/3Z876SHRNQHPw3clfjnyw5nIKKekTWXhuJAPWTpPq4IuDMEZFqwTRYJKwYB
BAHaRw8BAQdARY0HjbH7azmVOGL6WpmCGb7GrP3p9bgU0Uq/4GIy+IWI7wQYFgoA
IBYhBDVObrbmn82jvKGzt7NG1IN28l7LBQJkWrBNAhsCAIEJELNG1IN28l7LdiAE
GRYKAB0WIQTekuh6sEYBIRbQN1WaE4Qyev94UgUCZFqwTQAKCRCaE4Qyev94Uvyg
@penglei
penglei / macos-ramdisk.md
Created May 12, 2023 15:28 — forked from htr3n/macos-ramdisk.md
Creating RAM disk in macOS

Built-in

diskutil erasevolume HFS+ 'RAM Disk' `hdiutil attach -nobrowse -nomount ram://XXXXX`

where XXXXX is the size of the RAM disk in terms of memory blocks.

Notes:

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@penglei
penglei / network-restart.sh
Created January 25, 2021 08:16 — forked from tachang/network-restart.sh
Cleanly restart the default libvirt network
#!/bin/bash
#
# Yury V. Zaytsev <yury@shurup.com> (C) 2011
#
# This work is herewith placed in public domain.
#
# Use this script to cleanly restart the default libvirt network after its
# definition have been changed (e.g. added new static MAC+IP mappings) in order
# for the changes to take effect. Restarting the network alone, however, causes
# the guests to lose connectivity with the host until their network interfaces
@penglei
penglei / CMakeLists.txt
Created December 28, 2020 03:38
CLion config istio-proxy
cmake_minimum_required(VERSION 3.15)
project(istio-proxy)
macro(print_all_variables)
message(STATUS "print_all_variables------------------------------------------{")
get_cmake_property(_variableNames VARIABLES)
foreach (_variableName ${_variableNames})
message(STATUS "${_variableName}=${${_variableName}}")
endforeach()
message(STATUS "print_all_variables------------------------------------------}")
@penglei
penglei / penglei.zsh-theme
Last active June 27, 2022 07:24
my oh-my-zsh theme
#based on steeef theme
#run bellow command in terminal to show color list
#: spectrum_ls
function _penglei_theme_info_sep {
echo "%{$FG[245]%}|%{$reset_color%}"
}
# Determine our shell
#!/bin/bash
config_file=config.json
cat << EOF > $config_file
{
"signing": {
"default": {
"expiry": "87600h"
},
"profiles": {
@penglei
penglei / a-qemu-install-debian-arm64.sh
Last active April 5, 2023 09:07
run qemu-aarch64 on macOS
#!/bin/bash
#qemu-img create -f qcow2 disk.qcow2 20G
#qemu-img create -f qcow2 varstore.img 128M
debian_iso=debian-9.6.0-arm64-xfce-CD-1.iso
qemu-system-aarch64 -smp cpus=6 -M virt -cpu max -m 2G -nographic \
-drive file=QEMU_EFI.img,if=pflash,format=raw \
-drive file=varstore.img,if=pflash \
-drive file=disk.qcow2,if=virtio \
-drive file=$debian_iso,if=virtio,format=raw