Skip to content

Instantly share code, notes, and snippets.

View keiya's full-sized avatar

keiya keiya

View GitHub Profile
@keiya
keiya / KDB.php
Created August 1, 2012 08:05
Database O/RM
<?php
/*
* KDB database wrapper by Keiya Chinen <[email protected]>
*/
class KDB {
public function __construct ($user,$pass,$db,$host) {
$this->mysqli = new mysqli($host, $user, $pass, $db);
if ($this->mysqli->connect_error) {
@keiya
keiya / fnavi-scrape.pl
Created July 26, 2012 08:33
f-navigation.jp scraping script
#!/usr/bin/perl
#
# by Keiya Chinen
use strict;
use Web::Scraper;
use URI;
use Data::Dumper;
use Time::Piece;
@keiya
keiya / watchdog.pl
Created July 16, 2012 04:35
Process watchdog script
#!/usr/bin/perl --
# process watchdog script
# Keiya Chinen <[email protected]>
use strict;
use warnings;
$| = 1;
@keiya
keiya / image_filter_test.php
Created May 29, 2012 07:59
ImageMagick Filters Test
<?php
/* image_filter_test.php
* by Keiya Chinen
*
* https://gist.github.com/2823192
*
* (MIT Licence)
* 汚いコードだなぁ
*
@keiya
keiya / README
Created May 24, 2012 16:01
Perl Multithread & Multiprocess Socket Program
サーバ:マルチプロセスモデルのEchoサーバ、1プロセス1クライアント。
クライアント:マルチスレッド(threads)のクライアント
(標準入力に1スレッド,受信(と標準出力)に1スレッド,送信に1スレッドで、情報はキューで受け渡し)
クライアントの方はなぜかシグナルハンドラがゴミでシグナルが無視される。
いちばん手間かかったのがtty周りという。stty rawとかしてる。cursesとかつかえば簡単なんだろうけど。
でもこれでssh/telnetもどきができる土俵は整ったかな。
@keiya
keiya / batch.sh
Created May 24, 2012 08:24
シェルスクリプト排他処理のサンプル
#!/bin/sh
cd /var/www/html/application/batch_scripts
LOGDIR=batch_logs
LOCKFILE=$LOGDIR/lock
trap "echo Trapped; rm -f $LOCKFILE; exit" INT QUIT TERM
# ロックファイルがあれば60秒*最大3回待機、1日前のロックファイルなら無視
#!/usr/bin/perl
#
# by Keiya Chinen
# usage:
# perl animedl.pl http://www.anime44.com/the-melancholy-of-haruhi-suzumiya-season-2-episode-8
use strict;
use warnings;
use utf8;
#!/usr/bin/perl
#
# by Keiya Chinen
use strict;
use warnings;
use utf8;
use LWP;
@keiya
keiya / ec2script.sh
Created April 10, 2012 22:22 — forked from Problematic/ec2script.sh
Amazon EC2 Setup Script
#!/bin/bash
# Script for quick configuration of an EC2 Server
# Installs the necessaries for most PHP Jobs
# Run as Root or suffer the consequences of stuff telling you it can't get a lock and whatnot
ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
cd /etc/yum.repos.d
@keiya
keiya / akb_members.pl
Created February 29, 2012 10:59
csv of akb48 members
#!/usr/bin/perl
#
# by Keiya Chinen
use strict;
use Web::Scraper;
use URI;
use Data::Dumper;
use utf8;