Skip to content

Instantly share code, notes, and snippets.

Daichi SUZUO belltailjp

Block or report user

Report or block belltailjp

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@belltailjp
belltailjp / toggle_zeal.sh
Last active Apr 8, 2019
Toggle Zeal window active
View toggle_zeal.sh
#!/bin/sh
# Launch zeal, and bring it to top screen
# If it is already on top, bring it to the back (toggle)
DEBUG=0
if [ ! -e /usr/bin/zeal ]; then
if [ $DEBUG ]; then
echo "Zeal not found in /usr/bin/zeal"
@belltailjp
belltailjp / db_insertion_benchmark_with_or_without_index.ipynb
Created Jan 22, 2019
Python+SQLite+Peewee Squeeze insertion performance challenge
View db_insertion_benchmark_with_or_without_index.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@belltailjp
belltailjp / cmdscale.py
Last active Jun 17, 2019
Multi-Dimensional Scaling (also as known as Principal Coordinate Analysis) by Python
View cmdscale.py
import matplotlib.pyplot as plt
import numpy as np
from sklearn import manifold
cities = "Athens Barcelona Brussels Calais Cherbourg Cologne Copenhagen Geneva Gibraltar Hamburg HookOfHolland Lisbon Lyons Madrid Marseilles Milan Munich Paris Rome Stockholm Vienna".split(" ")
d = np.array([
# from eurodist dataset: https://rstudio-pubs-static.s3.amazonaws.com/221886_5c57ad0f5ff546e8af6386162f29fabc.html
[ 0, 3313, 2963, 3175, 3339, 2762, 3276, 2610, 4485, 2977, 3030, 4532, 2753, 3949, 2865, 2282, 2179, 3000, 817, 3927, 1991],
[3313, 0, 1318, 1326, 1294, 1498, 2218, 803, 1172, 2018, 1490, 1305, 645, 636, 521, 1014, 1365, 1033, 1460, 2868, 1802],
[2963, 1318, 0, 204, 583, 206, 966, 677, 2256, 597, 172, 2084, 690, 1558, 1011, 925, 747, 285, 1511, 1616, 1175],
@belltailjp
belltailjp / cost_vgg.py
Last active Oct 17, 2018
chainer_computational_cost (used from a blog post in daily.belltail.jp)
View cost_vgg.py
import chainer
import chainer.links as L
import numpy as np
import chainer_computational_cost as c3
net = L.VGG16Layers()
x = np.random.random((1, 3, 224, 224)).astype(np.float32) # dummy input
with chainer.no_backprop_mode(), chainer.using_config('train', False):
with c3.ComputationalCostHook(fma_1flop=True) as cch:
y = net(x)
@belltailjp
belltailjp / .zshrc
Created Feb 12, 2018
Force naming tmux session
View .zshrc
if [ ! -z $TMUX ]; then
tmux show-options | grep "TMUX_NO_FORCE_NAME_SESSION" > /dev/null
if [ $? -ne 0 ]; then
SESSION_NAME=`tmux display-message -p '#S'`
echo $SESSION_NAME | grep "^[0-9]\+$" > /dev/null
if [ $? -eq 0 ]; then # Not named
/bin/echo -n "tmux session name: "
read NAME
if [ ! -z $NAME ]; then
tmux rename-session $NAME
@belltailjp
belltailjp / optional.cpp
Created Dec 26, 2017
Just a confirm of whether all the information of optional is preserved or not after memory bytes copy
View optional.cpp
#include <iostream>
#include <experimental/optional>
int main()
{
std::experimental::optional<int> t;
//t = 100; // comment in/out
unsigned char *p = new unsigned char[sizeof(t)];
@belltailjp
belltailjp / prepare.sh
Last active Nov 1, 2017
chainer.links.ResNetXXLayers inaccurateness minimum reproduction code (Python 3.6, Chainer 3.0, CUDA8.0, cuDNN7) written for https://github.com/chainer/chainer/issues/3756
View prepare.sh
#!/bin/sh
wget http://www.image-net.org/challenges/LSVRC/2012/nnoupb/ILSVRC2012_img_val.tar
tar xf ILSVRC2012_img_val.tar
wget http://dl.caffe.berkeleyvision.org/caffe_ilsvrc12.tar.gz
tar xf caffe_ilsvrc12.tar.gz
@belltailjp
belltailjp / bench.py
Last active Oct 19, 2017
Draw 2D Gaussian Image using Cupy
View bench.py
import time
def measure_time_in_ms(func, n_times, size, sigma):
start = time.time()
for _ in range(n_times):
out = func(size, sigma)
assert(out.shape == (size, size))
elapsed_sec = time.time() - start
return elapsed_sec / n_times * 1000
View deploy.prototxt
input: "data"
input_dim: 1
input_dim: 3
input_dim: 368
input_dim: 368
layer {
name: "conv1_1"
type: "Convolution"
bottom: "data"
top: "conv1_1"
View process_safe_tqdm.py
import tqdm
import multiprocessing
class ProcessSafeTqdm(tqdm.tqdm):
def __init__(self, *args):
super(ProcessSafeTqdm, self).__init__(*args)
self.correct_count = multiprocessing.Value('i', 0)
def update(self, n=1):
with self.correct_count.get_lock():
You can’t perform that action at this time.