Skip to content

Instantly share code, notes, and snippets.

View haolian9's full-sized avatar
🐢
make it work, make it right

高浩亮 haolian9

🐢
make it work, make it right
View GitHub Profile
@haolian9
haolian9 / i3config.py
Last active August 11, 2021 05:48
simple implementation about generating i3wm config with include directive, [upstream](https://gitlab.com/haoliang-terraform/squidward/-/blob/master/i3/.config/i3/gencfg)
#!/usr/bin/env python3
import logging
import re
import shutil
import subprocess
from argparse import ArgumentParser, RawDescriptionHelpFormatter
from os import fdopen, unlink
from pathlib import Path
from tempfile import mkstemp
@haolian9
haolian9 / escape.sh
Created June 4, 2018 16:54
escape filename using shell script
#!/usr/bin/env bash
# todo
# follow convention
# * echo -n | awk '{ print $0 }'
# * echo | awk '{ print $0 }'
read_escape() {
while read -r filename; do
escape $filename
@haolian9
haolian9 / docker-tags
Last active November 24, 2017 06:22
shell script that lists all tags of a given image, inspired by [answer](https://stackoverflow.com/a/39454426)
#!/usr/bin/env bash
image="$1"
if [ -z "$image" ]; then
echo "usage: script-name full-image-name"
exit 1
fi
declare -A tags
function recover-last-version
{ #{{{
local commit_ref=$1
if [ ! "${commit_ref}" ]; then return 2; fi
for i in $(git diff HEAD "${commit_ref}" --name-only); do
vim -c 'Gvsplit HEAD~1:% | windo diffthis' -- "${i}"
done;
} #}}}
# 读取管道中传递的文件, 并用vim打开
function vip
{ # {{{
local lines=''
# 从管道中读取
while read x; do
if [[ ! "${x}" ]]; then continue; fi
# 绝对路径, 忽略文件夹
x="$(realpath $x)"
@haolian9
haolian9 / yii2-wechat-authclient.php
Last active October 15, 2015 03:53
Yii 2 authclient for wechat-public-account
<?php
namespace app\modules\stuff\oauthclients;
use CURLFile;
use yii\authclient\OAuthToken;
use yii\base\DynamicModel;
use yii\web\HttpException;
use yii\helpers\Json;