Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 permutations | |
| func Permutations(arr []int) <-chan []int { | |
| var fn func([]int, int) | |
| ch := make(chan []int) | |
| token := make(chan struct{}, factorial(len(arr))) | |
| fn = func(arr []int, n int) { | |
| if n == 1 { | |
| tmp := make([]int, len(arr)) |
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
| def is_iso(g, h): | |
| return (Counter(frozenset(g.degree[ee] for ee in e) for e in g.edges) == | |
| Counter(frozenset(h.degree[ee] for ee in e) for e in h.edges)) |
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
| # https://stackoverflow.com/a/44411205/10051099 | |
| function Write-BranchName () { | |
| try { | |
| $branch = git rev-parse --abbrev-ref HEAD | |
| if ($branch -eq "HEAD") { | |
| # we're probably in detached HEAD state, so print the SHA | |
| $branch = git rev-parse --short HEAD | |
| Write-Host " ($branch)" -ForegroundColor "red" | |
| } |
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
| # jupyter execution | |
| function je(){ | |
| if [ $# = 2 ] | |
| then | |
| kernel=$2 | |
| elif [ $# = 1 ] && [ -n $CONDA_DEFAULT_ENV ] | |
| then | |
| kernel=$CONDA_DEFAULT_ENV | |
| fi | |
| echo $1 $kernel |
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
| function ln-s() { | |
| cmd /c mklink $args[0] $args[1] | |
| } |
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
| $profile.psobject.properties | where { $_ -is [psnoteproperty] } | foreach { echo $_.value; Measure-Command { . $_ | |
| .value }} |
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
| function cd-gitroot(){ | |
| cd $(git rev-parse --show-toplevel) | |
| } |
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
| function _cd (){ | |
| pushd $args[0] | |
| echo $(resolve-path $args[0]) >> ~\.cd-hist | |
| echo $(gc ~\.cd-hist -tail 300) > ~\.cd-hist | |
| } | |
| set-alias -n cd -v _cd -Option AllScope | |
| function peco-cd () { | |
| _cd $(cat $HOME\.cd-hist | peco --initial-filter Fuzzy --layout bottom-up) | |
| } | |
| set-psreadlinekeyhandler -key ctrl+f -scriptblock { peco-cd } |
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
| function touch(){ new-item $args[0] -itemtype file } |