Skip to content

Instantly share code, notes, and snippets.

@aficionado
aficionado / 5400ebc59841fa7f50000811.json
Last active August 29, 2015 14:05
Psychsignal - APPL - Anomalies
{"fields": [{"optype": "categorical", "name": "Symbol", "datatype": "string", "preferred": false, "summary": {"missing_count": 0, "categories": [["AAPL", 911]]}, "term_analysis": {"enabled": true}, "column_number": 0, "id": "000000", "order": 0}, {"optype": "numeric", "name": "Open", "datatype": "double", "preferred": true, "summary": {"sum_squares": 4538487.31442, "splits": [47.73657, 48.60528, 49.42383, 50.32761, 51.74761, 54.02171, 55.52738, 56.79641, 57.76227, 59.9516, 61.06254, 62.37242, 63.80142, 65.21705, 66.59425, 69.96617, 71.737, 73.4288, 74.5442, 75.40514, 76.37247, 77.41663, 78.94439, 80.4674, 81.69666, 83.33576, 85.10045, 86.52656, 88.70865, 91.0064, 94.91478], "missing_count": 0, "sum": 62989.7769, "median": 69.96617, "maximum": 100.3443, "minimum": 45.24, "standard_deviation": 14.18676, "variance": 201.2641, "population": 911, "bins": [[45.38, 3], [47.65305, 53], [49.44396, 58], [51.25244, 38], [53.27143, 16], [54.46864, 20], [55.68153, 32], [57.46563, 54], [60.00132, 26], [61.1975, 32], [62.94
{"fields": [{"optype": "numeric", "name": "pregnancies", "datatype": "int8", "preferred": true, "summary": {"sum_squares": 20063, "missing_count": 0, "sum": 2953, "median": 2.96687, "maximum": 17, "minimum": 0, "standard_deviation": 3.36958, "variance": 11.35406, "counts": [[0, 111], [1, 135], [2, 103], [3, 75], [4, 68], [5, 57], [6, 50], [7, 45], [8, 38], [9, 28], [10, 24], [11, 11], [12, 9], [13, 10], [14, 2], [15, 1], [17, 1]], "population": 768, "mean": 3.84505}, "column_number": 0, "id": "000000", "order": 0}, {"optype": "numeric", "name": "plasma glucose", "datatype": "int16", "preferred": true, "summary": {"sum_squares": 12008759, "splits": [73.40028, 80.70976, 84.56046, 88.29697, 91.0653, 94.02324, 96.37393, 99.15167, 100.81422, 102.99865, 105.47912, 107.37394, 109.45106, 111.68975, 114.22117, 116.8391, 119.5, 122.06267, 124.31608, 126.65592, 129.19127, 132.64738, 136.8101, 140.43237, 144.72673, 148.62092, 155.01649, 161.85305, 168.92, 178.9276, 187.59806], "missing_count": 0, "sum": 92847, "median":

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called (Functional) Reactive Programming (FRP).

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

This variation of a clustered force layout uses an entry transition and careful initialization to minimize distracting jitter as the force simulation converges on a stable layout.

By default, D3’s force layout randomly initializes node positions. You can prevent this by setting each node’s x and y properties before starting the layout. In this example, because custom forces cluster nodes by color, most of the initial jitter is caused by the initial random placement overlapping clusters. We can reduce the jitter by initially placing nodes of the same color near other.

The number of clusters in this example is defined by the variable m; the local variable i is the node’s cluster number. To initialize clusters in a circle of radius 200px around the canvas center, we can define x and y like so:

x: Math.cos(i / m * 2 * Math.PI) * 200 + width / 2 + Math.random(),
y: Math.sin(i / m * 2 * Math.PI) * 200 + height / 2 + Math.r
build
@aficionado
aficionado / browser_train.csv
Last active August 29, 2015 13:57
Mini App
user_agent wants_api
Mozilla/5.0 (Windows NT 6.1; WOW64; rv no
Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 Safari/537.36 no
Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36 no
Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36 no
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv no
Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 Safari/537.36 no
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36 no
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Safari/537.36 no
Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Safari/537.36 no
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>BigML Prediction Test</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<script src="http://code.jquery.com/jquery-1.7.1.js" type="text/javascript"></script>
# Dataset with historical data
dataset = ‘dataset/52cb5ac7035d072695000bc6’
# Source data of day i
source_day_i = api.create_source(“day-i.csv”)
dataset_day_i = api.create_dataset(source_day_i)
# Test for covariate shift
if not detect_shfit(dataset, dataset_day_i,
training_sample_size, daily_data_sample_size, trials):
@aficionado
aficionado / covariate_shift.sh
Created January 3, 2014 00:21
Simple test to detect covariate shift
#!/bin/bash
# Simple test to detect covariate shift.
# Requires:
# BIGML_AUTH set up with your BIGML_USERNAME and API_KEY
# curl: http://curl.haxx.se/
# jq: http://stedolan.github.io/jq/
BIGML_DOMAIN=bigml.io # Set it up to your own BigML VPC domain
@aficionado
aficionado / index.html
Created December 24, 2013 01:18
Example for Petar
<!DOCTYPE html>
<meta charset="utf-8">
<style>
html, body{
height: 100%;
}
*, *:before, *:after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;