Skip to content

Instantly share code, notes, and snippets.

View kinow's full-sized avatar
💭
😬

Bruno P. Kinoshita kinow

💭
😬
View GitHub Profile
@kinow
kinow / gist:dc73f4fcfbcaa0443945364a43924ae2
Last active April 11, 2020 10:37
StreamRDFWriter, and stream processing

Apache Jena project is like a box full of interesting things—at least if you love programming. One of its many features, is stream processing.

It may contain very large datasets, with gigabytes of data about graphs. Some queries may be quite large, so sending the whole result would be simply impracticable.

Instead, the data will go through ARQ. ARQ is a query engine for Jena that supports Sparql. There is one piece of code there that I found interesting while reviewing a small pull request: org.apache.jena.riot.system.StreamRDFWriter.

It is responsible for writing graph data in a streaming fashion. (See stream processing for programming models and more.)

Stream factories

@kinow
kinow / cylc_st2.md
Last active March 24, 2020 11:10
Experiments running cyclic workflows with Cylc Flow and with StackStorm st2

Running a simple cyclic workflow with Cylc Flow and with StackStorm st2

First we need a simple workflow.

[scheduling]
    initial cycle point = 20130808T00
    final cycle point = 20130809T00
    [[graph]]
 R1 = "prep => foo"
@kinow
kinow / jupyterhub-no-sudo.md
Last active February 12, 2020 00:31
JupyterHub no sudo

Avoiding sudo with JupyterHub

Goal: avoid running sudo to spawn Cylc UI Server, while still allowing the JupyterHub to run with one user, while the Cylc UI Server applications are spawned individually running with the user accounts.

The SystemdSpawner can spawn applications with the user account. But - besides requiring Systemd - the JupyterHub and systemd-run need to be both executed as root. If these constraints are OK, then this spawner is probably a solution.

Make Tree data flat again

See subscription-reply.json for an example that includes families, cycle points, tasks, jobs, etc.

See subscription-reply.json for an example of what the InfiniteTree flat tree looks like (i.e. GraphQL --> JS code to add hierarchy as in Cylc 7 --> flattree).

NOTE: open Vue Dev Tools, click on the Workflow component, search for the Tree

@kinow
kinow / debugging-cylc8-pycharm-webstorm.md
Last active February 4, 2020 03:03
Debugging Cylc 8 with PyCharm and WebStorm

Document created for Cylc meetup in NIWA Wellington on February 2020.

Cylc 8 is mainly Python for the backend, and JS for the frontend. I use PyCharm when working on the backend, and WebStorm when on the frontend.

Here's a useful page on debugging & profiling that mentions pdb too, a command line debugger.

And the following will describe how I debug Cylc with PyCharm and WebStorm, two graphical IDE's.

@kinow
kinow / cylc-postgres.md
Last active February 2, 2020 06:11
Running Cylc Flow on Postgres

Preparing the environment

The branch used for this test was this one.

After checking it out, and installing everything in a virtual environment, you will need pip and Docker (or have a running Postgres server).

# install Postgres Python driver/module
@kinow
kinow / graphql-demo.js
Last active February 3, 2020 20:45
Run a GraphQL demo server, that replies a static Cylc 8.0a2 workflow query
const express = require('express')
const bodyParser = require('body-parser')
const { graphqlExpress, graphiqlExpress } = require('apollo-server-express')
const { makeExecutableSchema } = require('graphql-tools')
const { PubSub } = require('graphql-subscriptions')
const { createServer } = require('http')
const { SubscriptionServer } = require('subscriptions-transport-ws')
const { execute, subscribe } = require('graphql')
const statuses = [
@kinow
kinow / gist:c244d227d714f8d491dc3635ec353695
Created January 11, 2020 21:01
jul log everything to console
final ConsoleHandler consoleHandler = new ConsoleHandler();
consoleHandler.setLevel(Level.FINEST);
consoleHandler.setFormatter(new SimpleFormatter());
Logger logger = Logger.getLogger("");
logger.setLevel(Level.ALL);
logger.addHandler(consoleHandler);
@kinow
kinow / index.js
Created August 31, 2019 23:59
Keep only audio icons freesfonline.de
[...(document.getElementById("stories").children)]
.filter(e => e.tagName.toLowerCase() === 'div')
.filter((e) => {
const images = [...(e.querySelectorAll('img'))];
const audioIcon = images.filter((i) => i.title.toLowerCase().includes('audio'))
return audioIcon.length === 0
})
.map((e) => e.remove())
;