Skip to content

Instantly share code, notes, and snippets.

// JSでN個の非同期処理を同期的に実行したい場合の例。
// 1つめの非同期処理が終わったら2つ目に。2つ目が終わったら3つ目に。そして、いくつあるかは場合による。という状況。
var functions = [
function () {
var deferred = Q.defer();
// 何らかの処理。遅延してdeferred.resolve()される。
return deferred.promise;
@mamor
mamor / supervisord
Created October 11, 2014 06:12
init script for supervisord
#!/bin/sh
#
# /etc/rc.d/init.d/supervisord
# sudo chkconfig --add supervisord
# sudo chkconfig --level 35 supervisord on
#
# chkconfig: - 64 36
# description: Supervisor Server
# processname: supervisord
@mamor
mamor / gist:a346faf7e0370fcce6fa
Created October 11, 2014 06:11
init script for supervisord
#!/bin/sh
#
# /etc/rc.d/init.d/supervisord
# sudo chkconfig --add supervisord
# sudo chkconfig --level 35 supervisord on
#
# chkconfig: - 64 36
# description: Supervisor Server
# processname: supervisord
@mamor
mamor / trailing-slash in URLs on Laravel
Last active August 29, 2015 14:05
trailing-slash in URLs on Laravel
diff --git a/app/config/app.php b/app/config/app.php
index 10ae94b..f7a798f 100644
--- a/app/config/app.php
+++ b/app/config/app.php
@@ -121,6 +121,7 @@ return array(
'Illuminate\Validation\ValidationServiceProvider',
'Illuminate\View\ViewServiceProvider',
'Illuminate\Workbench\WorkbenchServiceProvider',
+ 'App\ServiceProvider',
@mamor
mamor / gist:fac1e1c75e3e0bcc2f9b
Created May 29, 2014 12:34
example-for-pre-commit
#!/usr/bin/php
<?php
// @see https://gist.github.com/raphaelstolt/588697
printf("%sGit pre-commit hook %1\$s", PHP_EOL);
putenv('PATH=/usr/local/bin');
$projectRoot = getcwd();
$projectName = basename($projectRoot);
$run = function ($projectName, $command) {
#!/bin/bash
# Installation:
# 1. Save this script to /some/bin/ssh-background
# 2. chmod 755 /some/bin/ssh-background
# 3. alias ssh=/some/bin/ssh-background
# 4. Configure your host colors below.
set_color() {
local HEX_FG=$1
local HEX_BG=$2
@mamor
mamor / gist:7615663
Last active December 29, 2015 04:29
knife-solo実行環境を用意するためのVagrantfileのdiff。/home/vagrant/.chef/knife.rbはtemplateで別途用意する必要がある。config.vm.synced_folderは設定する必要無いけど設定しない理由もないのでついでに。
diff --git a/Vagrantfile b/Vagrantfile
index 11320e1..6eee250 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -10,11 +10,11 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# please see the online documentation at vagrantup.com.
# Every Vagrant virtual environment requires a box to build off of.
- config.vm.box = "base"
+ config.vm.box = "ubuntu1304"
[ *.{rb,erb} ]
softTabs = true
tabSize = 2
@mamor
mamor / gist:5917446
Last active December 21, 2015 10:26
FuelPHPのORMで複数のorをつなげるサンプル
Model_Profile::query()
->and_where_open()->where('id', 'like', '%foo%')->or_where('user_id', 'like', '%foo%')->and_where_close()
->and_where_open()->where('id', 'like', '%bar%')->or_where('user_id', 'like', '%bar%')->and_where_close()
->get();
// WHERE (`t0`.`id` LIKE '%foo%' OR `t0`.`user_id` LIKE '%foo%') AND (`t0`.`id` LIKE '%bar%' OR `t0`.`user_id` LIKE '%bar%')
Model_Profile::find('all', array('where' => array(
// 当たり前だが'or'を複数指定しても最後のしか残らない
/**
* Log to chrome
*
* required Chrome Logger
* https://chrome.google.com/webstore/detail/chrome-logger/noaneddfkdjfnfdakjjmocngnfkfehhd
*
* @param mixed $message
* @param string $logger
* @return boolean
*/