Skip to content

Instantly share code, notes, and snippets.

@wuminzhe
wuminzhe / gist:828b6be186821c9b1be7204598789193
Created October 11, 2021 01:30 — forked from johanmeiring/gist:3002458
"git lg" alias for pretty git log
# From http://garmoncheg.blogspot.com/2012/06/pretty-git-log.html
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --"
@wuminzhe
wuminzhe / check_pr_commits.rb
Last active October 10, 2020 03:41
check if pull request commits contains target string
require 'octokit'
client = Octokit::Client.new(:login => 'username', :password => 'password')
user = client.user
user.login
files = []
pr_commits_r = client.pull_request_commits("darwinia-network/substrate", 3, :state => "closed")
pr_commits_r.each do |commit|
commit_r = client.commit("paritytech/substrate", commit.sha)
@wuminzhe
wuminzhe / eventmachine-defer.rb
Created May 6, 2020 02:14 — forked from acotie/eventmachine-defer.rb
eventmachine defer sample.
require 'bundler/setup'
require 'eventmachine'
require 'open-uri'
EM.run do
puts "main: #{Thread.current}"
operation = proc {
puts "defer operation: #{Thread.current}"
sleep(20)
@wuminzhe
wuminzhe / get_events_by_block.js
Created April 15, 2020 04:04
substrate js api: get events by block
const { ApiPromise } = require('@polkadot/api');
const { u8aToHex } = require('@polkadot/util');
async function main () {
const api = await ApiPromise.create();
const blockNumber = 100;
const result = await getEventsByBlock(api, blockNumber);
console.log(JSON.stringify(result));
api.disconnect();
}
@wuminzhe
wuminzhe / p3d.rs
Created July 16, 2019 10:12
p3d 分红算法简化
use std::collections::HashMap;
#[derive(Clone)]
struct Account {
token_balance: u64,
payouts: f64,
}
struct P3d {
accounts: HashMap<u32, Account>,
@wuminzhe
wuminzhe / init.vim
Last active January 11, 2021 09:01
neovim
call plug#begin()
" A Lightweight File Browser based on netrw
Plug 'tpope/vim-vinegar'
" wisely add end in ruby, endfunction/endif/more in vim script, etc
Plug 'tpope/vim-endwise'
" quoting/parenthesizing made simple
Plug 'tpope/vim-surround'
@wuminzhe
wuminzhe / netrw quick reference.md
Created August 7, 2018 09:11 — forked from t-mart/netrw quick reference.md
A quick reference for Vim's built-in netrw file selector.
Map Action
<F1> Causes Netrw to issue help
<cr> Netrw will enter the directory or read the file
<del> Netrw will attempt to remove the file/directory
- Makes Netrw go up one directory
a Toggles between normal display, hiding (suppress display of files matching g:netrw_list_hide) showing (display only files which match g:netrw_list_hide)
c Make browsing directory the current directory
C Setting the editing window
d Make a directory
@wuminzhe
wuminzhe / tmux-cheatsheet.markdown
Last active August 3, 2018 09:16 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@wuminzhe
wuminzhe / .screenrc
Created May 19, 2017 06:50
.screenrc
hardstatus off
hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %m-%d %{W} %c %{g}]'
startup_message off
termcapinfo xterm* ti@:te@
altscreen on
@wuminzhe
wuminzhe / litecoin.conf
Created May 18, 2017 06:04 — forked from dasher/litecoin.conf
example litecoin.conf
# litecoin.conf configuration file. Lines beginning with # are comments.
# Network-related settings:
# Run on the test network instead of the real litecoin network.
#testnet=0
# Connect via a socks4 proxy
#proxy=127.0.0.1:9050