Skip to content

Instantly share code, notes, and snippets.

@3100
3100 / update_b2d.sh
Created April 12, 2014 12:26
Update boot2docker
#!/bin/sh
TARGET=boot2docker
if [ ! -e $TARGET ]; then
rm $TARGET
fi
curl https://raw.github.com/boot2docker/boot2docker/master/boot2docker > $TARGET
chmod +x $TARGET
@3100
3100 / yukkuri.coffee
Last active August 29, 2015 13:59
a hubot script which proxies our inner service
module.exports = (robot) ->
robot.respond /yukkuri (\S+)/i, (msg) ->
url = "http://xxxx.t.proxylocal.com/#{encodeURIComponent(msg.match[1])}"
getResult(msg, url)
getResult = (msg, url) ->
msg.http(url).get() (err, res, body) ->
if err
msg.send "something went wrong."
else
tenkiのpref番号
1,2,3,4 hokkaido
5 aomori
6 iwate
7 miyagi
8 akita
9 yamagata
10 fukusgima
11 ibaraki
12 tochigi
@3100
3100 / sample.lua
Last active August 29, 2015 14:01
turtle.forward()

全体

Let this long package float, 
Goto private class if short.
While protected with debugger case,  
Continue volatile interface.
Instanceof super synchronized throw, 
Extends final export throws.  
@3100
3100 / sample.R
Created August 21, 2014 15:01
how to test a R script
Combine <- function(df1, df2, fmt) {
# 同じサイズの2つの行列を用いて、各セル値を合成します。
#
# Args:
# df1: 行列1
# df2: 行列2
# fmt: 表示書式(sprintf)
#
# Returns:
# 合成した行列
@3100
3100 / install_packages.R
Last active August 29, 2015 14:05
Install all needed packages and load all in R
InstallPackages <- function(packages, repos) {
# インストールされていないパッケージをインストールします。
#
# Args:
# packages: 必要パッケージ一覧
new.packages <- packages[!(packages %in% installed.packages()[, "Package"])]
if(length(new.packages)) install.packages(new.packages, repos = repos)
for(package in packages) {
do.call("library", list(package = package))
}
@3100
3100 / run_test.R
Created August 28, 2014 04:20
run test of R code for dir
library(testthat)
(function(){
dir <- dirname(sys.frame(1)$ofile)
Test <- function(src.name) {
message(src.name)
source(paste(dir, '/', src.name, sep = ''))
test_file(paste(dir, '/test_', src.name, sep = ''))
}
# HACK
src.names <- grep('^(?!test|run_test).+$',
@3100
3100 / gist:feda22d6bd5ea565aea2
Created January 27, 2015 07:46
docker build error
Step 12 : RUN /etc/init.d/sshd start;/etc/init.d/sshd stop
---> Running in 88e8c405c1eb
/bin/sh: /etc/init.d/sshd: No such file or directory
/bin/sh: /etc/init.d/sshd: No such file or directory
INFO[0001] The command [/bin/sh -c /etc/init.d/sshd start;/etc/init.d/sshd stop] returned a non-zero code: 127
@3100
3100 / pca.py
Last active August 29, 2015 14:14
主成分分析でn次元に縮小させた結果から画像を復元してみる
from sklearn.decomposition import PCA
from PIL import Image
import numpy as np
import scipy as sp
if __name__ == '__main__':
# 画像ファイル名に変えてください
filePath = 'gs.jpg'
# 試行するnの組(画像ピクセルサイズの最大数を超えないこと)
ns = [1,2,5,10,50,100,250]