Skip to content

Instantly share code, notes, and snippets.

View potix2's full-sized avatar
:octocat:

Katsunori Kanda potix2

:octocat:
View GitHub Profile
@potix2
potix2 / gist:3339485
Created August 13, 2012 11:01
ApacheBenchでJSONをPOSTする
% ab -n 10 -c 10 -p json.file -T "application/json; charset=utf-8" http://localhost/
@potix2
potix2 / gist:3332563
Created August 12, 2012 16:13
micro benchmark for kt
ktremotetest bulk -th 4 -bin -bulk 1 10000 > benchmark.log
# -*- coding: utf-8 -*-
import unittest
import StringIO
class StreamTestCase(unittest.TestCase):
def test_something(self):
output = StringIO.StringIO()
output.write("Lorem ")
output.write("Ipsum")
self.assertEquals(output.getvalue(), "Lorem Ipsum")
@potix2
potix2 / gist:2927691
Created June 14, 2012 02:04
github-growlerをgithub APIv3対応するためのパッチ
diff --git a/github-growler.pl b/github-growler.pl
index bc37fea..4b4b430 100755
--- a/github-growler.pl
+++ b/github-growler.pl
@@ -258,14 +257,12 @@ sub get_user {
$Cache->("user:$name", sub {
my $cb = shift;
- http_get "http://github.com/api/v2/json/user/show/$name", persistent => 0, sub {
+ http_get "https://api.github.com/users/$name", persistent => 0, sub {
@potix2
potix2 / gist:2916704
Created June 12, 2012 10:06
church encoding
type Church a = (a -> a) -> (a -> a)
curch::Integer -> Church Integer
curch 0 = \f -> \x -> x
curch n = \f -> \x -> f(curch(n-1) f x)
unchurch :: Church Integer -> Integer
unchurch n = n(\x -> x + 1) 0
@potix2
potix2 / gist:2908964
Created June 11, 2012 07:49
display bitmap pattern with spark
$od -i hoge| awk '{print $2,$3,$4,$5}' | spark
▇▅▄▆▄▁▁▁▁▄▁▄▄▄▄▄▅▄▄▁▁▅▁▄▄▅▂▁▅▂▄▄▁▂▄▅▇▆▁▂▅▃▁▆▆▅▁▆▃▃▆▂▆▄▂▄▆▇▃▄▄▄▆▁▁▁▃▃▂▅▂▂▂▄▃▂▃▂▆▃▇▆▄▃▆▅▆▄▅▁▂▆▄▂▃▂▁▄▄▇▆▁▇▅▄▃▄▃▂▄▁▃▁▁▁▁▃▅▄▆▃▁▇▅▂▆▅▄▄▆▁▁▄▇▅▄▄▂▆▄▇▆▄▅▂▆▁▁▅▂▃▂▇▁▇▄▆▅▅█▁▄▇▇▄▇▂▄▂▇▅▄▆▃▇▅▆▁▆▅▄▇▅▁▇▁▂▁▃▁▅▁▇▄▁▄▅▄▄▆▄▅▇▅▅▅▅▄▁▄▁▅▄▁▄▁▄▄▆▄▅▅▃▆▁▂▄▁▃▂▇▅▂▇▃▂▁▄▂▅▁▂▅▄▂▂▅▅▆▆▄▆▁▇▇▇▅▇▅▅▃▇▄▆▁▂▇▂▇▅▃▆▅▃▂▄▃▇▁▁▁▃▄▄▂▅▃▂▄▂▄▅▆▂▂▇▁▃▂▅▅▃▃▅▅▆▇▇▇▂▂▄▆▆▂▂▃▆▁▄▁▆▂▇▇▇▆▅▃▅▇▂▂▅▄▇▂▆▄▅▁▅▆▅▂▅▅▂▄▁▆▅▂▃▄▄▄▅▅▇▁▆▇▇▅▂▇▆▂▁▁▃▁▁▄▄▃▇▂▂▁▇▇▅▁▄▆▆▁▆▃▄▇▂▄▅▅▅▅▅▅▄▄▅▂▃▅▄▂▆▂▄▄
@potix2
potix2 / gist:2907530
Created June 10, 2012 22:24
NGクライアントを使ってvimclojureと会話
#start repl
%ng vimclojure.Nail Repl -s
{"value" : {"id" : 4}, "stdout" : "", "stderr" : ""}
#send expression to ng-server
%ng vimclojure.Nail Repl -r -i 4
(+ 1 2)^D
{"value" : 0, "stdout" : "3\n", "stderr" : ""}
@potix2
potix2 / .gitconfig
Created May 24, 2012 01:46
git alias
[alias]
co = checkout
st = status
ci = commit -a
di = diff
br = branch
stat = log --stat --summary
logg = log --graph --decorate --pretty=format:\"%ad [%cn] %h> %n %Cgreen%d%Creset %s %n\" --name-status
logs = log --graph --decorate --pretty=format:\"%ad [%cn] %h> %n %Cgreen%d%Creset %s %n\" --stat
#!/bin/sh
SRCDIR="original/"
DESTDIR="resized/"
if [ ! -d "resized" ];
then
mkdir resized
fi
@potix2
potix2 / gist:2291165
Created April 3, 2012 11:30
ASP.NET MVC3のController内でSessionが更新されていることをテストするためのコード(Moq使用)
//SEE: http://stackoverflow.com/questions/2916348/using-moq-to-set-indexers-in-c-sharp
[TestMethod]
public void IndexTest()
{
var mockHttpContext = new Mock<HttpContextBase>();
var mockSession = new Mock<HttpSessionStateBase>();
mockHttpContext.Setup(context => context.Session).Returns(mockSession.Object);
AppHttpContext.Current = () => mockHttpContext.Object;
var controller = new HomeController();