Skip to content

Instantly share code, notes, and snippets.

View DQNEO's full-sized avatar

Daisuke Kashiwagi DQNEO

View GitHub Profile
@DQNEO
DQNEO / hello.pl
Created September 18, 2010 08:04
print "Hello World!\n";
@DQNEO
DQNEO / mysql_db_document.sh
Created July 2, 2011 06:05
output MySQL Table Definitions as HTML
#!/bin/sh
## base config
MYSQL_BIN=mysql
MYSQL_USER=user
MYSQL_PASSWD=password
## dbname
if [ "$1" = "" ]; then
echo "no database name"
exit 1;
@DQNEO
DQNEO / pudding.php
Created July 7, 2011 20:02 — forked from sotarok/.gitignore
rapid and stupid search engine script for PHP source code.
#!/usr/bin/php
<?php
/**
* Hyper Pudding
* - yet another rapid and stupid search engine for PHP source code. -
*
* @author DQNEO (forked from sotarok)
* @see http://www.slideshare.net/sotarok/php-source-code-search-with-php
* @versoin 0.0.1
* @license The MIT License
@DQNEO
DQNEO / Constructor.php
Created October 16, 2011 18:38
__constructの落とし穴。parent::ClassName()で呼び出すとFatal Errorになる。
<?php
class Mother
{
public function __construct()
{
echo "I am Mother. \n";
}
}
class Child extends Mother
@DQNEO
DQNEO / jpegs2json.pl
Created November 12, 2011 13:19
ディレクトリ内のjpegファイル一覧を抽出してJavascriptのarrayに変換するスクリプト
use strict;
use warnings;
use List::Util;
my @photos = List::Util::shuffle glob('*.jpg');
print "var photos = [\n";
for my $photo (@photos) {
print "'$photo',\n";
}
@DQNEO
DQNEO / Explain Analyze
Created November 13, 2011 17:21
とあるPostgreSQLのスロークエリ
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Sort (cost=1568.27..1568.51 rows=96 width=260) (actual time=822.175..822.259 rows=198 loops=1)
Sort Key: e.pgd, e.evtno, p.ptgno
Sort Method: quicksort Memory: 100kB
-> Nested Loop (cost=87.12..1565.11 rows=96 width=260) (actual time=15.763..821.403 rows=198 loops=1)
-> Nested Loop (cost=87.12..1309.65 rows=96 width=256) (actual time=15.729..792.478 rows=198 loops=1)
-> Hash Join (cost=87.12..1058.64 rows=96 width=256) (actual time=15.703..791.253 rows=198 loops=1)
Hash Cond: (e.grpsno = g.grpsno)
-> Nested Loop (cost=0.00..970.13 rows=112 width=226) (actual time=13.304..788.536 rows=198 loops=1)
@DQNEO
DQNEO / use_GD.pl
Created November 28, 2011 14:48
GDモジュールを使ったサンプルコード
use strict;
use warnings;
use GD;
my @files= glob("*.JPG");
my $n = @files;
print "handling $n files...\n";
@DQNEO
DQNEO / init.sh
Created January 13, 2012 17:38
サーバ構築自動化スクリプト(ただの練習用)
#!/bin/bash
#
# ※これはただの落書きみたいなものです。マネしないで!!
#
# 1. このファイルをローカルからリモートサーバに転送する。
# scp init.sh -i key.pem root@example.com
#
# 2. リモートサーバにログインして、root権限で実行する
# $ ssh -i key.pem root@example.com
# # bash init.sh
@DQNEO
DQNEO / deploy.sh
Created January 13, 2012 18:49
簡易デプロイツール
#!/bin/bash
#
# deploy.sh : subversion用のデプロイツール
#
#
# Usage:
# deploy.sh
# 引数はありません。
#
# Output:
@DQNEO
DQNEO / check_running.sh
Created January 25, 2012 05:37
重複起動防止付きシェルスクリプト
#!/bin/bash
##
# 重複起動防止
# /tmp/{スクリプト名}.pid というファイルが作成されます。
#
# テスト方法
# while true ; do script.sh ; done
function pid_start() {