Skip to content

Instantly share code, notes, and snippets.

View weaming's full-sized avatar
🦀
Rustacean

Garden Yuen weaming

🦀
Rustacean
  • Shenzhen, China
View GitHub Profile
# inspired by https://github.com/junegunn/fzf/issues/868
function __fzf_ls_files
git ls-tree -r --name-only HEAD 2>/dev/null; or fd --type f --hidden --follow --exclude .git
end
function __fzf_grep_last
set -l cmd (commandline)
# default complete all, and compatible with fzf `**<TAB>`
if str_endswith "$cmd" ' '; or test $cmd = '**'
ETHBTC
LTCBTC
BNBBTC
NEOBTC
QTUMETH
EOSETH
SNTETH
BNTETH
BCCBTC
GASBTC
package main
import (
"io/ioutil"
"log"
"net/http"
)
func index(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
import json
from functools import wraps
import requests
allow_methods = [
'options',
'head',
'get',
'post',
#!/bin/bash
# macos: brew install https://raw.githubusercontent.com/kadwanev/bigboybrew/master/Library/Formula/sshpass.rb
user=$1
ip_or_tail=$2
if echo $ip_or_tail | grep -E '\.' >/dev/null; then
user_host=$user@$ip_or_tail
else
user_host=$user@192.168.1.$ip_or_tail
@weaming
weaming / jpeg-convert-color-space.py
Last active July 21, 2021 08:23
CLI to convert or assign colorspace of JPEG
#!/usr/bin/env python3
# Author : weaming
# Mail : garden.yuen@gmail.com
# Created : 2021-07-12 15:07:12
# 解决以下几个方面的问题:色彩空间、文件压缩、EXIF 处理、水印
import argparse
import io
import os
from PIL import Image

async in Python3

History

  1. generators found in Python 3.3
  2. event loop in the form of asyncio: In Python 3.4, the asyncio.coroutine decorator was used to label a function as acting as a coroutine that was meant for use with asyncio and its event loop.
  3. yield from to await in Python 3.5

Event loop and task

import (
"fmt"
"log"
"os"
"sync"
"time"
)
var KEEP_CALLS = os.Getenv("KEEP_CALLS") != ""
package main
import (
"bytes"
"encoding/json"
"fmt"
"time"
)
type Duration struct {
@weaming
weaming / git-aliases.bash
Last active February 5, 2021 04:51
使用 alias 提高 git 使用效率
alias gcl='git clone'
alias gs='git status'
alias gd='git diff'
alias gdc='git diff --cached'
alias gl='git lg'
alias gps='git push -u'
alias gconf='vi .git/config'
alias gamend='git commit --amend'
alias gamendy='git commit --amend --no-edit'
alias gback='git reset --hard HEAD~'