Skip to content

Instantly share code, notes, and snippets.

@tkuchiki
tkuchiki / redis.init
Last active December 29, 2015 12:59
redis template
#!/bin/sh
#
# redis init file for starting up the redis daemon
#
# chkconfig: - 20 80
# description: Starts and stops the redis daemon.
# Source function library.
. /etc/rc.d/init.d/functions
@tkuchiki
tkuchiki / template_luajit.spec
Last active December 29, 2015 14:49
luajit rpmbuild
VERSION=2.0.2
MAJOR_VERSION=`echo $VERSION | cut -d . -f 1`
MINOR_VERSION=`echo $VERSION | cut -d . -f 2`
LIBVERSION=5.1
LUAJIT_DIR=LuaJIT-$VERSION
LUAJIT_SRC=$LUAJIT_DIR.tar.gz
RPM_BUILD_DIR=$HOME/rpmbuild
LUAJIT_SOURCES=$RPM_BUILD_DIR/SOURCES
LUAJIT_SPEC=$RPM_BUILD_DIR/SPECS/luajit.spec
@tkuchiki
tkuchiki / gist:7687626
Created November 28, 2013 05:25
yumdownloader
# install yumdownloader
yum install -y yum-utils
# download rpm
yumdownload PACKAGE
# download src rpm
yumdownload --source PACKAGE
@tkuchiki
tkuchiki / 50x.html
Last active December 29, 2015 15:19
nginx rpmbuild(built in lua-module, perl-module)
<!DOCTYPE html>
<html>
<head>
<title>Error</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
@tkuchiki
tkuchiki / gist:7695918
Last active May 6, 2019 15:51
perl-Test-Nginx rpm build
VERSION=0.22
TEST_NGX_DIR="Test-Nginx-${VERSION}"
TEST_NGX_SRC="${TEST_NGX_DIR}.tar.gz"
RPM_BUILD_DIR=$HOME/rpmbuild
RPM_BUILD_SOURCES=$RPM_BUILD_DIR/SOURCES
RPM_BUILD_SPECS=$RPM_BUILD_DIR/SPECS
SPEC=perl-Test-Nginx.spec
TEST_NGX_SPEC=$RPM_BUILD_SPECS/$SPEC
yum install -y cpan cpanspec perl-libwww-perl perl-URI perl-List-MoreUtils perl-Text-Diff perl-Test-LongString perl-Test-Base perl-Time-HiRes
@tkuchiki
tkuchiki / gist:7744641
Last active December 29, 2015 23:39
KVM disk 拡張
sleep を挟みながら、1G くらいずつ足していく
# よくない方法
# 10G 追加
dd if=/dev/zero of=./add_disk.img bs=1G count=10
cat add_disk.img >> disk.img
@tkuchiki
tkuchiki / gist:7804112
Last active December 30, 2015 08:39
install mysql (yum)
rpm -ivh http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
yum install -y mysql-community-server
service mysqld start
@tkuchiki
tkuchiki / gist:7804211
Last active December 30, 2015 08:39
nginx rds-
mysql> CREATE DATABASE test_db DEFAULT CHARACTER SET utf8;
mysql> CREATE TABLE test_db.users (id int(11) unsigned AUTO_INCREMENT, username varchar(512), password varchar(512), PRIMARY KEY (id));
mysql> INSERT INTO test_db.users (username, password) VALUES ('foo', '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33'), ('bar', '62cdb7020ff920e5aa642c3d4066950dd1f01f4d');
# mysql> GRANT ALL PRIVILEGES ON *.* TO [email protected] IDENTIFIED BY 'test' WITH GRANT OPTION;
# mysql> GRANT ALL PRIVILEGES ON *.* TO test_user@localhost IDENTIFIED BY 'test' WITH GRANT OPTION;
# mysql> FLUSH PRIVILEGES;
@tkuchiki
tkuchiki / ngx_openresty.spec
Last active December 30, 2015 08:39
spec ngx_openresty
# add epel repo
yum install -y libdrizzle libdrizzle-devel pcre pcre-devel openssl openssl-devel zlib zlib-devel readline readline-devel libxml2 libxml2-devel libxslt-devel perl perl-devel perl-ExtUtils-Embed perl-ExtUtils-ParseXS GeoIP-devel gd-devel
@tkuchiki
tkuchiki / _upload_dump_header.lua
Last active December 30, 2015 16:59
nginx lua resty.upload (read http headers)
local resty_sha1 = require "resty.sha1"
local upload = require "resty.upload"
local chunk_size = 4096
local form = upload:new(chunk_size)
while true do
local typ, res, err = form:read()
ngx.say("### header 1")