Skip to content

Instantly share code, notes, and snippets.

Avatar

Beeno Tung beenotung

View GitHub Profile
@beenotung
beenotung / yarn
Created Jun 24, 2021
proxy yarn to call pnpm
View yarn
#!/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 $@
@beenotung
beenotung / npm
Last active Jun 24, 2021
proxy npm to call pnpm
View npm
#!/bin/bash
set -e
set -o pipefail
case "$1" in
i|install)
shift
case "$1" in
-g|--global)
shift
npx --no npm i -g $@
@beenotung
beenotung / .bash_error
Created May 11, 2021
command not found handler for shell
View .bash_error
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
@beenotung
beenotung / workspace-clean
Created Sep 24, 2020
to free up disk space by deleting downloaded packages
View workspace-clean
#!/usr/bin/env node
let fs = require('fs');
let path = require('path');
let util = require('util');
let target = {
files: [
'workspace.xml',
],
dirs: [
@beenotung
beenotung / hackers-news.users.js
Last active May 2, 2020
user script to improve readability and night mode for hackers news
View hackers-news.users.js
// ==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
#!/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
#!/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=''
@beenotung
beenotung / mobile-index.html
Last active Jul 15, 2019
html meta for mobile friendly
View mobile-index.html
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">
</head>
<body>
@beenotung
beenotung / transfer.fish
Last active Mar 4, 2019 — forked from nl5887/transfer.fish
Bash and zsh alias for transfer.sh. Transfers files and directories to transfer.sh.
View transfer.fish
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
@beenotung
beenotung / progress-demo.js
Created Feb 18, 2019
demo of npm package progress for cli progress bar
View progress-demo.js
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);