Skip to content

Instantly share code, notes, and snippets.

View tamuhey's full-sized avatar
🏠
Working from home

Yohei Tamura tamuhey

🏠
Working from home
View GitHub Profile
@tamuhey
tamuhey / parentheses.ipynb
Last active August 14, 2019 03:18
List of all unicode's parentheses
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tamuhey
tamuhey / permutations.go
Created June 1, 2019 08:51
Permutations for Golang (Heap's algolithm)
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))
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))
@tamuhey
tamuhey / prompt.ps1
Created April 9, 2019 02:52
powershell prompt with git branch name and conda env name
# 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"
}
@tamuhey
tamuhey / je.sh
Created April 3, 2019 01:43
bash function for executing Jupyter notebook
# jupyter execution
function je(){
if [ $# = 2 ]
then
kernel=$2
elif [ $# = 1 ] && [ -n $CONDA_DEFAULT_ENV ]
then
kernel=$CONDA_DEFAULT_ENV
fi
echo $1 $kernel
@tamuhey
tamuhey / ln-s.ps1
Created March 28, 2019 02:40
Create symlink in powershell, without root
function ln-s() {
cmd /c mklink $args[0] $args[1]
}
@tamuhey
tamuhey / measure_profile.ps1
Created March 28, 2019 01:57
measure import time for all profiles
$profile.psobject.properties | where { $_ -is [psnoteproperty] } | foreach { echo $_.value; Measure-Command { . $_
.value }}
@tamuhey
tamuhey / cd-gitroot.sh
Last active March 27, 2019 02:01
cd to git root directory in bash
function cd-gitroot(){
cd $(git rev-parse --show-toplevel)
}
@tamuhey
tamuhey / peco-cd.ps1
Last active March 28, 2019 03:37
cd with peco for PowerShell
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 }
@tamuhey
tamuhey / touch.ps1
Created March 25, 2019 02:31
`touch` for Powershell
function touch(){ new-item $args[0] -itemtype file }