This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func Test(t *testing.T) { | |
| a := map[int]int{ | |
| } | |
| var b sync.Map | |
| for i := 0; i < 2000; i++ { | |
| a[i] = i | |
| } | |
| var wg sync.WaitGroup | |
| wg.Add(2000) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "reflect" | |
| "testing" | |
| "github.com/aws/aws-sdk-go/aws/request" | |
| ) | |
| func BenchmarkFooF(b *testing.B) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| go test -run=. -bench=. -benchtime=5s -count 5 -benchmem -cpuprofile=cpu.out -memprofile=mem.out -trace=trace.out ./package | tee bench.txt | |
| go tool pprof -http :8080 cpu.out | |
| go tool pprof -http :8081 mem.out | |
| go tool trace trace.out | |
| go tool pprof $FILENAME.test cpu.out | |
| # (pprof) list <func name> | |
| # go get -u golang.org/x/perf/cmd/benchstat | |
| benchstat bench.txt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "bytes" | |
| "strings" | |
| "testing" | |
| ) | |
| func BenchmarkStringAppend(b *testing.B) { | |
| for i := 0; i < b.N; i++ { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [alias] | |
| st = status | |
| co = checkout | |
| br = branch | |
| ci = commit -av --no-status -q | |
| unstage = reset HEAD -- | |
| last = log -1 HEAD | |
| recent = for-each-ref --sort=committerdate refs/heads/ --format='%(committerdate:short) %(refname:short)' | |
| logd = log --decorate | |
| lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -eu | |
| doWork() { | |
| # make modifications here | |
| git br -d $i | |
| } | |
| for i in $(ls); do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Usage: | |
| timeStr := Get_now() | |
| MsgBox, %timeStr | |
| */ | |
| Get_now() | |
| { | |
| global | |
| UTCFormatStr := "yyyy-MM-dd'T'HH:mm:ss" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Get-ChildItem '.*' | foreach {$_.Attributes = $_.Attributes -bor "Hidden"} | |
| # Hide all files and folders that starts with . | |
| # I use this to clean up my home directory. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # Source: https://liam.sh/post/importing-bash-functions-over-ssh | |
| sshrc() { | |
| local SSHHOME=${SSHHOME:=~} | |
| if [ ! -f $SSHHOME/.sshrc ]; then | |
| echo "No such file: $SSHHOME/.sshrc" | |
| exit 1 | |
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Python3 | |
| urlencode() { | |
| python -c "import urllib.parse as ul; print(ul.quote_plus('$1'));" | |
| } | |
| #Python2 | |
| urlencode() { | |
| python -c "import urllib as ul; print(ul.quote_plus('$1'));" |
NewerOlder