Skip to content

Instantly share code, notes, and snippets.

@seafooler
seafooler / draw-multiple-bars-exp.py
Last active November 7, 2019 09:28
Example for drawing multiple bar diagrams for multiple groups of data
#-*- coding:utf-8 -*-
import matplotlib
import pandas as pd
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import numpy as np
a = np.array([608,425,555,1299,5594,18595,59607,107326])
b = np.array([9506,9119,5677,8478,16283,26443,71305,119392])
@seafooler
seafooler / vagrant-related-ops.sh
Last active December 11, 2019 01:43
Vagrant related operations
@seafooler
seafooler / split-hex-literal.go
Created October 6, 2019 05:37
Split a hex string to a literal, so as to assign it to a byte slice
// Target as follows:
// If we have a hex string as 'be0b136f2f3db38d4f55f1963f0acac506d637b3c27a4c42f3504836a4ec52b1',
// we want to convert to a literal in little endian, so as to assign it to a byte slice, for example:
// bytes := [32]byte{ // Make go vet happy.
// 0xb1, 0x52, 0xec, 0xa4, 0x36, 0x48, 0x50, 0xf3,
// 0x42, 0x4c, 0x7a, 0xc2, 0xb3, 0x37, 0xd6, 0x06,
// 0xc5, 0xca, 0x0a, 0x3f, 0x96, 0xf1, 0x55, 0x4f,
// 0x8d, 0xb3, 0x3d, 0x2f, 0x6f, 0x13, 0x0b, 0xbe,
// }
@seafooler
seafooler / revert-commit.sh
Created October 6, 2019 05:27
Revert the git repository to a previous commit, give away all the changes
git reset --hard commit-id
@seafooler
seafooler / del-commit-retain-file.sh
Created September 27, 2019 07:07
Git delete a commit log history but retain the files
git reset commit-id
@seafooler
seafooler / checkout-remote-branch.sh
Created September 9, 2019 07:02
Checkout a remote branch
git checkout -b branchxyz origin/branchxyz
@seafooler
seafooler / remove-files-committed-before.sh
Created May 6, 2019 08:20
Remove the files already committed before in Git
git rm -r --cached .
git add .
git commit -m "XXXXXXX"
@seafooler
seafooler / revert-changes-git.md
Created April 13, 2019 07:23
Revert all the changes in git

If you want to revert changes made to your working copy, do this: git checkout .

If you want to revert changes made to the index (i.e., that you have added), do this. Warning this will reset all of your unpushed commits to master!: git reset

If you want to revert a change that you have committed, do this: git revert <commit 1> <commit 2>

If you want to remove untracked files (e.g., new files, generated files):

@seafooler
seafooler / p2p.go
Created April 10, 2019 13:59
P2P network test
package main
import (
"bufio"
"context"
"flag"
"fmt"
"github.com/libp2p/go-libp2p"
"github.com/libp2p/go-libp2p-crypto"
"github.com/libp2p/go-libp2p-net"
@seafooler
seafooler / test-network-speed
Created March 25, 2019 14:05
Test the network speed
curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python -