Skip to content

Instantly share code, notes, and snippets.

View ijokarumawak's full-sized avatar
🎯
Focusing

Koji Kawamura ijokarumawak

🎯
Focusing
View GitHub Profile
#!/bin/sh
numberOfEvents=$1
fluentdUrl=$2
USAGE="send-events-to-fluentd.sh numberOfEvents fluentdUrl"
if [[ $# -ne 2 ]]; then
echo $USAGE
exit 1
fi
@ijokarumawak
ijokarumawak / Vagrantfile
Created April 7, 2014 06:29
Setup Ansible control server using Vagrant
config.vm.provision "shell", path: "provision.sh"
@ijokarumawak
ijokarumawak / elasticsearch.yml
Created April 15, 2014 06:02
Installing Elasticsearch and Couchbase transport plugin via Ansible using elasticsearch role
- name: Install Elasticsearch
hosts: rails.myvm
sudo: true
vars:
elasticsearch_install_java: true
elasticsearch_timezone: Asia/Tokyo
elasticsearch_plugins:
- name: 'transport-couchbase'
url: 'http://packages.couchbase.com.s3.amazonaws.com/releases/elastic-search-adapter/1.2.0/elasticsearch-transport-couchbase-1.2.0.zip'
- name: 'mobz/elasticsearch-head'
@ijokarumawak
ijokarumawak / CBL local Java thread dump
Last active May 3, 2016 08:34
couchbase lite local hangs with _replicate request
Running local couchbase lite instance
username: d4b724ee-131b-468e-b3ab-953d6fef2686
password: fcd11474-53db-44f8-b865-91d3fefe1779
http://d4b724ee-131b-468e-b3ab-953d6fef2686:fcd11474-53db-44f8-b865-91d3fefe1779@localhost:5984
Press Ctrl-C to shutdown
[Fri Apr 24 06:10:23 JST 2015] TJWS httpd 0.0.0.0 - SimpleAcceptor ServerSocket[addr=0.0.0.0/0.0.0.0,localport=5984] is listening.
2015-04-24 06:14:41
Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.25-b02 mixed mode):
@ijokarumawak
ijokarumawak / sync-streaming.js
Last active August 29, 2015 14:20
Drawing realtime graph with SyncGateway and Plot.ly
/*
# ===================
# How to execute
# ===================
# Install dependencies.
$ npm install plotly
$ npm install request
$ npm install moment
# Execute.
$ node sync-streaming.js
String query = "SELECT airportname FROM `" + bucket.name()
+ "` WHERE type = 'airport' ORDER BY airportname ASC";
N1qlQueryResult result = bucket.query(N1qlQuery.simple(query));
List<String> airports = new ArrayList<>();
for(N1qlQueryRow row : result){
airports.add(row.value().getString("airportname"));
}
return airports;
SimpleQuery query = Query.simple(
select("airportname").from(i(bucket.name())).where(
x("type").eq(s("airport"))
.and(x("airportname").like(s(prefix + "%")))
).orderBy(asc(x("airportname")))
);
logger.info(query.statement());
QueryResult result = bucket.query(query);
List<String> airports = new ArrayList<>();
import static com.couchbase.client.java.query.Select.select;
import static com.couchbase.client.java.query.dsl.Expression.i;
import static com.couchbase.client.java.query.dsl.Expression.s;
import static com.couchbase.client.java.query.dsl.Expression.x;
import static com.couchbase.client.java.query.dsl.Sort.asc;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class AirportController {
private final Bucket bucket;
private final Log logger = LogFactory.getLog(getClass());
public List<String> airportNamesStartingWith(@RequestParam String prefix) {
N1qlQuery query = ...;
logger.trace(query.statement());