Skip to content

Instantly share code, notes, and snippets.

Avatar
🔥
🍖

Norio Suzuki suzuki

🔥
🍖
View GitHub Profile
@suzuki
suzuki / build.xml
Created Mar 26, 2012
Sorted filelist for Phing
View build.xml
<?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 Mar 26, 2012
sample data for gist:2203147
View gist:2203180
$ 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 Mar 26, 2012
result for gist:2203147
View gist:2203185
$ 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
View markdown2inao.pl
#!/usr/bin/env perl
use strict;
use warnings;
use Pod::Usage;
use Text::Markdown 'markdown';
use HTML::TreeBuilder;
use List::Util 'max';
View markdown2inao.pl
#!/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 Apr 3, 2012
Detect charset from MIME string
View gist:2288154
/**
* 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
split-window-vertically-one-third
View gist:2657241
(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
CandyCane with PostgreSQL
View gist:2715870
$ 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
An idea of CakeEmail content-type detection
View gist:2760759
protected function _getContentTypeCharset() {
switch($this->charset) {
case 'iso-2022-jp-ms':
$charset = 'iso-2022-jp';
break;
default:
$charset = $this->charset;
}
return $charset;
}
View gist:4425864
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'
You can’t perform that action at this time.