Skip to content

Instantly share code, notes, and snippets.

@disktnk
disktnk / gist:4104284
Created November 18, 2012 08:44
Mac(OSX)で.bashrcを編集する

Application > Terminalを起動したとき,環境変数の追加その他もろもろを自動でやってほしいとき,.bashrcを編集すればよい.

初期状態では,ホームディレクトリに.bashrcファイルはないので,自分で作成する.

cd ~
vi .bashrc

例えばPATHに何かを追加したいときは,以下を足して保存.

@disktnk
disktnk / Pair.java
Last active September 12, 2020 12:05
C++の標準ライブラリにあるPairみたいなやつ. javadocに書いてある通り,StackOverflowにあったコードほぼママ. What is the equivalent of the C++ Pair<L,R> in Java? - Stack Overflow http://stackoverflow.com/questions/156275/what-is-the-equivalent-of-the-c-pairl-r-in-java
/**
* immutable pair class, like c++'s Pair<br>
* from <a href=
* "http://stackoverflow.com/questions/156275/what-is-the-equivalent-of-the-c-pairl-r-in-java"
* > What is the equivalent of the C++ Pair&lt;L,R&gt; in Java? - Stack Overflow </a>
*
* @param <A>
* first
* @param <B>
* second
@disktnk
disktnk / test.py
Created July 24, 2020 08:12
generate function during executing
def dynamic_generated_fn():
created_fns = {}
fn_code = """def {name}(x):
return x + '_called_by_{name}'"""
fn_name1 = 'foo'
fn_name2 = 'bar'
# This is the custom theme template for gitprompt.sh
override_git_prompt_colors() {
GIT_PROMPT_THEME_NAME="Custom"
GIT_PROMPT_START_USER="${BoldCyan}${USER}@${HOSTNAME%%.*} ${ResetColor}_LAST_COMMAND_INDICATOR_ ${ResetColor}${Yellow}${PathShort}${ResetColor}"
GIT_PROMPT_START_ROOT="${GIT_PROMPT_START_USER}"
}
@disktnk
disktnk / test_bn_rtcheck.py
Created February 20, 2019 03:47
`pytest`
def test_bn_onnxruntime():
import numpy as np
import onnx
# this code is from ONNX BatchNomalization example
# https://github.com/onnx/onnx/blob/master/onnx/backend/test/case/node/batchnorm.py
def _batchnorm_test_mode(x, s, bias, mean, var, epsilon=1e-5): # type: ignore
dims_x = len(x.shape)
dim_ones = (1,) * (dims_x - 2)
s = s.reshape(-1, *dim_ones)
bias = bias.reshape(-1, *dim_ones)
class Database(object):
def dump(self, url):
import sqlite3
db = sqlite3.connect(url)
script = '\n'.join(db.iterdump())
with open('test.sql', 'w') as f:
f.write(script)
db.close()
set -g prefix 'C-\'
unbind C-b
# enable mouse operation
set-option -g mouse on
# enable copy mode when scroll-up
bind-key -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'select-pane -t=; copy-mode -e; send-keys -M'"
# unable coy mode on end of scroll
bind-key -n WheelDownPane select-pane -t= \; send-keys -M
@disktnk
disktnk / private.xml
Created December 28, 2016 07:12
for Karabiner
<?xml version="1.0"?>
<root>
<item>
<name>Remap cursor keys</name>
<identifier>private.remap.cursor_keys</identifier>
<autogen>__KeyToKey__ KeyCode::HOME, KeyCode::CURSOR_LEFT</autogen>
<autogen>__KeyToKey__ KeyCode::CURSOR_LEFT, KeyCode::CURSOR_DOWN</autogen>
<autogen>__KeyToKey__ KeyCode::CURSOR_DOWN, KeyCode::CURSOR_UP</autogen>
<autogen>__KeyToKey__ KeyCode::CURSOR_UP, KeyCode::HOME</autogen>
</item>
@disktnk
disktnk / Makefile
Created September 29, 2016 14:54
ref: みんなのGO言語
# meta info
NAME := myproj
VERSION := $(shell git describe --tags --abbrev=0)
REVISION := $(shell git rev-parse --short HEAD)
LDFLAGS := -X 'main.version=$(VERSION)' \
-X 'main.revision=$(REVISION)'
# setup required tools
## Setup
setup: