Skip to content

Instantly share code, notes, and snippets.

@niratama
niratama / gist:2368443
Created April 12, 2012 15:44
9個中1個の重さの違う肉まんを探す(from https://twitter.com/#!/panta_rhei2004/status/190430047675486208)
#!env perl
use 5.010;
use List::Util qw(sum);
my @m = @ARGV;
if (sum(@m[0..2]) == sum(@m[3..5])) { # 0〜2と3〜5はあんまん
if ($m[6] == $m[7]){ # 6と7もあんまん
say 8;
} else { # 6か7どちらかが肉まん
@niratama
niratama / svndump_fix.pl
Created October 30, 2012 04:41
svnadmin dumpしたものが日本語ファイル名が原因で戻せないときの対策ツール
#!env perl
# vi:ts=4:sw=4
use 5.010;
use strict;
use SVN::Dump;
use Data::Dumper;
my ($infile, $outfile) = @ARGV;
unless ($infile && $outfile) {
say "$0 infile outfile";
@niratama
niratama / libpafe.rb
Created May 13, 2013 23:14
homebrew libpafe formula
require 'formula'
class Libpafe < Formula
homepage 'http://homepage3.nifty.com/slokar/pasori/libpafe.html'
url 'http://homepage3.nifty.com/slokar/pasori/libpafe-0.0.8.tar.gz'
sha1 'dec47ea185dd052c3e9b28cfb3494e509f7a4316'
head 'git://github.com/htrb/libpafe.git'
depends_on 'pkg-config' => :build

MojoliciousでリアルタイムWeb

こばやし けんいち

自己紹介 ねこ

  • こばやし けんいち @Niratama
  • Perlでサーバーサイドプログラム書いてます
@niratama
niratama / gist:7022910
Created October 17, 2013 10:54
XslateとUTF-8の挙動一覧
#!/usr/bin/env perl
use strict;
use utf8;
use Encode qw(encode decode);
use Text::Xslate;
my $template = <<'__HERE__';
: my $xkey = '日本語';
: my $ykey = dec('日本語');
Sbt.global.Base.Money *= Sbt.global.Base.Money;
window.setInterval(function () { Sbt.global.Base.ClickTetsuya(); }, 1);
for (i = 0; i < 7; i++) for (j = 0; j < 256; j++) Sbt.global.Base.ClickMachine(i);
for (i = 0; i < 14; i++) Sbt.global.Base.ClickOption(i)
@niratama
niratama / gist:7214083
Created October 29, 2013 12:52
perl-Net-HandlerSocketのやっつけパッチ
diff --git a/perl-Net-HandlerSocket/HandlerSocket.xs b/perl-Net-HandlerSocket/HandlerSocket.xs
index d0aaaa3..67baf8c 100644
--- a/perl-Net-HandlerSocket/HandlerSocket.xs
+++ b/perl-Net-HandlerSocket/HandlerSocket.xs
@@ -522,7 +522,8 @@ execute_multi(obj, cmds)
CODE:
DBG(fprintf(stderr, "execute_multi0\n"));
const I32 cmdsmax = av_len(cmds);
- execute_arg args[cmdsmax + 1]; /* GNU */
+// execute_arg args[cmdsmax + 1]; /* GNU */
@niratama
niratama / myapp.pl
Created December 10, 2013 13:50
Mojoliciousで各種ストリーミングのテスト
#!/usr/bin/env perl
use Mojolicious::Lite;
get '/' => sub {
my $self = shift;
$self->render('index');
};
# XMLHttpRequest Streaming
get '/stream' => sub {
@niratama
niratama / test.xml
Created December 19, 2013 11:12
FirefoxとIE/Safari/Chromeで挙動の違うXSLT
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<article title="hello!">
<content><![CDATA[
<div style="text-align: center;">Hello, world!</div>
]]></content>
</article>
@niratama
niratama / futapo.user.js
Last active August 29, 2015 13:56
futaPoのサムネイルを拡大するuserscript
// ==UserScript==
// @name futaPoサムネイル拡大
// @namespace http://nira.poi.jp/userscript/futapo.user.js
// @version 0.0.3
// @description futaPoのサムネイルを拡大します
// @includes http://futakuro.com/futapo/*
// @excludes
// ==/UserScript==
//
(function (callback) {