Skip to content

Instantly share code, notes, and snippets.

@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];
@naosim
naosim / ftpup.sh
Created October 13, 2014 22:19
FTPでファイルをアップするスクリプトです。
#!/bin/sh
SERVER=$1
USER=$2
PASS=$3
DIR=$4
FILE=$5
ftp -n <<END
open $SERVER
@naosim
naosim / killpmaker.js
Last active August 29, 2015 14:08
create kill process sh file
/**
create kill process sh file.
Usage:
require('./killpmaker.js')('stop.sh');
=> create stop.sh
*/
var fs = require('fs');
module.exports = function(file) {
fs.writeFileSync(file, 'kill -9 ' + process.pid);
@naosim
naosim / jsoncheck.js
Last active February 6, 2021 15:36
JSONファイルをチェックする (node.js)
/**
* JSONファイルをチェックする (node.js)
* 使い方
* - このファイルを任意の場所に置く
* 例: ~/jsoncheck.js
* - jsonファイルのパスをpipeで渡して実行する
* 例: $ find . -name "*.json"|node ~/jsoncheck.js
* - エラーがあればコンソールに表示され、exit(1)を返す。
*/
/* jslint node: true */
@naosim
naosim / git_revert_file.txt
Created December 28, 2014 02:48
gitの変更の取り消し
git checkout -- hoge.txt
git fetch
current=`git log --oneline master -1`
origin=`git log --oneline origin/master -1`
if [ "$current" = "$origin" ] ; then
exit 0
fi
# do something...