Skip to content

Instantly share code, notes, and snippets.

View kei2100's full-sized avatar

Kei Arima kei2100

  • Japan
  • 02:22 (UTC +09:00)
View GitHub Profile
@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 / ulimit sysctl
Created October 30, 2015 06:15
ulimit sysctl memo
cat <<EOF >> /etc/security/limits.conf
root soft nofile 65536
root hard nofile 65536
root soft stack 16384
root hard stack 32768
root soft nproc 16384
root hard nproc 32768
* soft nofile 65536
* hard nofile 65536
@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 / 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 / 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 / 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 / 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 / webstrom_setting_memo
Created December 23, 2013 05:46
WebStorm setting memo for node.js development
Preference > JavaScript > Libraries
* Node.js vXX.XX Core Modules -> check
* Node.js Globals -> check
@kei2100
kei2100 / nodebrew.rb
Created December 21, 2013 13:49
chef recipe nodebrew
#
# Cookbook Name:: base-vagrant
# Recipe:: nodebrew
#
# Copyright 2013, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#
# install nodebrew
@kei2100
kei2100 / backup_jenkins.sh
Created December 8, 2013 05:27
Jenkins backup script
#!/bin/bash
set -e
JENKINS_HOME=
BACKUP_LOCAL_DIR=backup
RETENTION_DAYS=14
TODAY=`date +'%Y-%m-%d'`