Skip to content

Instantly share code, notes, and snippets.

View tkfm-yamaguchi's full-sized avatar

Takafumi Yamaguchi tkfm-yamaguchi

View GitHub Profile
@tkfm-yamaguchi
tkfm-yamaguchi / binize
Created January 6, 2016 05:05
create symlink in bin dir
#!/usr/bin/env python
import os, sys
import subprocess as sbp
target_paths = []
# Retrieve bin directory path
gopath = os.environ.get("GOPATH")
calcpi <- function(n = 10000) {
r <- 1
p <- cbind(runif(n, 0, r), runif(n, 0, r))
sq <- apply(p, c(1,2), function(x) x**2)
ss <- apply(sq, 1, sum)
sr <- sqrt(ss)
pin <- p[sr <= r,]
pout <- p[sr > r,]
@tkfm-yamaguchi
tkfm-yamaguchi / HEAD-request.py
Created January 5, 2016 03:00 — forked from FiloSottile/HEAD-request.py
How to send a HEAD HTTP request in Python with urllib2
import urllib2
class HeadRequest(urllib2.Request):
def get_method(self):
return "HEAD"
class HEADRedirectHandler(urllib2.HTTPRedirectHandler):
"""
Subclass the HTTPRedirectHandler to make it use our
HeadRequest also on the redirected URL
@tkfm-yamaguchi
tkfm-yamaguchi / fruit.rb
Last active September 11, 2015 14:37
Weird behavior when a property setting method called from a instance method
class Fruit
def set_apple1
name = "apple"
end
def set_apple2
self.name = "apple"
end
def name=(v)
@tkfm-yamaguchi
tkfm-yamaguchi / progress-archiving.sh
Created July 6, 2015 05:15
create archive file with showing progress dialog
# Needs pv & dialog
SRC="target_to_archive"
DEST= "archive_name"
(tar cf - ${SRC} | pv -n -s $(du -sb ${SRC} | awk '{print $1}') | gzip -9 > ${DEST}) 2>&1 | dialog --gauge 'Progress' 7 70
@tkfm-yamaguchi
tkfm-yamaguchi / vagrant.md
Created June 19, 2015 06:09
about vagrant

Vagrant

仮想マシンをコマンドラインから作成・開始・停止・削除出来たりする。 また Vagrant ファイルを作成することで、同じ開発環境を作成できる。 box という仕組みで仮想マシンファイルをやり取りできる。

仮想マシン作成後は、Chef や Ansible などのプロビジョニングツールで 開発システムの稼働環境を構築する機能が組み込まれている。

@tkfm-yamaguchi
tkfm-yamaguchi / Fabric.md
Last active August 29, 2015 14:23
about fabric

Fabric

Python 製のオーケストレーションツール。 リモートでのコマンド実行機能が標準で用意されている Rake みたいなイメージ。 てか、ローカルタスクの自動化用につかう方が便利そうな気がする。

cuisine

https://github.com/sebastien/cuisine

@tkfm-yamaguchi
tkfm-yamaguchi / test.hs
Created May 26, 2015 07:13
insert sort by haskell
-- My answer:
-- myinsert' l [] n = l ++ [n]
-- myinsert' l (x:r) n | n < x = l ++ [n, x] ++ r
-- | otherwise = myinsert' (l ++ [x]) r n
--
-- myinsert l n = myinsert' [] l n
--
-- mysort' [] sorted = sorted
-- mysort' (x:l) sorted = mysort' l (myinsert sorted x)
@tkfm-yamaguchi
tkfm-yamaguchi / msdn_kill_popup.user.js
Created April 30, 2015 02:34
kill annoying translation popup on msdn web sites
// ==UserScript==
// @name MSDN kill popup
// @namespace https://github.com/zeroyonichihachi
// @description Removes annoying popup
// @include http://msdn.microsoft.com/*
// @include http://msdn2.microsoft.com/*
// @include http://technet.microsoft.com/*
// ==/UserScript==
window.onload = function(hndl_e) {
@tkfm-yamaguchi
tkfm-yamaguchi / .vimrc
Created April 18, 2015 01:44
simple.vimrc
" coding: utf-8
set nocompatible
let s:vimrc_plugins = $HOME."/.vim/vimrc.plugins"
if filereadable(s:vimrc_plugins)
execute "source ".s:vimrc_plugins
endif