Skip to content

Instantly share code, notes, and snippets.

View shinpei's full-sized avatar
🏠
Working from home

Shinpei shinpei

🏠
Working from home
View GitHub Profile
@shinpei
shinpei / .zshrc
Last active January 22, 2019 03:26
fzf-gcloud
# fzf gcloud
function fzf-gconf() {
local proj=$(gcloud config configurations list | grep -v NAME | fzf --query "$LBUFFER")
if [ -n "$proj" ]; then
local cnf=$(echo ${proj} | awk '{print $1;}')
BUFFER="gcloud config configurations activate ${cnf}"
zle accept-line
fi
zle reset-prompt
}
import math; print map(lambda m: int(math.log(m, 2)), map(lambda n : int(n), raw_input().split()))
@shinpei
shinpei / loan.py
Last active July 26, 2018 07:50
calculate mortgage loan
years=25
amount = 45000000
bonus=300000
yearlyPay= 120000
def yearPay():
pay = 0
pay += bonus * 2
pay += yearlyPay * 12
@shinpei
shinpei / gist:64164da2d685278715cf
Created March 9, 2015 02:55
Move cassandra column timestamp forward to the future.
import pycassa;
import time;
pool = pycassa.ConnectionPool('keyspace')
cf = pycassa.ColumnFamily(pool, 'columnfamily')
rowKey = "row"
print cf.get(rowKey)
cf.insert(rowKey, {"detail_info":"future"}, time.time()*1000)
print cf.get(rowKey)
stack cat main.go
package stack
type stack struct {
head int
values []int
}
type Stack interface {
Push(int)
Pop() int