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 / ranbow.sh
Created September 16, 2019 16:31
ranbow animation in bash
#!/bin/bash
RAINBOW=(196 202 208 214 220 226 190 154 118 82 46 46 47 48 49 50 51 45 39 33 27 21 21 57 93 129 165 201 200 199 198 197 196)
function char_rainbow() {
local STR="$1" I
J=$(( $J % ${#RAINBOW[@]} ))
for I in $(seq 0 $(( ${#STR} - 1 )) ) ; do
printf "\e[38;5;%dm%c" "${RAINBOW[J]}" "${STR:${I}:1}"
J=$(( $J + 1 ))
@GongT
GongT / rgb.sh
Last active September 16, 2019 16:01
color in shell
#!/bin/bash
# rgb R G B
# 0 <= RGB <= 5
function rgb() {
local R=$1 G=$2 B=$3
echo -n $(( $R * 36 + $G * 6 + $B + 16 ))
}
@GongT
GongT / parallel-goget.sh
Created December 23, 2018 20:20
parallel go get
#!/bin/bash
GOBIN=/usr/golang/bin/go
function go() {
if [ "$1" = "get" ]; then
shift
echo "run go get ::: $*" >&2
parallel --will-cite -j 4 "$GOBIN" get -u -v ":::" "$@"
else
"$GOBIN" "$@"
fi
@GongT
GongT / README.dm
Created October 29, 2018 08:27
a service file to redirect Privoxy log file to journald
```bash
journalctl -ft privoxy
```
@GongT
GongT / steps.md
Last active September 3, 2018 07:43
Create A Library With Typescript And Rollup

You want:

  1. write some code as library
  2. split your code into many files

Then you can just write every file standalone, compile them all (to commonjs format), and others can use. perfect.

If you also want:

  1. manage imports using absolute path in your module (eg. import xxx from "vs/code/workbench")
    • without requires user mock require call to handle absolute import path
  2. remove "src" or "out" from import path
@GongT
GongT / tiny-tsc-intro.ts
Created September 1, 2018 19:14
the first part of typescript analyze process.
import {
createCompilerHost,
createProgram,
Diagnostic,
formatDiagnostic,
FormatDiagnosticsHost,
getParsedCommandLineOfConfigFile,
ParseConfigFileHost,
ParsedCommandLine,
Program,
@GongT
GongT / setup
Created May 5, 2018 15:24
cygwin install new package
#!/bin/bash
LOCAL_REPO='http://mirrors.aliyun.com/cygwin/'
LOCAL_PACKAGE_DIR='A:/cygwin-repo'
if [ ! -e /setup-x86_64.exe ]; then
if command -v wget &>/dev/null ; then
wget -c "http://cygwin.org/setup-x86_64.exe" -O /setup-x86_64.exe
else
echo "No setup-x86_64.exe, and no wget." >&2
@GongT
GongT / mount.sh
Created April 24, 2018 14:43
mount qemu disk
#!/bin/sh
export O_P_W_D=$(pwd)
trap "
cd '$O_P_W_D'
pwd
echo 'cleanup...'
while ! umount root ; do sleep 1 ; done
while ! qemu-nbd --disconnect /dev/nbd0 ; do sleep 1 ; done
@GongT
GongT / pstorm
Last active February 23, 2018 05:03
Idea IDE commandline shortcut
#!/usr/bin/env bash
#################################
IDEA_PATH="/opt/PhpStorm/bin/phpstorm.sh"
#################################
set -e
@GongT
GongT / remote-connect.md
Last active June 11, 2017 03:36
from linux shell, remote open chrome on windows

On windows

create a link to chrome inside WSL. this will only run after Creators Update

echo '#!/bin/bash

cd /mnt/c
exec "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe" "$@"
' > /usr/local/bin/chrome
chmod a+x /usr/local/bin/chrome