Skip to content

Instantly share code, notes, and snippets.

use strict;
use warnings;
my $sum = 0;
while(<>) {
if(m/\A# Query_time: ([0-9.]+)/){
$sum = $sum + $1;
}
}
package main
import (
"bufio"
"crypto/md5"
"fmt"
"os"
"time"
goCache "github.com/pmylund/go-cache"
@catatsuy
catatsuy / .tmux.conf
Created November 13, 2012 12:09
Basic tmux config
# Prefix
set-option -g prefix C-z
# 日本語環境なら必須??
setw -g utf8 on
set -g status-utf8 on
# status
set -g status-interval 10
set -g status-bg colour100
@catatsuy
catatsuy / presenters.pl
Created November 20, 2012 16:08
プレゼンする人を決める Perl スクリプト
use strict;
use warnings;
use utf8;
use IO::File;
use Text::CSV_XS;
use List::Util qw/shuffle/;
binmode STDOUT, ':utf8';
package main
import (
"fmt"
"math/rand"
"time"
)
type weight struct {
weight float64
@catatsuy
catatsuy / musume.pl
Created January 4, 2013 15:40
This is a sample of Acme::MorningMusume
use strict;
use warnings;
use utf8;
use FindBin::libs;
use Acme::MorningMusume;
my $musume = Acme::MorningMusume->new;
my @active_members = $musume->members('active');
use strict;
use warnings;
use utf8;
use Acme::MorningMusume;
my $musume = Acme::MorningMusume->new;
my @active_members = $musume->members('active');
my @sorted_by_birthday = $musume->sort('birthday', 0, @active_members);
N = 2**60
r = 1.0
(1..7000000).each do |i|
r *= ((N.to_f - i + 1) / N)
end
p 1 - r
@catatsuy
catatsuy / fd_bytes.cc
Created April 16, 2013 17:22
from float/double to byte sequence
#include <cstdio>
void dump(unsigned char *p, int n) {
for (int i = n - 1; i >= 0; i--) {
printf("%02x ", p[i]);
}
printf("\n");
}
int main() {
@catatsuy
catatsuy / app_pi.rb
Last active December 16, 2015 11:09
APP_PI = 3.14
app_pis = (3..1000).map { |n| n * Math.sin(Math::PI / n) }
ans = 0
app_pis.each_with_index do |item, n|
if (item - APP_PI).abs < (app_pis[ans] - APP_PI).abs
ans = n
end