Skip to content

Instantly share code, notes, and snippets.

@yoshi0309
yoshi0309 / App.java
Created May 19, 2014
Apache Tika 1.5 - AutoDetectParser example
View App.java
package yoshida.tika_sample;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.apache.tika.exception.TikaException;
import org.apache.tika.metadata.Metadata;
import org.apache.tika.parser.AutoDetectParser;
@yoshi0309
yoshi0309 / deleteByQuery.py
Last active Oct 26, 2018
delete documents by query result for Amazon CloudSearch.
View deleteByQuery.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import urllib
import urllib2
import json
# you need to set your domain endpoints.
SEARCH_ENDPOINT = "XXXXX.us-east-1.cloudsearch.amazonaws.com"
DOCUMENT_ENDPOINT = "XXXXX.us-east-1.cloudsearch.amazonaws.com"
@yoshi0309
yoshi0309 / mapping.json
Last active Aug 29, 2015
Dynamic mapping template for Elasticsearch 1.3.2
View mapping.json
{
"settings" : {
"index" : {
"analysis" : {
"analyzer" : {
"unigram" : {
"tokenizer" : "unigram_tokenizer"
},
"bigram" : {
"tokenizer" : "bigram_tokenizer"
View ElasticsearchRecordWriter.java
package com.yoslab.process.writer;
import java.util.List;
import org.elasticsearch.action.bulk.BulkRequestBuilder;
import org.elasticsearch.action.bulk.BulkResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
@yoshi0309
yoshi0309 / build.gradle
Created Sep 18, 2014
Gradle template for Batch Project
View build.gradle
apply plugin: "java"
apply plugin: "eclipse"
compileJava.options.encoding = "UTF-8"
//version = '0.1-SNAPSHOT'
repositories {
mavenCentral()
}
View UserData4RHEL.sh
#!/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
semanage port -m -t ssh_port_t -p tcp 443
iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT
iptables -D INPUT -j REJECT --reject-with icmp-host-prohibited
iptables -A INPUT -j REJECT --reject-with icmp-host-prohibited
service iptables save
service iptables restart
service sshd restart
View UserData4Ubuntu.sh
#!/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
@yoshi0309
yoshi0309 / event.py
Last active Aug 29, 2015
Connpass Event Classifiere using Pocket - Jubatus Hackathon - Team Paper.
View event.py
#!/usr/bin/env python
# coding: utf-8
# jubatus server info.
host = 'localhost'
port = 9199
import sys
import json
import random
View logstash_template_4_solr.json
{
"template" : "logstash-*",
"mappings": {
"solr_log": {
"properties": {
"@log_name": {
"type": "string",
"index" : "not_analyzed"
},
"@timestamp": {
@yoshi0309
yoshi0309 / ElasticsearchRecordWriter.java
Created Oct 22, 2014
ElasticsearchRecordWriter.java (using JSON over HTTP not API)
View ElasticsearchRecordWriter.java
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;
You can’t perform that action at this time.