Skip to content

Instantly share code, notes, and snippets.

@hayajo
hayajo / gist:1062957
Created July 4, 2011 06:06
Plack::HTTPParser::PP
--- Plack/HTTPParser/PP.pm.org 2011-05-26 16:21:15.000000000 +0900
+++ Plack/HTTPParser/PP.pm 2011-07-01 17:23:18.000000000 +0900
@@ -52,7 +52,7 @@
$env->{REQUEST_URI} = $uri;
my($path, $query) = ( $uri =~ /^([^?]*)(?:\?(.*))?$/s );
- for ($path, $query) { s/\#.*$// if length } # dumb clients sending URI fragments
+ for ($path, $query) { s/\#.*$// if (defined && length) } # dumb clients sending URI fragments
$env->{PATH_INFO} = URI::Escape::uri_unescape($path);
@hayajo
hayajo / gist:1066442
Created July 6, 2011 02:48
open_junk_file - vim
" Open junk file
" via. http://vim-users.jp/2010/11/hack181/
command! -nargs=0 JunkFile call s:open_junk_file()
function! s:open_junk_file()
if !exists('g:junk_file_basedir')
let g:junk_file_basedir = $HOME . '/.vim_junk'
endif
let l:junk_file_dir = g:junk_file_basedir . strftime('/%Y/%m')
if !isdirectory(l:junk_file_dir)
call mkdir(l:junk_file_dir, 'p')
@hayajo
hayajo / gist:1066443
Created July 6, 2011 02:49
postinstall - dotcloud
#!/bin/sh
# install Hopen from github
cpanm https://github.com/hayajo/Hopen/tarball/master
# install additional modules from filepath
for MODULE in modules/*; do
cpanm ${MODULE}
done
@hayajo
hayajo / in.emacs.el
Created July 6, 2011 03:11
gist.el in emacs config
(require 'gist)
(setq gist-fetch-url "https://raw.github.com/gist/%d")
@hayajo
hayajo / test_json.el
Created July 6, 2011 08:52
test json.el
(require 'json)
(setq hash (make-hash-table :test 'equal))
(puthash "hoge" "HOGE" hash)
(puthash "fuga" "FUGA" hash)
(puthash "piyo" "PIYO" hash)
(json-encode "hoge") ;string
(json-encode ["hoge" "fuga" "piyo"]) ;array
(json-encode '("hoge" "fuga" "piyo")) ;list
(json-encode hash) ;hash-table
@hayajo
hayajo / gist.el
Created July 8, 2011 05:03
github API v3 based gist.el
(eval-when-compile (require 'cl))
(require 'json)
(defvar gist-github-user nil
"GitHub username")
(defvar gist-github-password nil
"GitHub password")
(defvar gist-supported-modes-alist '((action-script-mode . "as")
(c-mode . "c")
(c++-mode . "cpp")
@hayajo
hayajo / gist:1126900
Created August 5, 2011 04:02
set cursorline only current window - vim
" set cursorline only current window
augroup cch
autocmd! cch
autocmd WinLeave * set nocursorline
autocmd WinEnter,BufRead * set cursorline
augroup END
@hayajo
hayajo / autoIgnoreKey.js
Created August 19, 2011 04:07
autoIgnoreKey.js - vimperator
(function(){
/**
* String or RegExp
* e.g)
* * /^https?:\/\/mail\.google\.com\//
* * 'http://reader.livedoor.com/reader/'
*
* The autoignorekey_pages is a string variable which can set on
* vimperatorrc as following.
*
@hayajo
hayajo / gist:1167189
Created August 24, 2011 02:46
DBIx::Skinny::Schema::Loader 0.22 patch
--- DBIx/Skinny/Schema/Loader.pm.org 2011-08-24 10:33:56.000000000 +0900
+++ DBIx/Skinny/Schema/Loader.pm 2011-08-24 10:42:22.000000000 +0900
@@ -58,7 +58,7 @@
connect_options => $connect_options || {},
};
}
- $opts->{dsn} =~ /^dbi:([^:]+):/;
+ $opts->{dsn} =~ /^dbi:([^:]+):/i;
my $driver = $1 or croak "Could not parse DSN";
croak "$driver is not supported by DBIx::Skinny::Schema::Loader yet"
@hayajo
hayajo / gist:1196394
Created September 6, 2011 02:15
Plack::Middleware::Auth::Form 0.010 patch
--- Plack/Middleware/Auth/Form.pm.bak 2011-09-06 10:53:44.000000000 +0900
+++ Plack/Middleware/Auth/Form.pm 2011-09-06 11:09:13.000000000 +0900
@@ -74,6 +74,7 @@
$user_id = $params->get( 'username' );
}
if( !$login_error ){
+ $env->{'psgix.session.options'}->{change_id}++;
$env->{'psgix.session'}{user_id} = $user_id;
$env->{'psgix.session'}{remember} = 1 if $params->get( 'remember' );
my $redir_to = delete $env->{'psgix.session'}{redir_to};