Skip to content

Instantly share code, notes, and snippets.

View handlename's full-sized avatar

NAGATA Hiroaki handlename

View GitHub Profile
<?php
class kayacActions extends sfActions
{
public function executeError(sfWebRequest $request)
{
// 問答無用でエラーレスポンス
$this->forwardError('500', 'エラーメッセージ');
}
myEnvironmentConfigFilter:
class: myEnvironmentConfigFilter
<?php
class myEnvironmentConfigFilter extends sfFilter
{
public function execute($filterChain)
{
if ($this->isFirstCall()) {
include(sfContext::getInstance()->getConfigCache()->checkConfig(sfConfig::get('sf_config_dir').'/environment.yml'));
}
config/environment.yml:
class: sfDefineEnvironmentConfigHandler
param:
prefix: app_
#!/usr/bin/php
<?php
$text = file_get_contents('php://stdin');
$text = preg_replace('/<\/?div[^>]*\/?>/', '', $text);
$text = preg_replace('/<\/?a[^>]*>/', '', $text);
$text = preg_replace('/<span[^\/]+\/span>/', '', $text);
$text = preg_replace('/ id="[^"]*"/', '', $text);
<?php
function getFileList($dir_path)
{
if(! is_dir($dir_path))
{
return array();
}
$list = array();
@handlename
handlename / is_deeply.php
Created October 29, 2010 17:04
better is_deeply
<?php
function is_deeply($a, $b, $diff = array(), $key_str = '') {
ksort($a);
ksort($b);
$keys = array_unique(
array_merge(
array_keys($a),
array_keys($b)
@handlename
handlename / html-helper-mode.diff
Created November 11, 2010 15:48
for html-helper-mode 3.0.4kilo
*** html-helper-mode_default.el 2004-05-17 01:01:09.000000000 +0900
--- html-helper-mode.el 2010-11-11 16:51:48.000000000 +0900
***************
*** 310,316 ****
(defvar html-helper-new-PHP-buffer-template
'("<html> <head>\n"
! "<? PHP\n\n?>"
"</head><body>\n"
"<? /* " html-helper-timestamp-start "\n\n"
@handlename
handlename / sgrep.pl
Created November 26, 2010 17:20
utf8なコマンドラインからjsisのファイルを直接grepしたいときに使うのかも
#!/usr/bin/env perl
use strict;
use warnings;
use Encode;
use File::Find;
use Term::ANSIColor::Print;
my @targets = split /,/, $ARGV[0];
@handlename
handlename / ktai-hankaku.el
Created February 5, 2011 21:39
replace katakana characters with hankaku katakana characters.
(defun ktai-hankaku-katakana-region (start end)
(interactive "r")
(while (string-match
"[0-9A-Za-zァ-ンー:;$]+\\|[!?][!?]+"
(buffer-substring start end))
(save-excursion
(japanese-hankaku-region
(+ start (match-beginning 0))
(+ start (match-end 0))
))))