Skip to content

Instantly share code, notes, and snippets.

View demmer's full-sized avatar

Michael Demmer demmer

View GitHub Profile
@demmer
demmer / slack-messages-by-user.py
Created December 2, 2016 22:59
count slack messages posted to a channel by user
#!/usr/bin/python
'''
Script to count messages by user posted to a channel for a given date range.
Install:
# sudo pip install slackclient
Also you will need to obtain a slack API token:
https://api.slack.com/docs/oauth-test-tokens
@demmer
demmer / extendable-base-to-es6-class.js
Created February 5, 2016 01:12
converter script to translate extendable-base classes into ES6 classes
#!/usr/bin/env node
//
// Script to convert any extendable-base derived classes in the specified
// files into proper ES6 classes.
//
// Along the way it will remove any require() statements for extendable-base
// itself, convert any prototype literals into ES6 properties, and add the
// appropriate superclass constructor invocations to get the same behavior as
// the extendable-base initialize chain.
//
@demmer
demmer / README.md
Last active January 28, 2016 17:28
Juttle API Proxy Example

Juttle API Proxy

This is a simple proof-of-concept example of how one could embed Juttle-powered charts and visualizations in a custom application.

Installing / Running

Requires node.js to be installed.

@demmer
demmer / main.juttle
Created July 28, 2015 16:45
silly twitter analytics
// silly little juttle that compares the twitterati
(
emit -limit 1 | put name='demmer', tweets=12, followers=33, first_tweet=:2015-06-02:;
emit -limit 1 | put name='apurva', tweets=81, followers=71, first_tweet=:2002-06-18:;
emit -limit 1 | put name='henri', tweets=121, followers=61, first_tweet=:2007-12-31:;
)
| put followers_per_day = Duration.get(:now: - first_tweet, "days")
| put followers_per_tweet = followers / tweets
|(
@barchart -title "Followers" -valueField 'followers' -categoryField 'name';
@demmer
demmer / main.juttle
Last active August 29, 2015 14:25
Simple Input Controls
// Simple example of using input controls as parameters
input message: text -label 'Message to show' -default 'Testing...';
input num_points: dropdown -items [1,2,3,4,5,6,7,8] -label 'Number of points' -default 5;
emit -limit num_points
| put message="${message} ${count()}"
| @tile
@demmer
demmer / main.juttle
Created July 23, 2015 13:15
Combining Inputs with Juttle
// Prompt for a time duration and a threshold parameter
input duration: duration -label 'Time period';
input threshold: number -label 'Max response time (ms)' -default 500;
// Use these inputs to filter out only hosts that have experienced high response times
// during the specified time period.
input host: combobox -juttle "read -demo 'srch_cluster' -last :${duration}: name = 'response_ms' | filter value > ${threshold} | reduce by host"
-valueField 'host' -label 'Hosts with response time > ${threshold} ms';
// Once a host is selected, show the response time chart
@demmer
demmer / main.juttle
Last active August 29, 2015 14:10
Playground launch countdown
// Simple juttle program to show a big metric tile counting down the time until
// the launch of playground
const launch = :2014-12-10 12:10:14 PST:;
function format(value) {
var days = Duration.get(value, 'day');
var hours = Duration.get(value, 'hour');
var minutes = Duration.get(value, 'minutes');
var seconds = Duration.get(value, 'seconds');
@demmer
demmer / git-log2json.js
Created November 24, 2014 18:58
Convert a git commit log into JSON
#!/usr/bin/env node
//
// Converts a git log into a JSON array including the full commit message.
//
var cp = require('child_process');
var formats = {
author: '%an',
email: '%ae',
@demmer
demmer / README.md
Last active August 29, 2015 14:10
Juttle wordcloud

Juttle Wordcloud

This gist adapts a wordcloud visualization from http://www.jasondavies.com/wordcloud/ as a Juttle view, adding transitions between batches for updates.

As a silly little showcase, the demonstration program calculates a frequency count of words from Dr Seuss' "The Cat in the Hat" (text pulled from http://paulandlizdavies.com/poems/cat.htm) by splitting the words from each page into separate points, then counting the words by frequency and showing them in the wordcloud and a barchart.

@demmer
demmer / README.md
Last active August 29, 2015 14:09
Live Joins

Live Joins

Juttle's powerful join functionality allows you to join your local data with data stored anywhere else. What's more, you can do streaming joins where points are joined as they come in.

Here we're counting the number of server errors triggered by each user_id and joining that data to an external customer data file.

Your Turn:

  • Try changing "first_name" to "last_name" on lines 11 and 12
  • Check out the raw data from the two data sources by commenting out line 18 and adding "@table" on line 19