Skip to content

Instantly share code, notes, and snippets.

View taiyoh's full-sized avatar
👶

taiyoh taiyoh

👶
View GitHub Profile
(function(global) {
var Sym = function Sym(path) {
var paths = path.split('/');
for (var i in paths) {
var m = /_(.+)\.php$/.exec(paths[1]);
if (m.length > 0) {
this.env = m[1];
break;
}
php no1.php
# returns:
#
# echo "no2\n";
# no1
@taiyoh
taiyoh / find_in_set.diff
Created August 30, 2011 12:08
CriteriaでORDER BY FIND_IN_SETを使うためのクイックハック。at your own risk!
Index: symfony/lib/plugins/sfPropelPlugin/lib/vendor/propel/util/Criteria.php
===================================================================
--- symfony/lib/plugins/sfPropelPlugin/lib/vendor/propel/util/Criteria.php (リビジョン 3317)
+++ symfony/lib/plugins/sfPropelPlugin/lib/vendor/propel/util/Criteria.php (作業コピー)
@@ -913,6 +913,11 @@
return $this;
}
+ public function addFindInSetOrderByColumn($name, array $list)
+ {
@taiyoh
taiyoh / nginx.conf
Created October 20, 2011 13:32
nginxを使ったreproxyの最小(に近い)設定
worker_processes 1;
error_log logs/error.log;
daemon off;
events {
worker_connections 1024;
}
@taiyoh
taiyoh / brick.coffee
Created November 3, 2011 07:30
brick.jsをCoffeeScriptで書きなおしてみた(習作につき)
makeArray = (args, sp) ->
return Array::slice.call args, sp ? 0
detectType = (o) ->
return Object::toString.call(o)
.replace /^\[object (.+)\]$/, '$1'
_bind = (f, self) ->
args = makeArray arguments, 2
return ->
asciitable = {
NUL : 0, SOH : 1, STX : 2, ETX : 3, EOT : 4, ENQ : 5, ACK : 6, BEL : 7, BS : 8, HT : 9,
NL : 10, VT : 11, NP : 12, CR : 13, SO : 14, SI : 15, DLE : 16, DC1 : 17, DC2 : 18, DC3 : 19,
DC4 : 20, NAK : 21, SYN : 22, ETB : 23, CAN : 24, EM : 25, SUB : 26, ESC : 27, FS : 28, GS : 29,
RS : 30, US : 31, SP : 32, DEL : 127,
NULL: 0, ENTER : 13, SPACE: 32, TAB : 9,
find: function(c) {
return this[c] || (function(i, v, r) {
if (c.length === 1) return c.charCodeAt();
for (;v=c[i];++i) r.push(v.charCodeAt());
@taiyoh
taiyoh / flickr-api2.diff
Created November 13, 2011 06:30
Flickr::API2を修正したので、そのdiff
diff --git a/lib/Flickr/API2/Base.pm b/lib/Flickr/API2/Base.pm
index d7f5673..e07a72f 100644
--- a/lib/Flickr/API2/Base.pm
+++ b/lib/Flickr/API2/Base.pm
@@ -37,20 +37,13 @@ sub _response_to_photos {
my ($self, $photos) = @_;
my @photos = map {
- Flickr::API2::Photo->new(
- api => $self->api,
--- a/lib/Archer/Plugin/Confirm.pm
+++ b/lib/Archer/Plugin/Confirm.pm
@@ -2,7 +2,7 @@ package Archer::Plugin::Confirm;
use strict;
use warnings;
use base qw/Archer::Plugin/;
-use IO::Prompt;
+use IO::Prompt::Simple;
sub run {
package Foo {
use IO::Prompt;
sub new { bless {}, shift }
sub ask {
my ($self, $msg) = @_;
my $echo = prompt("next: ");
print "You said '$echo'\n";
}
diff --git a/lib/Archer/Plugin/Rsync.pm b/lib/Archer/Plugin/Rsync.pm
index c2f943c..1eebd23 100644
--- a/lib/Archer/Plugin/Rsync.pm
+++ b/lib/Archer/Plugin/Rsync.pm
@@ -44,8 +44,8 @@ sub run {
$rsync->exec;
- $self->log( debug => $rsync->out ) if $rsync->out;
- $self->log( debug => $rsync->err ) if $rsync->err;