Skip to content

Instantly share code, notes, and snippets.

javascript: (function () {
var TIMER_INPUT_DESCRIPTION = 'Enter a timer.\nex)\n "30" -> 30sec\n "01:20" -> 1min20sec\n "3m" -> 3min';
var END_MESSAGE = 'TIMEUP!!';
var inputSec = function() {
var input = window.prompt(TIMER_INPUT_DESCRIPTION, '60');
if(input.indexOf(':') != -1) {
var a = input.split(':');
return parseInt(a[0], 10) * 60 + parseInt(a[1], 10);
} else if(input.indexOf('m') != -1) {
@naosim
naosim / crontab_for_selenium
Created March 24, 2014 16:53
seleniumのプログラムをcrontabから実行する
* * * * * export DISPLAY=:0 && /bin/bash -lc /home/path/to/program/hoge.sh
@naosim
naosim / create-enchant.sh
Created March 25, 2014 06:13
enchantの初期状態をサクっと作るスクリプト (プロジェクトテンプレート)
mkdir js css img
echo "download image"
cd img
curl -s -f -L https://raw.github.com/uei/enchant.js-builds/master/images/chara1.png -O
cd ..
echo "download enchant.js"
cd js
curl -s -f -L https://raw.github.com/uei/enchant.js-builds/master/build/enchant.min.js -O
@naosim
naosim / make_link.txt
Created April 26, 2014 12:50
シンボリックリンクの作成
@naosim
naosim / about_express
Created June 11, 2014 14:53
expressっぽくうごくやつ
var URLMacher = (function() {
function URLMacher() {
this.map = {};
}
URLMacher.prototype.put = function(str, obj) {
this.map[str] = obj;
};
URLMacher.prototype.get = function(url) {
for(var key in this.map) {
@naosim
naosim / PullreqBookmarklet.txt
Last active August 29, 2015 14:03
プルリクをメッセンジャー等に知らせるときに便利なブックマークレットです。
javascript:alert('プルリクしました\n' + document.title.substr(0, document.title.indexOf(' · Pull Request')) + '\n' + location.href);
@naosim
naosim / replace.js
Created July 13, 2014 00:39
全置換
String.prototype.replaceAll = function(before, after){
return this.split(before).join(after);
};
@naosim
naosim / server_controll.md
Last active August 29, 2015 14:05
サーバアプリの起動/停止

#起動

  • ログアウト後も動き続けるように nohupを付ける
  • バックグラウンドで動作するようにコマンドの最後に & をつける
  • 例: nohup node app.js &

#停止

  • ps aux でプロセスIDを調べる
  • kill -9 [ProcessID] で停止
@naosim
naosim / nginx_memo.md
Created October 6, 2014 02:05
Nginxメモ

ディレクトリ

  • 設定系 /etc/nginx
  • index.html /usr/share/nginx/www/
  • log /var/log/nginx

意味

  • sites-enabled
    • 読み込まれる設定ファイル
    • 実態はsites-availableへのリンク
  • リンクを切り替える感じで管理する
@naosim
naosim / gitci.js
Created October 13, 2014 22:16
node製簡易CI環境です。定期的にgitのアップデートを確認して、任意のスクリプトを実行できます。
/*
実行例
node gitci.js -i 10 deploy.sh
引数
-i: interval[分] デフォルト5分
最終引数: アップデートがあった場合に実行するコマンド
*/
// 引数取得
var shFile = process.argv[process.argv.length - 1];