Skip to content

Instantly share code, notes, and snippets.

@miyakogi
miyakogi / nim.snip
Created January 13, 2015 11:13
Nim's Snippet file for neosnippet
snippet import
alias imp
abbr import ...
options head
import ${0:#:module}
snippet from
abbr from ... import ...
options head
from ${1:#:package} import ${0:#:module}
@miyakogi
miyakogi / gist:90a99a11aac0515c99fd
Created January 17, 2015 13:56
pathlib.Path.relative_to
from os import path
print(path.relpath('/a/b', '/a')) # >>> b
print(path.relpath('/a', '/a/b')) # >>> ..
from pathlib import Path
a = Path('/a')
b = Path('/a/b')
print(b.relative_to(a)) # >>> b
@miyakogi
miyakogi / gist:8049fb85889a9e7aae9a
Created January 22, 2015 07:56
Benchmark (フィボナッチ数列42まで)
#!/usr/bin/env bash
remove() {
if [ -e $1 ]; then
rm -rf $1
fi
}
remove c
echo "c (not optimized) compile"
@miyakogi
miyakogi / test29.failed
Created January 29, 2015 03:29
vim-jp issue #693 1
asdfasdf. asdf
asdfasdf. asdf
asdfasdf. asdf
asdfasdf. asdf
asdfasdf. asdf
asdfasdf. asdf
asdfasdf. asdf
asdfasdf asdf
asdfasdf asdf
asdfasdf asdf
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from os import path, environ
from subprocess import check_output, call
from shlex import split
from codecs import open
home_dir = environ['HOME']
python_path = u'''
@miyakogi
miyakogi / compile.sh
Created March 5, 2015 03:54
Nim で DOM をさわる
nim js -o:hellonim.js hellonim.nim
@miyakogi
miyakogi / gist:6d41191246729d89a602
Created March 28, 2015 11:36
Pythonでディレクトリ中のファイルを全て別のディレクトリにSymlinkを辿ってコピー
#!/usr/bin/env python3
import os
import shutil
# コピーしたいディレクトリにいること
# os.getcwd() とか ipythonからならpwdでパス確認できる
# 違うディレクトリにいたら移動するなりソース修正するなり
dstdir = 'コピー先のディレクトリのフルパス'
files = os.listdir()
num_files = len(files) # 進捗表示用
@miyakogi
miyakogi / config.md
Last active July 1, 2025 08:25
JSON, YAML, ini, TOML ざっくり比較
if executable('fcitx-remote')
autocmd InsertLeave * call system('fcitx-remote -c')
else
autocmd InsertLeave * set iminsert=0
endif
@miyakogi
miyakogi / pacth.patch
Last active January 31, 2016 04:19
Jedi's patch to support type hints in python3
diff --git a/jedi/parser/grammar3.4.txt b/jedi/parser/grammar3.4.txt
index d4a32b8..45f733f 100644
--- a/jedi/parser/grammar3.4.txt
+++ b/jedi/parser/grammar3.4.txt
@@ -27,7 +27,8 @@ parameters: '(' [typedargslist] ')'
typedargslist: (tfpdef ['=' test] (',' tfpdef ['=' test])* [','
['*' [tfpdef] (',' tfpdef ['=' test])* [',' '**' tfpdef] | '**' tfpdef]]
| '*' [tfpdef] (',' tfpdef ['=' test])* [',' '**' tfpdef] | '**' tfpdef)
-tfpdef: NAME [':' test]
+tname: NAME [':' test]