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 / test.ipynb
Last active August 26, 2018 04:46
test
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tamuhey
tamuhey / jupyter_shortcuts.md
Created September 26, 2018 13:16 — forked from kidpixo/jupyter_shortcuts.md
Keyboard shortcuts for ipython notebook 3.1.0 / jupyter

Toc

Keyboard shortcuts

The IPython Notebook has two different keyboard input modes. Edit mode allows you to type code/text into a cell and is indicated by a green cell border. Command mode binds the keyboard to notebook level actions and is indicated by a grey cell border.

MacOS modifier keys:

  • ⌘ : Command
@tamuhey
tamuhey / file0.txt
Last active May 12, 2022 16:30
シンプルな第一原理計算(密度汎関数法)の Python コードを書く ref: https://qiita.com/tamurahey/items/9ac3ca91923d2834c7e0
n_grid = 200
x = np.linspace(-5, 5, n_grid)
h = x[1] - x[0]
D = -np.eye(n_grid) + np.diagflat(np.ones(n_grid-1), 1)
D /= h
@tamuhey
tamuhey / file0.txt
Last active December 19, 2018 13:59
量子アニーリングで数独を解く ref: https://qiita.com/tamurahey/items/b0e919071e7e19acd494
pip install dwave-qbsolv
@tamuhey
tamuhey / file0.txt
Last active February 21, 2020 12:11
量子アニーリングで数独を解く ref: https://qiita.com/tamurahey/items/105f1dc9ee9a3bc01f15
pip install dwave-qbsolv
@tamuhey
tamuhey / pytorch_earlystop.py
Created December 26, 2018 02:27
Pytorch Early Stop Class
import torch as to
import torch.nn as nn
class EarlyStop:
"""Check early stop, and save best params
Examples:
>>> e=EarlyStop(10)
@tamuhey
tamuhey / random_seq_generator.py
Created January 6, 2019 08:35
Random sequence generator in Python
def random_generator(step=None):
step = step or random.randint(1e4, 1e5)
for c in count():
for i in random.sample(range(c*step, (c+1)*step), step):
yield i
@tamuhey
tamuhey / sudo.ps1
Created March 24, 2019 07:56
Sudo for Powershell
function sudo()
{
if ($args.Length -eq 1)
{
start-process $args[0] -verb runAs
}
if ($args.Length -gt 1)
{
start-process $args[0] -Args "-executionpolicy bypass -command Set-Location \`"$PWD\`"; $($args[1..$args.Length])" -verb runAs
}
@tamuhey
tamuhey / touch.ps1
Created March 25, 2019 02:31
`touch` for Powershell
function touch(){ new-item $args[0] -itemtype file }
@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 }