Skip to content

Instantly share code, notes, and snippets.

View ceekz's full-sized avatar

Mitsuo Yoshida ceekz

View GitHub Profile
@ceekz
ceekz / pin.cgi
Created June 20, 2014 06:36
Create an access token from a consumer key in Twitter.
#!/usr/bin/perl
use strict;
use warnings;
use CGI;
use Net::Twitter;
my $cgi = new CGI;
/IPAGothic << /FileType /TrueType /Path (/usr/share/fonts/ipa-gothic/ipag.ttf) /CSI [(Japan1) 6] >> ;
/IPAMincho << /FileType /TrueType /Path (/usr/share/fonts/ipa-mincho/ipam.ttf) /CSI [(Japan1) 6] >> ;
/IPAPGothic << /FileType /TrueType /Path (/usr/share/fonts/ipa-pgothic/ipagp.ttf) /CSI [(Japan1) 6] >> ;
/IPAPMincho << /FileType /TrueType /Path (/usr/share/fonts/ipa-pmincho/ipamp.ttf) /CSI [(Japan1) 6] >> ;
/#82l#82r#20#83S#83V#83b#83N /IPAGothic ;
/#82l#82r#83S#83V#83b#83N /IPAGothic ;
/@#82l#82r#83S#83V#83b#83N /IPAGothic ;
/DFHSGothic-W5 /IPAGothic ;
/DFPHSGothic-W5 /IPAGothic ;
@ceekz
ceekz / mrtg.cfg
Last active August 29, 2015 14:05
# indexmaker --columns=1 /etc/mrtg/mrtg.cfg > /var/www/mrtg/index.html
WorkDir: /var/www/mrtg
Target[eth0]: \eth0:private@localhost:
SetEnv[eth0]: MRTG_INT_IP="localhost" MRTG_INT_DESCR="eth0"
MaxBytes[eth0]: 125000000
Options[eth0]: growright, bits
Title[eth0]: eth0
PageTop[eth0]: <h1>eth0</h1>
@ceekz
ceekz / Mecab.cs
Created September 15, 2014 06:54
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace MecabWrapper
{
public class Mecab
{
@ceekz
ceekz / gist:0ad19287e32d0cb514c7
Last active August 29, 2015 14:13
up/down concordance rate
sub udcr {
my ($X, $Y) = @_;
if (scalar(@{$X}) < 2 || scalar(@{$X}) != scalar(@{$Y})) {
return;
}
my $j = 0;
for (my $i = 1; $i < scalar(@{$X}); $i++) {
my $_x = $X->[$i] - $X->[$i - 1];
@ceekz
ceekz / dbbackup.sh
Last active October 7, 2015 03:37
Backup shell script for MySQL
#!/bin/sh
keepday=14
dir=/home/dbbackup
file=dump.sql
now_date=`date +%Y%m%d`
old_date=`date "-d$keepday days ago" +%Y%m%d`
cd $dir
@ceekz
ceekz / wget_wrapper.pl
Last active October 7, 2015 03:37
Wget Wrapper for a Web Page Cache
#!/usr/bin/perl
# Wget のラッパー
# 任意の URL のページを画像込みで保存する
# $ wget_wrapper.pl Directory URL
# (Directory は URL ごとにユニークなものを指定する)
#
# .htaccess 設定例
# AddType text/html .htmlwget
# DirectoryIndex index.htmlwget index.html index.htm
@ceekz
ceekz / gist:3099041
Created July 12, 2012 16:03
An IP address is used at random.
# サーバに割り当てた任意の IP アドレスを利用する
# (本コードではランダムに選択)
use LWP::UserAgent (@LWP::Protocol::http::EXTRA_SOCK_OPTS);
# ランダムに IP を選択
{
my @IP = qw(
203.0.113.1
203.0.113.2
use List::Util;
sub add_cloud_font_size {
my ($font_size_min, $font_size_max, $val_col, @lists) = @_;
if (scalar(@lists) == 0) {
return;
}
my $val_min = log(List::Util::min(map { $_->{$val_col} } @lists) + 1);
my $val_max = log(List::Util::max(map { $_->{$val_col} } @lists) + 1);
@ceekz
ceekz / sign_test.pl
Last active December 15, 2015 02:09
# Reference:
# http://aoki2.si.gunma-u.ac.jp/lecture/Average/sign-test.html
# http://kusuri-jouhou.com/statistics/fugou.html
use strict;
use warnings;
use List::Util;
my @sign = qw(1 0 1 1 -1 1 1 -1 1 1);