Skip to content

Instantly share code, notes, and snippets.

View ikuyamada's full-sized avatar

Ikuya Yamada ikuyamada

View GitHub Profile
@ikuyamada
ikuyamada / .vimrc
Created June 30, 2011 12:41
my vimrc
syntax on
filetype plugin on
set nocompatible
set viminfo+=!
set autoindent
set smartindent
set expandtab
set smarttab
set tabstop=4
@ikuyamada
ikuyamada / .gvimrc
Created June 30, 2011 12:47
my gvimrc
nnoremap <Tab> :BufExplorer<CR>
defaults write org.vim.MacVim MMZoomBoth -boolean YES
colorscheme xoria256
set guioptions-=T
set transparency=5
set lines=50
set columns=150
set guifont=Monaco:h13
set clipboard+=unnamed
@ikuyamada
ikuyamada / .zshrc
Created June 30, 2011 13:02
my zshrc
export LANG=ja_JP.UTF-8
export MAILCHECK=0
export EDITOR=vim
HISTFILE=$HOME/.zsh-history
HISTSIZE=3000
SAVEHIST=3000
PROMPT="%B%n@%m%%%b "
RPROMPT="%B[%~]%b"
@ikuyamada
ikuyamada / urlreader app.js
Created July 4, 2011 01:59
app.js of urlreader
var TWITTER_USER_NAME = 'ikuyamada';
function processTweets(data) {
var urls = [];
for (var i = 0; i < data.length; i++) {
var ret = data[i].text.match(/https?:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+/);
if (ret)
urls = urls.concat(ret);
}
showUrlList(urls);
@ikuyamada
ikuyamada / unordered_map.pxd
Created August 5, 2012 15:06
Cython wrapper for std::unordered_map
from libcpp.utility cimport pair
cdef extern from "<tr1/unordered_map>" namespace "std::tr1":
cdef cppclass unordered_map[T, U]:
cppclass iterator:
pair[T, U]& operator*() nogil
iterator operator++() nogil
iterator operator--() nogil
bint operator==(iterator) nogil
bint operator!=(iterator) nogil
@ikuyamada
ikuyamada / iterm_ssh_new_window.zsh
Created June 18, 2013 06:32
A short zshrc snippet that creates new tab on executing ssh in iTerm 2
ITERM_SESSION_NAME=Default
if [ $TERM_PROGRAM = "iTerm.app" ]; then
function new_tab() {
osascript\
-e "tell application \"iTerm\""\
-e "tell the first terminal"\
-e "launch session \"${ITERM_SESSION_NAME}\""\
-e "tell the current session"\
-e "write text \"$1\""\
@ikuyamada
ikuyamada / mongo_cache.py
Last active September 21, 2023 12:01
A Python decorator that caches the result of a function on MongoDB
# -*- coding: utf-8 -*-
import base64
import cPickle as pickle
import hashlib
from functools import wraps
class NoopSerializer(object):
def serialize(self, obj):
@ikuyamada
ikuyamada / imap_lazy.py
Created July 19, 2014 06:19
multiprocessing's imap() wrapper that lazily creates chunks
from multiprocessing import Pool
from itertools import islice
def imap_lazy(func, iterable, pool_size=10, chunk_size=10000,
maxtasksperchild=1000, unordered=False):
p = Pool(processes=pool_size, maxtasksperchild=maxtasksperchild)
while True:
chunk = list(islice(iterable, chunk_size))
if not chunk:
@ikuyamada
ikuyamada / ec2_spot_price_list.py
Last active October 6, 2019 09:24
Display the price summary of AWS EC2's spot instances across all regions and availability zones
#!/usr/bin/env python
"""
ec2_spot_price_list.py - Display the price summary of AWS EC2's spot instances across all regions
and availability zones.
Basic usage:
$ pip install numpy click boto3
$ python ec2_spot_price_list.py --instance-type m5.xlarge --product-description "Linux/UNIX (Amazon VPC)"
Copyright (C) 2019, Ikuya Yamada
import torch
import deepspeed
from transformers import BertLayer, BertConfig
hf_config = BertConfig()
hf_layer = BertLayer(hf_config)
hf_layer.eval().to("cuda")
ds_config = deepspeed.DeepSpeedTransformerConfig(
batch_size=16,