Skip to content

Instantly share code, notes, and snippets.

@oshiro-kazuma
oshiro-kazuma / SimpleTemplateEngine.php
Created March 23, 2017 08:05
SimpleTemplateEngine
<?php
/**
* Class SimpleTemplateEngine
*
* 変数展開ができるだけのテンプレートエンジン
*
* ex)
* SimpleTemplateEngine::apply('こんにちは{{ name }}さん', ['name' => '大城']);
* >> こんにちは大城さん。
@oshiro-kazuma
oshiro-kazuma / jenkins_2_insta.sh
Last active October 12, 2016 07:28
jenkins をamazon linux にインストール
# install
sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
sudo rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key
sudo yum install jenkins
sudo service jenkins start
curl localhost:8080
# default password
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8">
</head>
<body>
developer consoleを確認
<!-- 共通ライブラリ的なところに -->
<script type="text/javascript">
@oshiro-kazuma
oshiro-kazuma / add_config.sh
Created June 30, 2016 02:35
マージ済みのbranchを削除
cat << 'EOF' >> ~/.gitconfig
[alias]
delete-merged-branch = "!f () { git checkout $1; git branch --merged|egrep -v '\\*|develop|master'|xargs git branch -d; };f"
EOF
@oshiro-kazuma
oshiro-kazuma / io.hs
Created December 6, 2014 04:32
IOモナる
main = do
putStrLn "Hello, what's your name?"
name <- getLine
putStrLn ("Hello, " ++ name ++ "!")
@oshiro-kazuma
oshiro-kazuma / flyway.sh
Last active August 29, 2015 14:10
flywayに設定をコマンドラインから渡すぱてぃーん
sbt -Dflyway.url=jdbc:mysql://localhost/test_db flywayMigrate
@oshiro-kazuma
oshiro-kazuma / rec.scala
Last active August 29, 2015 14:10
scalaで末尾再帰処理
// 自分の中でこれはイディオムとしてfixした
def rec(x: String, xs: Seq[String]): String = {
xs match {
case Seq() => x
case Seq(y, ys@_*) =>
rec(s"$x:$y", ys)
}
}
//scala> rec("start", List("1","2","3"))
//res1: String = start:1:2:3
@oshiro-kazuma
oshiro-kazuma / test.sh
Created December 3, 2014 10:22
berkshelf を入れなおすとき
rm Berksfile.lock berks-cookbooks/ -rf
@oshiro-kazuma
oshiro-kazuma / bash.sh
Last active August 29, 2015 14:10
vagrant コマンド
# 一覧を出すとき
vagrant box list
# 消すとき
vagrant box remove chef/centos-6.5
# plugin のリスト
vagrant plugin list
@oshiro-kazuma
oshiro-kazuma / すごい・・・.sql
Last active August 29, 2015 14:09
一瞬にして1億データ作っちゃいますよ
mysql> insert into uid_unq (select null, "a", "a", "a" from testdata, testdata t2, testdata t3, testdata t4, testdata t5, testdata t6, testdata t7);
Query OK, 10000000 rows affected (22.80 sec)
Records: 10000000 Duplicates: 0 Warnings: 0
mysql> insert into user_attribute(select 1001, account_id, "charge_ammount", FLOOR(1 + RAND() * 9000) from uid_unq );
mysql> insert into user_attribute(select 1001, account_id, "key2", FLOOR(1 + RAND() * 9000) from uid_unq );
mysql> insert into user_attribute(select 1001, account_id, "key3", FLOOR(1 + RAND() * 9000) from uid_unq );
mysql> insert into user_attribute(select 1001, account_id, "key4", FLOOR(1 + RAND() * 9000) from uid_unq );
mysql> insert into user_attribute(select 1001, account_id, "key5", FLOOR(1 + RAND() * 9000) from uid_unq );
mysql> insert into user_attribute(select 1001, account_id, "key6", FLOOR(1 + RAND() * 9000) from uid_unq );