Skip to content

Instantly share code, notes, and snippets.

@suzuki
suzuki / build.xml
Created March 26, 2012 05:14
Sorted filelist for Phing
<?xml version="1.0" encoding="utf-8" ?>
<project name="sorted-filelist" basedir="." default="all">
<target name="all" depends="use-fileset, use-find" />
<!-- fileset version -->
<!-- no sort -->
<target name="use-fileset">
<foreach param="filename" target="echo-filename">
<fileset dir="./testdir">
@suzuki
suzuki / gist:2203180
Created March 26, 2012 05:30
sample data for gist:2203147
$ mkdir testdir
$ cd testdir
$ touch touch 22test.txt
$ touch touch 10test.txt
$ touch touch 40test.txt
$ touch touch 30test.txt
@suzuki
suzuki / gist:2203185
Created March 26, 2012 05:34
result for gist:2203147
$ phing
Buildfile: /home/suzuki/build.xml
sorted-filelist > use-fileset:
[foreach] Calling Buildfile '/home/suzuki/build.xml' with target 'echo-filename'
sorted-filelist > echo-filename:
[echo] Filename is 22test.txt
#!/usr/bin/env perl
use strict;
use warnings;
use Pod::Usage;
use Text::Markdown 'markdown';
use HTML::TreeBuilder;
use List::Util 'max';
#!/usr/bin/env perl
use strict;
use warnings;
use Pod::Usage;
use Text::Markdown 'markdown';
use HTML::TreeBuilder;
use List::Util 'max';
@suzuki
suzuki / gist:2288154
Created April 3, 2012 00:05
Detect charset from MIME string
/**
* Detect charset from MIME string
*
* @params string
* @return mixed found a charset string (upper case) or couldn't found false
*/
public function getCharsetFromMimeString($mimeString) {
$mimeString = trim($mimeString);
if (preg_match('/^=\?([^?]+)\?(:?B|Q)\?[^?]+\?=$/', $mimeString, $matched)){
return strtoupper($matched[1]);
@suzuki
suzuki / gist:2657241
Created May 11, 2012 03:04
split-window-vertically-one-third
(defun split-window-vertically-one-third()
"Split the selected window into two windows, one above the other, size is one third of window-heihgt"
(interactive)
(split-window-vertically (/ (window-height) 3)))
(global-set-key "\C-x2" 'split-window-vertically-one-third)
@suzuki
suzuki / gist:2715870
Created May 17, 2012 02:55
CandyCane with PostgreSQL
$ git diff app/Model/Project.php
diff --git a/app/Model/Project.php b/app/Model/Project.php
index af47298..fa9c98e 100755
--- a/app/Model/Project.php
+++ b/app/Model/Project.php
@@ -329,7 +329,7 @@ class Project extends AppModel {
$enabledModuleTable = $this->EnabledModule->tablePrefix . $this->EnabledModule->table;
$emName = $perm['project_module'];
- $base_statement[] = array("EXISTS (SELECT em.id FROM $enabledModuleTable em WHERE em.name='$emName' AND em.project_id=$projectTable.id)" => true);
@suzuki
suzuki / gist:2760759
Created May 21, 2012 06:14
An idea of CakeEmail content-type detection
protected function _getContentTypeCharset() {
switch($this->charset) {
case 'iso-2022-jp-ms':
$charset = 'iso-2022-jp';
break;
default:
$charset = $this->charset;
}
return $charset;
}
500 Internal Server Error
cannot load such file -- pygments (LoadError)
/usr/local/rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/usr/local/rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/home/tdiary/tdiary/core/tdiary/style/gfm_style.rb:24:in `block_code'
/home/tdiary/tdiary/core/tdiary/style/gfm_style.rb:120:in `render'
/home/tdiary/tdiary/core/tdiary/style/gfm_style.rb:120:in `to_html'
/home/tdiary/tdiary/core/tdiary/style/gfm_style.rb:50:in `initialize'