Skip to content

Instantly share code, notes, and snippets.

View xtetsuji's full-sized avatar

OGATA Tetsuji xtetsuji

View GitHub Profile
@xtetsuji
xtetsuji / QudoWorker.pm
Created March 25, 2014 01:41
Qudo, a perl one of jobqueue system's sample.
package My::QudoWorker;
use base 'Qudo::Worker';
use Data::Dumper;
sub work {
my ($class, $job) = @_;
print $job->arg; #print $user->email;
@xtetsuji
xtetsuji / battery-watchd
Created April 18, 2014 18:01
Battery watcher and observer for Mac and Linux laptop.
#!/usr/bin/env perl
# xtetsuji by 2014/04/19
our $VERSION = "0.01";
use strict;
use warnings;
use utf8;
use AnyEvent;
@xtetsuji
xtetsuji / mydb-insert.pl
Created April 20, 2014 08:05
Perl SQLite connection, insert and select sample for beginner education. (ビギナー教育用の簡単なPerl SQLite接続とINSERTとSELECTのサンプル)
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
binmode STDOUT, ':utf8';
use DBI;
my $dbfile = "mydb.sqlite3";
my $dbh = DBI->connect("dbi:SQLite:dbname=$dbfile","","");
#!/bin/bash
# plenvを自動的に入れてくれるやつです
set -e
if [[ $(which plenv 2> /dev/null) ]]; then
echo 'plenv already installed.'
elif [[ ! $(which git) ]]; then
echo 'git is not installed!!!!!!!'
exit 1;
@xtetsuji
xtetsuji / README.md
Created June 1, 2014 15:53
In my Mac OS X enviromnent, when it changes Wi-Fi network, then some processes is called system by Perl Cocoa::* modules, and ancient wakeonlan.

#NAME

macwland - Mac 無線変更検知フレームワークのサンプル

#SYNOPSIS

macwland &

#DESCRIPTION

@xtetsuji
xtetsuji / check_mysql_slavestatus
Last active August 29, 2015 14:05 — forked from taka3110/check_mysql_slavestatus.sh
Nagios plugin of MySQL slave check from "SHOW SLAVE STATUS".
#!/bin/sh
#
# Forked at 2014/08/12
# Modifier: OGATA Tetsuji <github:xtetsuji>
# Source: https://gist.github.com/xtetsuji/d82125bfab2247d6cc96
#
# Thanks to original:
# File: check_mysql_slavestatus.sh
# Release Version: 0.1.1
# Created 2012/12/10
@xtetsuji
xtetsuji / wget.c
Created August 21, 2014 16:04
10年くらい前の大昔に書いたwgetと同名のジョークコマンド
#include <stdio.h>
int main(int a, char *b[]) {
int i, j;
char buf[256];
char *get[6] = {
"今だ!w番ゲットォォォォ!!",
" ̄ ̄ ̄ ̄ ̄∨ ̄ ̄ ̄       (´´",
"    ∧ ∧          (´⌒(´",
"  ⊂(゚Д゚⊂⌒`つ≡≡≡(´⌒;;;≡≡≡",
"        ̄ ̄  (´⌒(´⌒;;",
@xtetsuji
xtetsuji / file-unshift-append.pl
Created August 28, 2014 04:25
Efficiency sample Perl program to append line to file's top when this file is too big on consideration RAM.
#!/usr/bin/perl
# ファイルの冒頭にデータを追加する
# open my $fh, '>>', $file; は末尾追加になるのでこれをどうするか
# 超巨大なファイルを想定して、一時ファイルを作る方法で丸呑みを最小限にして
# メモリ消費をおさえて書き直すという作戦を取る
use strict;
use warnings;
use File::Copy qw(move);
@xtetsuji
xtetsuji / plenv-check.txt
Created September 9, 2014 08:18
plenvのセットアップがうまくいかない場合にチェックする部分
### まずは ls -l ~/.plenv の中を見てみる
ogata@macbookair:~$ ls -l ~/.plenv
total 88
-rw-r--r-- 1 ogata staff 3399 2 3 2014 Changes
-rw-r--r-- 1 ogata staff 18359 2 3 2014 LICENSE
-rw-r--r-- 1 ogata staff 546 2 3 2014 Makefile
-rw-r--r-- 1 ogata staff 12025 2 3 2014 README.md
drwxr-xr-x 3 ogata staff 102 2 3 2014 author/
drwxr-xr-x 3 ogata staff 102 2 3 2014 bin/
drwxr-xr-x 4 ogata staff 136 5 27 19:56 build/
@xtetsuji
xtetsuji / localize-core-function.pl
Created October 16, 2014 06:49
Localize core function. Is this good?
#!/usr/bin/env perl
use strict;
use warnings;
BEGIN {
*CORE::GLOBAL::ref = sub { return "HELLO"; };
}
my $hash = {