Skip to content

Instantly share code, notes, and snippets.

@tomoyamkung
tomoyamkung / xxx
Created August 10, 2022 03:33
xxx
‎‎​
@tomoyamkung
tomoyamkung / xxx.sh
Created July 9, 2016 03:01
ヒアドキュメントを使ってファイルに追記する
#!/bin/bash
cat << EOS >> ~/hoge
line: 1
line: 2
line: 3
EOS
@tomoyamkung
tomoyamkung / xxx.sh
Created July 9, 2016 02:55
実行中のスクリプトが保存されているディレクトリに移動する
#!/bin/bash
# このスクリプトが保存されているディレクトリに移動する
cd `dirname $0`
@tomoyamkung
tomoyamkung / installed_command.sh
Last active July 9, 2016 02:46
コマンドがインストールされているかを確認するスクリプト。 `which` を使って指定されたコマンドがシステムに存在するかを確認するスクリプトと、そのユニットテストを作成。
function installed_command() {
which $1 > /dev/null 2>&1
}
@tomoyamkung
tomoyamkung / 0_reuse_code.js
Created July 9, 2016 02:02
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@tomoyamkung
tomoyamkung / unittest-template.xml
Last active October 13, 2015 15:12
[Eclipse,JUnit]JUnit のテストメソッド作成テンプレート
<?xml version="1.0" encoding="UTF-8" standalone="no"?><templates><template autoinsert="true" context="java-members" deleted="false" description="" enabled="true" name="test_abnormal">@${testType:newType(org.junit.Test)}
public void 異常系_${testName}() throws Exception {
${staticImport:importStatic('org.junit.Assert.*')}${cursor}// setup
// exercise
// verify
}</template><template autoinsert="true" context="java-members" deleted="false" description="" enabled="true" name="test_normal">@${testType:newType(org.junit.Test)}
public void 正常系_${testName}() throws Exception {
${staticImport:importStatic('org.junit.Assert.*')}${cursor}// setup
// exercise
// verify
@tomoyamkung
tomoyamkung / countup.sh
Created December 6, 2013 02:54
[Shell]1 から 255 までカウントするスニペット。こういうのはちょっと応用が効くのでメモしておく。
#!/bin/sh
COUNT=1
MAX_COUNT=256
while [ $COUNT -lt $MAX_COUNT ]
do
echo "$COUNT"
COUNT=`expr $COUNT + 1`
done
@tomoyamkung
tomoyamkung / showxhrerrormessage.js
Created November 21, 2013 02:26
[JavaScript]Ajax 通信処理で失敗した responseText をログ出力する。
/**
* Ajax 通信処理で失敗した responseText をログ出力する。
*
* responseText には次の形式の JSON が設定されている想定。
*
* {
* "errors" : [
* エラーメッセージ1,
* エラーメッセージ2,
* エラーメッセージ3
@tomoyamkung
tomoyamkung / toggleclass.js
Last active December 28, 2015 20:48
[JavaScript]タグに定義されている class を切り替える。 `isNullOrEmpty` は [[JavaScript]文字列が Null かブランクであるかを問い合わせる。](https://gist.github.com/tomoyamkung/7559383) で取り上げたスニペット。
/**
* タグに定義されている class を切り替える。
*
* to が定義されていない、もしくはブランクの場合は from の class を取り除く。
*
* @param {String} id 切り替える class が定義されているタグの ID 属性
* @param {String} from 切り替え対象の class
* @param {String} to 切り替える class
* @returns {}
*/
@tomoyamkung
tomoyamkung / isnullorempty.js
Last active December 28, 2015 20:39
[JavaScript]文字列が Null かブランクであるかを問い合わせる。
/**
* 文字列が Null かブランクであるかを問い合わせる。
*
* @param {String} value 検査する文字列
* @returns {Boolean} 条件を満たしている場合 true
*/
function isNullOrEmpty(value) {
return typeof value === "undefined" || value.length === 0;
}