Skip to content

Instantly share code, notes, and snippets.

View kei2100's full-sized avatar

Kei Arima kei2100

  • Japan
  • 19:23 (UTC +09:00)
View GitHub Profile
@kei2100
kei2100 / gist:5c14f3163b1d85331e83
Last active August 29, 2015 14:06
mysql yum install
yum install http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
yum install mysql mysql-community-devel mysql-community-server
edit my.cnf
mysql_install_db
/etc/init.d/mysqld start
CREATE DATABASE mydb;
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypass' WITH GRANT OPTION;
@kei2100
kei2100 / mysql dump database
Created October 27, 2014 04:07
mysql dump database
mysqldump -uroot --opt {database} > {database}.dump
mysqladmin -uroot create {database}
mysql -uroot {database} < {database}.dump
@kei2100
kei2100 / proxy.js
Created October 30, 2014 06:52
local tcp proxy using tcp-proxy.js
var tcpProxy = require('tcp-proxy');
var servers = [];
[
{dst: '192.168.33.10:3306', src: 3306},
{dst: '192.168.33.10:6379', src: 6379},
{dst: '192.168.33.10:11211', src: 11211}
].forEach(function(config) {
var destHost = config.dst.split(':')[0];
@kei2100
kei2100 / gist:ac19822280dc4aff997a
Created December 27, 2014 08:40
Java grep stacktrace log
pcregrep -nM '^.+\n(\w+\.)+\w*Exception:.*(\n\s+at .+|\nCaused by: .+(\n### .+)*)+' log
@kei2100
kei2100 / HotpUtil.java
Last active August 29, 2015 14:16
RFC4226 HOTP generator
import org.apache.commons.codec.digest.HmacUtils;
import java.nio.ByteBuffer;
public class HotpUtil {
private static final int LONG_BYTE_SIZE = Long.SIZE / Byte.SIZE;
private static final int MAX_DIGITS = 9;
@kei2100
kei2100 / redis-server
Created February 14, 2012 01:57 — forked from masuidrive/redis-server
/etc/init.d/redis-server
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db
@kei2100
kei2100 / out_redis_sample.rb
Created February 15, 2012 12:12
Fluentd Redis out plugin sample
class RedisOutput < Fluent::BufferedOutput
# Register plugin first. NAME is the name of this plugin
# which is used in the configuration file.
Fluent::Plugin.register_output('redis_sample', self)
def initialize
require 'msgpack'
require 'redis'
super
end
@kei2100
kei2100 / closer_test
Created December 8, 2015 13:07
closer test golang
// Try to close the reader if the io.Closer interface is implemented
if closer, ok := src.(io.Closer); ok {
closer.Close()
}
@kei2100
kei2100 / JMagick Eclipse Webapp Setting
Created February 3, 2013 15:14
JMagick Eclipse Webapp Setting
* add jmagick.jar > Java Build Path Entries
* add jmagick.jar > Deployment Assembly
* jmagick.systemclassloader setting
static {
System.setProperty("jmagick.systemclassloader","false");
}
or
@kei2100
kei2100 / apache_response_time.py
Last active December 20, 2015 16:39
munin script for apache response time
#!/usr/bin/env python
import sys
import os.path
import re
from subprocess import *
LAST_N_REQUESTS = 50000
LOG_PATH = '/usr/local/apache/logs/access.log'
LOG_OPEN_COMMANDS = [
('tail', '-n %d' % LAST_N_REQUESTS, LOG_PATH),