This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ $# -eq 2 ] | |
then | |
i=$2 | |
else | |
i=`whoami` | |
fi | |
declare -i mine=`git blame $1 | grep -i $i | wc -l` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Benchmark 'cmpthese'; | |
my $tagname = shift; | |
cmpthese( | |
1_000_000, | |
{ | |
regexp => sub { regexp($tagname) }, | |
lc_eq => sub { lc_eq($tagname) }, | |
regexp_subst => sub { regexp_subst($tagname) }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
system( | |
"$ENV{HOME}/perl5/bin/cpanm", | |
map { | |
s/\.pm$// and s{/}{::}g; # Can't locate | |
s/^perl-// and s{-}{::}g; # yum | |
$_; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub indent_html { | |
my $html = shift; | |
my $indent = 0; | |
return join "\n", grep { $_ !~ /^\s*$/ } map { | |
s{(^\s+|\s+$)}{}g; | |
if (m{</}) { | |
$indent--; | |
} | |
$indent = 0 if $indent < 0; | |
my $res = ' ' x $indent . $_; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from google.appengine.ext import webapp | |
from google.appengine.ext.webapp.util import run_wsgi_app | |
import httplib | |
class StatusCode(webapp.RequestHandler): | |
def get(self, code): | |
self.response.headers['Content-Type'] = 'text/html' | |
content = 'statuscode : ' + code + '<br>' | |
for c, m in httplib.responses.iteritems(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use IDNA::Punycode; | |
use Encode; | |
idn_prefix('xn--'); | |
decode_punycode('xn--cho'); #=> '䑵' | |
decode_punycode('xn--motemen'); #=> '嵡嵣嵫嵧嵨' | |
decode_punycode('xn--hitode'); #=> '岴岊岲' | |
decode_punycode('xn--hakobe932'); #=> IDNA::Punycode が落ちて abort |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
# TODO | |
# - drop key | |
@ARGV == 2 or die 'Usage: mysqldiff dbname1 dbname2'; | |
my @tables = map { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE entry ( | |
blog_id INT, | |
created datetime | |
); | |
DROP PROCEDURE IF EXISTS set_uninterrupted_count; | |
DELIMITER // | |
CREATE PROCEDURE set_uninterrupted_count(IN id INT, OUT uninterrupted_count INT) | |
BEGIN | |
DECLARE done INT DEFAULT 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@media screen and (max-device-width: 480px) { | |
* { | |
font-size: 48px; | |
line-height: 64px; | |
word-break: break-all; | |
} | |
table#banner, div#simple-header, div.sidebar, div.caption { | |
display:none | |
} | |
img.hatena-star-comment-button, img.hatena-star-add-button, img.hatena-star-star { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
print "Hello, World!!"; |
OlderNewer