View .bash_error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
command_not_found_handle() { | |
# Do not run within a pipe | |
if test ! -t 1; then | |
echo "command not found: $1" >&2 | |
return 127 | |
fi | |
# run local npm package if exist | |
cmd="node_modules/.bin/$1" | |
if [ -f "$cmd" ]; then |
View yarn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
set -o pipefail | |
echo >&2 original: yarn $@ | |
if [ "$1" == 'install' ] || [ "$1" == 'add' ] ; then | |
shift | |
if [ "$1" == '--silent' ]; then | |
shift | |
fi | |
echo >&2 mapto: pnpm install --prefer-offline $@ |
View npm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
set -o pipefail | |
case "$1" in | |
i|install) | |
shift | |
case "$1" in | |
-g|--global) | |
shift | |
npx --no npm i -g $@ |
View .bash_error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
command_not_found_handle() { | |
# Do not run within a pipe | |
if test ! -t 1; then | |
echo "command not found: $1" >&2 | |
return 127 | |
fi | |
# run local file if exist | |
if [ -f "$1" ]; then | |
echo "running ./$1..." >&2 |
View workspace-clean
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
let fs = require('fs'); | |
let path = require('path'); | |
let util = require('util'); | |
let target = { | |
files: [ | |
'workspace.xml', | |
], | |
dirs: [ |
View hackers-news.users.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name hackers-news | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description improve readability and night mode for hackers news | |
// @author You | |
// @match https://news.ycombinator.com/item?id=* | |
// @match https://news.ycombinator.com/* | |
// @grant none | |
// ==/UserScript== |
View git-extract
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## extract files archived from git-compress | |
## TODO use tmp folder to support operation within a git repo | |
set -e | |
set -o pipefail | |
with_progress=0 | |
filename='' | |
if [ "$1" == "-p" ] || [ "$1" == "--progress" ]; then |
View git-compress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## use git to compress a single folder or file | |
## TODO use tmp folder to support operation within a git repo | |
set -e | |
set -o pipefail | |
with_progress=0 | |
filename='' | |
dest='' |
View transfer.fish
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function transfer | |
if test (count $argv) -eq 0 | |
echo "No arguments specified. Usage:\ntransfer /tmp/test.md\ncat /tmp/test.md | transfer test.md" | |
return 1 | |
end | |
## get temporarily filename, output is written to this file show progress can be showed | |
set tmpfile ( mktemp -t transferXXX ) | |
## upload stdin or file |
View progress-demo.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ProgressBar = require('progress'); | |
var bar = new ProgressBar(' demo-ing progress [:bar] :percent :etas',{ | |
complete: '=', | |
incomplete: ' ', | |
width: 20, | |
total: 100, | |
}); | |
var timer = setInterval(()=>{ | |
if(bar.curr<bar.total) { | |
bar.tick(1); |
NewerOlder