Skip to content

Instantly share code, notes, and snippets.

View ijokarumawak's full-sized avatar
🎯
Focusing

Koji Kawamura ijokarumawak

🎯
Focusing
View GitHub Profile
[
{
"name": "US Airways", "flight": "US940",
"equipment": ["738"], "utc": "00:00:00",
"source": "SFO", "destination": "LAX"
},
"(中略)",
{
"name": "Delta Air Lines", "flight": "DL864",
"equipment": ["E75"], "utc": "23:49:00",
Document Id: airline_5265
{
"id": 5265,
"type": "airline",
"name": "US Airways",
"iata": "US",
"icao": "USA",
"callsign": "U S AIR",
"country": "United States"
}
// 元となるN1QLクエリ
SELECT r.* from `travel-sample` r
WHERE r.sourceairport = "SFO"
AND r.destinationairport = "LAX"
LIMIT 1;
// 結果
{
"airline": "AS",
"airlineid": "airline_439",
// r.scheduleでUNNEST
SELECT META(r).id as rid, r.airlineid, r.equipment, s.flight, s.utc
FROM `travel-sample` r
UNNEST r.schedule AS s
WHERE r.sourceairport = "SFO"
AND r.destinationairport = "LAX"
ORDER BY rid ASC, s.utc ASC
LIMIT 2;
// 結果
// r.airlineidでJOIN
SELECT META(r).id as rid, META(a).id as aid, a.name, r.equipment, s.flight, s.utc
FROM `travel-sample` r
UNNEST r.schedule AS s
JOIN `travel-sample` a ON KEYS r.airlineid
WHERE r.sourceairport = "SFO"
AND r.destinationairport = "LAX"
ORDER BY rid ASC, s.utc ASC
LIMIT 2;
@ijokarumawak
ijokarumawak / ecs_set_docker_hosts.sh
Last active February 15, 2022 11:21
Couchbase Day on ECS
#!/bin/sh
TASK_NAME=$1
if [ -z $TASK_NAME ]
then
echo ERR: missing task_name
echo usage: ecs_set_docker_hosts.sh task_name
exit 1
fi

How to name your Gist entry nicely

Every Gist entry has its own id which constructs URL. Also, every Gist entry is shown with name, however, there's no clear method to specify the name for an entry. It seems that the fist file name in alphabetical order will be used as the entry name.

So, adding a file (a markdown file would be nice) with a name starting with '_' might be a solution.

@ijokarumawak
ijokarumawak / ExecuteStreamCommandExample.xml
Last active February 15, 2022 11:20
NiFi Template Files
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<template>
<description>GenerateFlowFileで生成したtextデータをExecuteStreamCommandでwcコマンドに渡し、wcの結果をLogAttributeで出力します。</description>
<name>ExecuteStreamCommandExample</name>
<snippet>
<connections>
<id>6458677b-cfba-442c-8d6f-c90a8f0c67ee</id>
<parentGroupId>7d6ffdcd-6518-4bff-9b25-31ae93f65c01</parentGroupId>
<backPressureDataSizeThreshold>0 MB</backPressureDataSizeThreshold>
<backPressureObjectThreshold>0</backPressureObjectThreshold>
try (
final PipedOutputStream outputStream = new PipedOutputStream();
final PipedInputStream inputStream = new PipedInputStream(outputStream);
final ReadableByteChannel channel = Channels.newChannel(inputStream);
) {
new Thread(() -> {
try {
for (int i = 0; i < 10; i++) {
Thread.sleep(300);
outputStream.write(("idx:" + i).getBytes());
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><template encoding-version="1.0"><description>Sending data via Site-to-Site using HTTP to itself.</description><name>http-site-to-site-send</name><snippet><connections><id>9b9e5c8e-4767-485a-a258-08d40a0acbef</id><parentGroupId>37b7ad42-8ab2-4d8e-90d3-332fe18fe096</parentGroupId><backPressureDataSizeThreshold>0 MB</backPressureDataSizeThreshold><backPressureObjectThreshold>0</backPressureObjectThreshold><destination><groupId>37b7ad42-8ab2-4d8e-90d3-332fe18fe096</groupId><id>295693bf-f0e1-46fc-82bb-f4b6549b233c</id><type>PROCESSOR</type></destination><flowFileExpiration>0 sec</flowFileExpiration><labelIndex>1</labelIndex><name></name><selectedRelationships>success</selectedRelationships><source><groupId>37b7ad42-8ab2-4d8e-90d3-332fe18fe096</groupId><id>aa4bd298-d727-41d3-8c4c-4eabe57d569f</id><type>PROCESSOR</type></source><zIndex>0</zIndex></connections><connections><id>6eb5ccba-c711-4da2-9b91-23b7341d2f55</id><parentGroupId>37b7ad42-8ab2-4d8e-90d3-332fe1