Skip to content

Instantly share code, notes, and snippets.

View GongT's full-sized avatar
😺
meow meow

sbYm GongT

😺
meow meow
View GitHub Profile
@GongT
GongT / auto-update
Created August 13, 2023 12:30
archlinux pacman auto update
########### /usr/local/bin/auto-update
#!/usr/bin/env bash
set -Eeuo pipefail
declare -i RETRY=3
while ! pacman -Syu --noconfirm; do
RETRY=$((RETRY - 1))
if [[ $RETRY -le 0 ]]; then
// GENERATED CODE, DO NOT EDIT.
{
"$schema": "http://json-schema.org/schema",
"definitions": {
"global-config": {
"description": "全局配置",
"additionalProperties": false,
"properties": {
"RecordMode": {
"description": "录制模式",
@GongT
GongT / profile.ps1
Created November 4, 2020 17:21
Sync network drive mapping when run "PowerShell (admin)"
### append this into $PROFILE.CurrentUserAllHosts
foreach ($info in Get-ChildItem -Path HKCU:/Network) {
$letter = Split-Path -Leaf -Path $info.Name -ErrorAction SilentlyContinue
if (-Not $letter) { continue }
if (Test-Path -Path "${letter}:/") { continue }
$remote = $info.GetValue('RemotePath')
if (-Not $remote) { continue }
New-PSDrive -Scope Global -PSProvider "FileSystem" -Name $letter -Root $remote -ErrorAction SilentlyContinue | Out-Null
}
@GongT
GongT / create-initrd.sh
Created September 3, 2020 04:20
libvirtd direct kernel boot
#!/usr/bin/env bash
mkinitrd \
--with fuse \
--with virtio_scsi \
--with virtio_mmio \
--with virtio_console \
--with virtio_blk \
-f initrd.img \
"$(uname -r)"
@GongT
GongT / arguments.sh
Created January 27, 2020 02:03
bash argument options parser (BASH>=4.2)
declare -a _ARG_GETOPT_LONG
declare -a _ARG_GETOPT_SHORT
declare -A _ARG_COMMENT
declare -A _ARG_INPUT
declare -A _ARG_OUTPUT
declare -A _ARG_RESULT
declare -A _ARG_REQUIRE
function arg_string() {
if [[ "$1" == '+' ]]; then
shift
@GongT
GongT / profile.d-cygwin-path.sh
Created December 10, 2019 10:07
remove Windows staff from PATH cygwin
if uname | grep -iq "cygwin" ; then
IFS=: read -r -d '' -a path_array < <(printf '%s:\0' "$PATH")
WINPATH=""
LP=""
for P in "${path_array[@]}"; do
if [[ "$P" =~ ^/cygdrive ]]; then
WINPATH+=":$P"
else
LP+="$P:"
@GongT
GongT / cloudSettings
Last active January 11, 2020 20:45
cloudSettings
{"lastUpload":"2020-01-11T20:45:17.450Z","extensionVersion":"v3.4.3"}
@GongT
GongT / node-long-running.service
Created November 8, 2019 06:11
Systemd service file for long running nodejs project, eg, a website.
[Unit]
Description=Auto run UMI UI
After=data.mount
# Requires=mariadb.service
[Service]
Type=simple
Restart=on-failure
Environment=DISPLAY= HOST=0.0.0.0 UMI_PORT=15000 UMI_UI_BROWSER=none DEBUG=umiui:*
ExecStart=/usr/local/bin/umi ui
@GongT
GongT / code.sh
Created November 5, 2019 03:30
start VSCode from cygwin (/usr/local/bin/code)
#/usr/bin/env bash
ARGS=("$@")
WPATH=()
PPATH=()
OIFS="$IFS"
IFS=":"
X=( $PATH )
@GongT
GongT / 00.service.md
Last active September 26, 2019 08:08
Windows 10 native OpenSSH Agent

To enable ssh-agent and add private key into it:

Set-Service ssh-agent -StartupType Automatic
Start-Service ssh-agent

ssh-add X:\xxx.ed25519

The permission of file X:\xxx.ed25519 need manual tweak before ssh-add:

  1. Right click X:\xxx.ed25519, click "Properties."