Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Thomas Darimont thomasdarimont

🏠
Working from home
View GitHub Profile
@thomasdarimont
thomasdarimont / format.js
Last active Aug 29, 2015
Nice sprintf-Style placeholder replacement in format strings (only %s supported)
View format.js
function format(format, a, b, c, d, e, f){
if (format === undefined) {
return "";
}
var idx = 0;
var args = [a, b, c, d, e, f];
return format.replace(/%s/g, function() { return args[idx++]; });
View DglSolverExample.java
package de.tutorials.training.math;
import de.tutorials.training.JavaFxUtil;
import javafx.application.Application;
import javafx.collections.ObservableList;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.chart.LineChart;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.XYChart;
@thomasdarimont
thomasdarimont / ReplaySourceOptionsMetadata.java
Last active Aug 29, 2015
replay: A prototypic XD source module definition that is able to replay pre-recorded events from a file. Allows to configure a fixed delay in milliseconds or an SpEL expression that the module waits for issuing a new event.
View ReplaySourceOptionsMetadata.java
/*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
View SnapToCurrentTimeWindowExample.java
package de.tutorials.training;
import java.time.LocalDateTime;
public class SnapToCurrentTimeWindowExample {
public static void main(String[] args) {
LocalDateTime ldt = LocalDateTime.of(2013,9,1,13,39,0);
System.out.println(ldt);
@thomasdarimont
thomasdarimont / XD Stream Definition.md
Last active Aug 29, 2015
Example for a custom groovy based XD aggregator that is able to combine multiple messages for a logical group when a "group change" is detected.
View XD Stream Definition.md

Stream definition

stream create --name simple --definition "http --outputType=application/x-xd-tuple | script --location=aggregate.groovy | filter --expression=!payload.isEmpty() | splitter | log" --deploy

Post http data

http post --target http://localhost:9000 --contentType application/json --data "{ \"ts\":1, \"house_id\":1, \"plug_id\":0, \"load\":11}"
@thomasdarimont
thomasdarimont / Redis-time-series.md
Last active Aug 29, 2015
Redis-time-series: key, value scheme and data structure
View Redis-time-series.md

Scenario

In a stream processing context I want to store sensor readings over time with redis.

I have multiple sensors (~2k) that and potentially mutiple readings, e.g. value1, value2, value3 that can happen at a fixed rate for some sensor (e.g. every second) or at arbitrary points in time for other sensors.

Later I want to be able to load the time-series data, completly as well as just a slice, from redis in order to plot them, values since start with dynamic updates.

Values should be stored as key-value pairs.

View generate_linear_regression_models.R
require(stringr)
require(pmml)
require(RODBC)
channel <- odbcConnect("PostgreSQL35W32")
#for(houseId in 0:39){
houseId <- "*"
View agg_load_min_by_h.sql
copy(
with
base_data as
(
select
alm.*
, dd.day
, dd.hour
, dd.minute
from
View agg_load_min_by_h_hh_p.sql
with
base_data as (
select
s.*
, d.day
, d.hour
, d.minute
from
smart_plug_info as s
JOIN dim_date d
View agg_load_min_by_h_hh_p_sumavg.sql
with
base_data as
(
select
alm.*
, dd.day
, dd.hour
, dd.minute
, dd.hourminute
from
You can’t perform that action at this time.