Skip to content

Instantly share code, notes, and snippets.

View yaotti's full-sized avatar

Hiroshige Umino yaotti

View GitHub Profile
# aliases for git
alias g="git"
alias gad="git add"
alias gb="git branch -v"
alias gba="git branch -a"
alias gbl="git blame"
alias gbr="git branch -r"
alias gc="git commit -v"
alias gca="git commit -av"
alias gco="git checkout"
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>CSRF test</title>
</head>
<body onload="document.getElementById('f').submit();">
<form action="/some/post/url" method="post" id="f" target="ifr">
<input type="text" name="body" value="CSRF!" />
#!/usr/bin/env python
# coding: utf-8
def say(word=None):
print word
if __name__ == '__main__':
say(word='hi')
say(**{'word': 'hi'})
say(**{'wo'+'rd': 'hi'})
#!/usr/bin/env ruby
commit = ARGV.empty? ? 'HEAD' : ARGV.shift
puts `git log --pretty=oneline #{commit}`.split(/\s+/)[0]
#!/usr/bin/env python
# coding: utf-8
def fact(x):
def factrec(f, n):
if n < 1:
return 1
else:
return n * (f (f, (n - 1)))
return factrec(factrec, x)
#!/usr/bin/env python
# coding: utf-8
# http://ameblo.jp/programming/entry-10001721422.html
class Cards:
@classmethod
def deal(cls, num, string):
cds = [""]*num
for i in xrange(len(string) / num):
for j in xrange(num):
cds[j] += string[i*num+j]
#!/usr/bin/env perl
use strict;
use warnings;
use Hash::MultiValue;
use XXX;
my $h = [a => 1, a => 2, b => 3];
my $hm = Hash::MultiValue->new(@$h);
YYY $hm;
@yaotti
yaotti / GET.pm
Created December 28, 2009 04:41
design pattern: Chain Of Responsibility
package HTTP::RequestHandler::GET;
use base qw/HTTP::RequestHandler/;
use strict;
use warnings;
sub handle_request {
my ($self, $request) = @_;
return if $request->method ne 'GET';
warn 'Requested method is GET: ' . $request->uri;
}
#!/usr/bin/env perl
use strict;
use warnings;
use WWW::Mechanize;
use Config::Pit;
my $mech = WWW::Mechanize->new();
my $login_url = "http://lang-8.com/login";
my $response = $mech->get($login_url);
my ( $mail, $password ) = do { @{ pit_get("lang-8.com") }{qw/mail password/} };
(defun c++-debug-print()
(interactive)
(let* ((var-str (read-from-minibuffer "variables (space separated): "))
(vars (split-string var-str))
(dp "cout"))
(dolist (v vars)
(setq dp (concat dp " << " v " << \", \"")))
(insert (concat dp " << endl;"))))