This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - yum: | |
| name: perl-App-cpanminus | |
| - cpanm: | |
| name: "{{ item }}" | |
| with_items: | |
| - "Sys::Syslog" | |
| - "DateTime" | |
| - "LWP::Protocol::https" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * 複数のHTTPリクエストをノンブロッキングで多重化する | |
| * Stream 抽象化版 | |
| * Streamクラスは `read()` メソッドが呼ばれるたびにソケットからデータを読み込む | |
| * 読み込むデータがなくなったら `closed = true` に設定する。 | |
| * | |
| * Looper クラスは全ての Stream が `closed = true` の状態になるまで `read()` を実行し続ける | |
| * 全ての Stream が `closed` になったら全てのデータ読み込みが完了したことになるので終了する。 | |
| * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * 複数のHTTPリクエストをノンブロッキングで多重化する | |
| * fsockopen()版 | |
| * | |
| * $blocking = true を設定すると順に処理される | |
| * $blocking = false を設定すると準備できている $sock から処理される | |
| */ | |
| $blocking = false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| snippet laravel-mutator-enum | |
| public function set${1:CamelCase}Attribute($${2:camelCase}) | |
| { | |
| if (!is_null($$2)) { | |
| $this->attributes['${3:snake_case}'] = $$2->id; | |
| } else { | |
| $this->attributes['$3'] = null; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Bad. IE POSTs the form twice | |
| <button class="btn btn-primary" onclick="if(window.confirm('よろしいですか?')){$(this).parent().submit();}else{return false;}">Go</button> | |
| // Good | |
| <button class="btn btn-primary" onclick="return confirm('よろしいですか?')">Go</button> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| " Indent multiline /* comments correctly {{{ | |
| " UltiSnipsとの組合せでPHPの複数行コメントのインデントが壊れる問題の修正 | |
| " snippetを展開するとコメントの中にいることがわからないので再チェックしてフラグをOnにする | |
| if last_line =~ '^\s*/\*' | |
| echo "In multiline comment!" | |
| let b:PHP_InsideMultilineComment = 1 | |
| endif | |
| " ------------------------------------------------------------ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function get_pid() { | |
| if [ ! -e $PID ] | |
| then | |
| echo -1 | |
| return | |
| fi | |
| if [ $(pgrep -F $PID | wc -l) -eq 0 ] | |
| then | |
| rm -f "$PID" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /var/www/webapp/shared/storage/logs/*.log { | |
| missingok | |
| notifempty | |
| nocompress | |
| daily | |
| rotate 5 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| task('logrotate:link', function () { | |
| run('sudo ln -fs {{ current_path }}/etc/logrotate.conf /etc/logrotate.d/AppName'); | |
| }); | |
| // Create a symlink to rotate laravel logs. | |
| on(host('stage'), function ($host) { | |
| after('deploy:symlink', 'logrotate:link'); | |
| }); |