Skip to content

Instantly share code, notes, and snippets.

View ken39arg's full-sized avatar

Kensaku Araga ken39arg

  • KAYAC Inc.
  • Yokohama, Kamakura
View GitHub Profile
<?php
function upper_and_length($item)
{
global $maxlength;
$item = strtoupper(preg_replace('/([a-z0-9])([A-Z])/', '$1_$2', $item));
if ($maxlength < strlen($item))
$maxlength = strlen($item);
return $item;
}
@ken39arg
ken39arg / gist:933833
Created April 21, 2011 06:14
JSでログの制御ってこれで良いのかな?
var IS_DEV = true;
// logger
var console = window.console;
if (IS_DEV === false || !console) {
console = {
log: function(){},
debug: function(){},
info: function(){},
warn: function(){},
#! /usr/bin/env sh
dir=$1
echo "target > $dir"
pattern="^No*"
files=`find $dir -name '*.php'`
for file in $files
do
@ken39arg
ken39arg / gist:1079771
Created July 13, 2011 05:29
vimrc.local
" {{{ 場所ごとの設定
augroup vimrc-local
autocmd!
autocmd BufNewFile,BufReadPost * call s:vimrc_local(expand('<afile>:p:h'))
augroup END
function! s:vimrc_local(loc)
let files = findfile('.vimrc.local', escape(a:loc, ' ') . ';', -1)
for i in reverse(filter(files, 'filereadable(v:val)'))
source `=i`
@ken39arg
ken39arg / vim-inflect-pluralize.vim
Created September 4, 2011 04:33
単数系を複数系に変換する :PL child #=> children, :PLI child #=> カーソルにchildrenをinsertする
if !exists('g:inflect_pluralize_cmd')
let g:inflect_pluralize_cmd = "perl -MLingua::EN::Inflect=PL -E 'print PL(\"%s\")'"
endif
function! s:inflect_pluralize(word)
return system(substitute(g:inflect_pluralize_cmd, "%s", a:word, "g"))
endfunction
function! s:insert_(v)
execute "normal i" . a:v ."\<Esc>"
use strict;
use warnings;
use Benchmark qw/ :all /;
use URI;
use URI::WithBase;
my $BACKEND_URL = "http://hoge.fuga.com";
sub func_a {
**diff
diff --git a/src/swf_tag.c b/src/swf_tag.c
index bff81f7..c7966ad 100644
--- a/src/swf_tag.c
+++ b/src/swf_tag.c
@@ -515,9 +515,16 @@ swf_tag_get_bitmap_color1stpixel(swf_tag_t *tag,
*blue = swf_tag_lossless->colormap[color_index].blue;
} else { // Lossless2 => RGBA
int alpha = swf_tag_lossless->colormap2[color_index].alpha;
- *red = swf_tag_lossless->colormap2[color_index].red * 255 / alpha;
#!perl
use strict;
use warnings;
use Data::Dumper;
my %o = (
abc => 1,
def => 'ghi',
);
@ken39arg
ken39arg / grappe.pl
Created May 14, 2012 07:42
grappe upload
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use Encode;
use LWP::UserAgent;
use HTTP::Request::Common qw(POST);
use Config::Pit;
# grappe is https://github.com/mix3/grappe
var regexp = /\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}/,
links = document.getElementsByTagName('a'),
len = links.length,
i = 0;
for (i = 0; i < len; ++i) {
if (links[i].title && regexp.test(links[i].title)) {
links[i].innerHTML = links[i].innerHTML + "[" + links[i].title + "]";
}