Skip to content

Instantly share code, notes, and snippets.

View nyurik's full-sized avatar

Yuri Astrakhan nyurik

View GitHub Profile
{
"$schema": "https://vega.github.io/schema/vega/v3.0.json",
"signals": [
{
"name": "count",
"value": 10,
"bind": {"input": "select", "options": [1, 5, 10, 20]}
},
{
"name": "points",
@nyurik
nyurik / vl.json
Created September 30, 2017 19:42
Shows warnings
{
"$schema": "https://vega.github.io/schema/vega-lite/v2.0.0-beta.json",
"autosize": {"type": "fit", "contains": "padding"},
"data": {"values": [{"a": "A", "b": 28}, {"a": "B", "b": 55}]},
"mark": "bar",
"encoding": {
"x": {
"field": "a",
"type": "ordinal",
"scale": {"rangeStep": 100}
@nyurik
nyurik / TSLA.csv
Created October 5, 2017 22:32
Tesla stock prices - public domain from https://www.quandl.com/api/v3/datasets/WIKI/TSLA.csv
Date Open High Low Close Volume Ex-Dividend Split Ratio Adj. Open Adj. High Adj. Low Adj. Close Adj. Volume
2017-10-05 356.0 357.435 351.35 355.33 4102286.0 0.0 1.0 356.0 357.435 351.35 355.33 4102286.0
2017-10-04 351.25 358.62 349.6 355.01 8120353.0 0.0 1.0 351.25 358.62 349.6 355.01 8120353.0
2017-10-03 335.9 348.55 331.28 348.14 9981885.0 0.0 1.0 335.9 348.55 331.28 348.14 9981885.0
2017-10-02 342.52 343.7 335.51 341.53 4901453.0 0.0 1.0 342.52 343.7 335.51 341.53 4901453.0
2017-09-29 341.86 344.68 338.601 341.1 5062297.0 0.0 1.0 341.86 344.68 338.601 341.1 5062297.0
2017-09-28 339.88 342.75 335.4 339.6 5279310.0 0.0 1.0 339.88 342.75 335.4 339.6 5279310.0
2017-09-27 349.9 351.489 340.5 340.97 6010631.0 0.0 1.0 349.9 351.489 340.5 340.97 6010631.0
2017-09-26 350.93 351.24 340.9 345.25 7126550.0 0.0 1.0 350.93 351.24 340.9 345.25 7126550.0
2017-09-25 353.15 357.469 342.88 344.99 7542161.0 0.0 1.0 353.15 357.469 342.88 344.99 7542161.0
@nyurik
nyurik / gist:78442ad6a4218157114594c67b58272b
Created October 18, 2017 07:23
reco elasticsearch data
PUT /datareco1
{
"mappings" : {
"_default_" : {
"properties" : {
"action" : {"type": "keyword" },
"reco" : { "type" : "integer" },
"question" : {"type": "integer" },
"dimension" : {"type": "keyword" },
"yes" : { "type" : "integer" },
@nyurik
nyurik / reco1.json
Created October 18, 2017 07:51
sample data for vega scatter plot
{
"took": 1,
"timed_out": false,
"_shards": {"total": 5, "successful": 5, "failed": 0},
"hits": {
"total": 63,
"max_score": 1,
"hits": [
{
"_index": "datareco1",
@nyurik
nyurik / roco_vis.json
Last active October 18, 2017 08:26
Scatter plot using roco dataset
{
"$schema": "https://vega.github.io/schema/vega/v3.0.json",
"data": [
{
"name": "source",
"url": {
"index": "datareco1",
"body": {"query": {"match_all": {}}, "size": 10000}
},
"format": {"property": "hits.hits"}
@nyurik
nyurik / reco2.json
Created October 19, 2017 00:08
sample data for vega with dots in the names
{
"took": 1,
"timed_out": false,
"_shards": {"total": 5, "successful": 5, "failed": 0},
"hits": {
"total": 63,
"max_score": 1,
"hits": [
{
"action": "stopp",
@nyurik
nyurik / subregions.sparql
Created December 8, 2017 05:18
Query to get subregions of a given region/country from Wikidata
# Use group-by to ensure only a single ID is present (otherwise the geo service will error)
SELECT
?id
(SAMPLE(?label_en) as ?label_en)
(SAMPLE(?label_zh) as ?label_zh)
(SAMPLE(?label_fr) as ?label_fr)
(SAMPLE(?label_de) as ?label_de)
(SAMPLE(?iso_3166_2) as ?iso_3166_2)
(SAMPLE(?insee_fr) as ?insee_fr)
@nyurik
nyurik / eu_subreg.sparql
Created December 8, 2017 07:38
All european sub-regions with their languages
SELECT
?id
# remove possible duplicates
(SAMPLE(?iso_3166_2) as ?iso_3166_2)
(SAMPLE(?insee_fr) as ?insee_fr)
(SAMPLE(?flagImg) as ?flagImg)
# all of the official languages in the European Union
(SAMPLE(?label_bg) as ?label_bg)
(SAMPLE(?label_cs) as ?label_cs)
{
"$schema": "https://vega.github.io/schema/vega/v3.0.json",
"data": [
{
"name": "data",
"values": {
"aggregations": {
"pairs": {
"buckets": [
{"key": "aa:cc", "doc_count": 10},