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 / 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 / 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 / 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 / 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 / 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"
}
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 / 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))
@tamuhey
tamuhey / parentheses.ipynb
Last active August 14, 2019 03:18
List of all unicode's parentheses
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tamuhey
tamuhey / setup.cfg
Last active October 13, 2019 11:49
minimal setup.cfg
[metadata]
name = {}
home-page = {}
long-description = file: README.md
[options]
zip_safe = false
include_package_data = true
python_requires = >=3.6
packages = {}
@tamuhey
tamuhey / combmod.hs
Last active September 8, 2019 16:47
import qualified Data.Vector.Unboxed as U
import Data.Vector.Unboxed ( (!) )
import qualified Data.Vector.Unboxed.Mutable as UM
import Control.Monad.ST
import Control.Monad
base = 10 ^ 9 + 7 :: Int
maxL = 3 * 10 ^ 5 :: Int
n *% m = (n * m) `mod` base