Skip to content

Instantly share code, notes, and snippets.

View horitaku1124's full-sized avatar

Horimatsu Takuya horitaku1124

  • Tokyo
View GitHub Profile
@horitaku1124
horitaku1124 / tips.js
Created April 21, 2013 12:10
JavaScriptの技
console.log(Math.random() * 10 | 0); // => 0 .. 9 in Integer
@horitaku1124
horitaku1124 / composer.js
Last active December 16, 2015 08:18
Formにデータを入れるためのjs
var list = document.getElementsByTagName("input");
var kv = {};
for(var i = 0;i < list.length;i++) {
var name = list[i].getAttribute("name")
kv[name] = "";
}
var json = JSON.stringify(kv).replace(/","/g,"\"\n ,\"").replace(/^\{/,"{\n ").replace(/\}$/, "\n}");
// データを入れる
@horitaku1124
horitaku1124 / echoip.sh
Created April 16, 2013 16:13
eth0のIPアドレスを表示
#!/bin/bash
ip=`ifconfig eth0 | sed -n "s/ *inet addr:\([0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\).*/\1/g p"`
echo ${ip}
@horitaku1124
horitaku1124 / commands2.sh
Created April 11, 2013 11:58
複数のコマンドを配列にして実行
#!/bin/bash
list=()
list+=("date '+%Y/%m/%d %H:%M:%S'")
list+=("date '+%Y-%m-%d %H:%M:%S'")
list+=("date '+%Y-%m-%d'")
for((i = 0; i < ${#list[@]}; i++))
do
echo ${list[$i]} | bash
@horitaku1124
horitaku1124 / commands.sh
Created April 11, 2013 10:52
コマンドを配列にして実行
#!/bin/bash
array=()
array+=(date)
array+=(ls)
array+=(pwd)
for e in ${array[@]}
do
echo ${e} | bash