Skip to content

Instantly share code, notes, and snippets.

@miguno
miguno / topic-as-stream.java
Last active January 9, 2020 07:38
Kafka Streams Example: read a topic as a stream
// Create KStream from Kafka topic.
StreamsBuilder builder = new StreamsBuilder();
KStream<String, String> stream =
builder.stream("input-topic", Consumed.with(Serdes.String(), Serdes.String()));
@miguno
miguno / aggregation.java
Last active April 13, 2022 13:02
Kafka Streams Example: Continuously aggregating a stream into a table
// Continuously aggregating a KStream into a KTable.
KStream<String, String> locationUpdatesStream = ...;
KTable<String, Long> locationsPerUser
= locationUpdatesStream
.groupBy((k, v) -> v.username)
.count();
@miguno
miguno / aggregation.sql
Last active January 9, 2020 22:15
ksqlDB example: Continuously aggregating a stream into a table with a push query
-- Continuously aggregating a stream into a table with a ksqlDB push query.
CREATE STREAM locationUpdatesStream ...;
CREATE TABLE locationsPerUser AS
SELECT username, COUNT(*)
FROM locationUpdatesStream
GROUP BY username
EMIT CHANGES;
@miguno
miguno / midipipe.applescript
Last active December 5, 2022 10:55
MidiPipe AppleScript for macOS to reconfigure the AKAI APC 40 mk2 MIDI controller to execute Undo (Cmd-Z) and Redo (Shift-Cmd-Z) in Ableton Live with the controller's 'NUDGE -' and 'NUDGE +' buttons, respectively, instead of nudging the tempo.
# MidiPipe: http://www.subtlesoft.square7.net/MidiPipe.html
#
# The APC 40 out-of-the-box is great for performing, but less useful for producing because it lacks
# frequently used functionality such as Undo/Redo (doh, made a mistake) or deleting clips, for which
# you are forced to go back to mouse and keyboard.
#
# This example AppleScript shows how to use MidiPipe to re-configure the AKAI APC 40 mk2 MIDI controller
# to execute Undo (Cmd-Z) and Redo (Shift-Cmd-Z) in Ableton Live with the controller's 'NUDGE -' and 'NUDGE +'
# buttons, respectively, instead of nudging the tempo.
#
@miguno
miguno / foo.java
Last active September 27, 2019 22:46
Read KTable / TABLE from beginning (not from 'now')
StreamsBuilder#table("my-topic",
Consumed.with(AutoOffsetReset.EARLIEST));
@miguno
miguno / Mac Keyboard Symbols.md
Created September 9, 2019 19:28 — forked from Zenexer/Mac Keyboard Symbols.md
List of Mac/Apple keyboard symbols

Common symbols

Modifiers

When a key combination is displayed, the modifiers are written in the order presented here. For example, Control + Option + Shift + Command + Q would be written as ⌃⌥⇧⌘Q.

Sym Key Alt
Control
Option
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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
*
@miguno
miguno / interactive-queries_song-id.md
Created October 31, 2018 16:27 — forked from enothereska/interactive-queries_song-id.md
Get details for a particular song
# Get all the top-5 charts across all instances
$ http://localhost:7070/kafka-music/song/9
{
  "artist":"N.W.A",
  "album":"Straight Outta Compton",
 "name":"Gangsta Gangsta"
# Get all the top-5 charts across all instances
$ http://localhost:7070/kafka-music/charts/genre/punk
[
  {
    "artist":"Wheres The Pope?",
 "album":"PSI",
# Get all the top-5 charts across all instances
$ http://localhost:7070/kafka-music/charts/top-five
[
  {
    "artist":"Hilltop Hoods",
 "album":"The Calling",