Skip to content

Instantly share code, notes, and snippets.

View oinume's full-sized avatar
🏠
Working from home

oinume oinume

🏠
Working from home
View GitHub Profile
@oinume
oinume / web.xml
Created June 1, 2013 14:43
Jettyでシンボリックリンクを使えるようにする設定
<servlet>
<servlet-name>jetty</servlet-name>
<servlet-class>org.eclipse.jetty.servlet.DefaultServlet</servlet-class>
<init-param>
<param-name>aliases</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
#!/bin/sh
set -x
export PYENV_ROOT=/usr/local/pyenv
cd /usr/local/
git clone https://github.com/yyuu/pyenv.git pyenv
cd pyenv/plugins
git clone https://github.com/yyuu/pyenv-virtualenv
_SHELL=$(basename $(echo $SHELL))
@oinume
oinume / pyenv.sh
Created April 10, 2013 05:10
/etc/profile.d/pyenv.sh $ . /etc/profile
#!/bin/sh
if [ -d /usr/local/pyenv/bin ]; then
pathmunge /usr/local/pyenv/bin
pathmunge /usr/local/pyenv/shims/
export PYENV_ROOT=/usr/local/pyenv
fi
@oinume
oinume / connect.rb
Created April 1, 2013 10:29
Connecting to MySQL with JRuby and JDBC.
require 'java'
require 'rubygems'
require 'dbi'
require 'dbd/Jdbc'
require 'jdbc/mysql'
Jdbc::MySQL.load_driver
DBI.connect(
'DBI:Jdbc:mysql://localhost/test',
@oinume
oinume / z2h.pl
Created February 7, 2013 02:56
./z2h.pl zenkaku_kana.txt > /tmp/hankaku_kana.txt
#!/usr/bin/env perl
use strict;
use warnings;
use Encode;
use Encode::JP::H2Z;
use open ":utf8";
binmode STDOUT, ":utf8";
binmode STDIN, ":utf8";
my $euc = Encode::find_encoding("eucjp");
sub z2h { my $s = $euc->encode(shift); Encode::JP::H2Z::z2h(\$s); $s = $euc->decode($s); }
@oinume
oinume / symlink_munin_mysql_plugins.sh
Created January 14, 2013 09:08
symlink all available mysql plugins in Munin 2.0 to /etc/munin/plugins
@oinume
oinume / entity.ftl
Created November 18, 2012 00:24
FreeMarkerで余計な改行を入れないftlの例
package ${packageName};
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@oinume
oinume / entity.ftl
Created November 13, 2012 16:19
FreeMarkerで余計な改行が入ってしまうftl例(最初の段階)
package ${packageName};
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@oinume
oinume / User.java
Created November 13, 2012 16:02
FreeMarkerで余計な改行が入ってしまう例
package jp.ameba.picnic.orm.microbookmark.entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.metamodel.StaticMetamodel;
@oinume
oinume / parse_apache_log.py
Created October 11, 2012 11:26
Parsing apache log file and summarize request time.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Usage: tail -10000 <access_log> | ./parse_apache_log.py
import os
import re
import sys
class LogParser(object):
LOG_PATTERN = re.compile(r"""^(?P<remote_host>[0-9]{,3}\.[0-9]{,3}\.[0-9]{,3}\.[0-9]{,3}) (?P<ident>[^ ]{1,}) (?P<remote_user>[^ ]{1,}|\-) \[(?P<datetime>[0-9]{2}\/[A-Za-z]{3}\/[0-9]{1,4}:[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2} [+\-][0-9]{4})\] "(?P<method>[A-Z ]+) (?P<uri>[^"]*) (?P<protocol>[^"]*)" (?P<status>[0-9]{3}) (?P<bytes>[0-9]{1,}|\-) "(?P<referer>[^"]*|\-)" "(?P<user_agent>[^"]+)" (?P<elapsed>[\d]+)$""")