Skip to content

Instantly share code, notes, and snippets.

View yoshi0309's full-sized avatar

Takumi Yoshida yoshi0309

View GitHub Profile
@yoshi0309
yoshi0309 / ExceptionHandler.java
Created July 17, 2018 06:38
CuratorFramework Experiment handling RuntimeException which throws in a Listener.
import java.util.concurrent.TimeUnit;
public class ExceptionHandler
implements Thread.UncaughtExceptionHandler {
private final long WAIT_TIME = 60L;
@Override public void uncaughtException(Thread thread, Throwable e) {
// -------------------------------------------------
// RuntimeException which was throwed in TestListener should handled here, but not.
@yoshi0309
yoshi0309 / 0_reuse_code.js
Created November 14, 2016 01:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
#!/bin/bash -ex
# run only on MASTER node.
if grep -Fq "\"isMaster\": true" /mnt/var/lib/info/instance.json ; then
# open the ssh port...
perl -pi -e 's/^#?Port 22$/Port 22\nPort 443/' /etc/ssh/sshd_config
/etc/init.d/sshd restart
# install scala and sbt.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import itertools
import csv
import datetime
import time
from math import sqrt
from operator import add
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import boto
import sys
import csv
"""
Import CSV data to your DynamoDB.
usage : importCSV2DDB.py -f <csv filepath>
@yoshi0309
yoshi0309 / td-agent.conf
Created October 27, 2014 01:59
td-agent.conf for Solr log for parsing query log.
<source>
type tail
path /opt/solr/solr-4.9.0/example/logs/solr.log
pos_file /var/log/td-agent/solr.log.pos
tag raw.solr.log
format /^(?<loglevel>[^ ]*) (?<hyp>[^ ]*) (?<time>[^ ]* [^ ]*) (?<class>[^ ]*) \[(?<core>[^ ]*)\] webapp=\/(?<webapp>[^ ]*) path=\/(?<path>[^ ]*) params={(?<params>[^ ]*)} hits=(?<hits>[^ ]*) status=(?<status>[^ ]*) QTime=(?<Qtime>[^ ]*) /
time_format %Y-%m-%d %H:%M:%S.%L;
</source>
<match raw.solr.log>
@yoshi0309
yoshi0309 / ElasticsearchRecordWriter.java
Created October 22, 2014 04:55
ElasticsearchRecordWriter.java (using JSON over HTTP not API)
package com.yoslab.process.writer;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.URISyntaxException;
import java.util.ArrayList;
{
"template" : "logstash-*",
"mappings": {
"solr_log": {
"properties": {
"@log_name": {
"type": "string",
"index" : "not_analyzed"
},
"@timestamp": {
@yoshi0309
yoshi0309 / event.py
Last active August 29, 2015 14:07
Connpass Event Classifiere using Pocket - Jubatus Hackathon - Team Paper.
#!/usr/bin/env python
# coding: utf-8
# jubatus server info.
host = 'localhost'
port = 9199
import sys
import json
import random
#!/bin/bash -ex
exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1
perl -pi -e 's/^#?Port 22$/Port 22\nPort 443/' /etc/ssh/sshd_config
/etc/init.d/ssh stop
/etc/init.d/ssh start