Skip to content

Instantly share code, notes, and snippets.

@michalskop
michalskop / d3.tip.js
Last active August 29, 2015 14:03
SK-BB 2013: Map Explorer (Leaflet + D3)
// d3.tip
// Copyright (c) 2013 Justin Palmer
//
// Tooltips for d3.js SVG visualizations
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module with d3 as a dependency.
define(['d3'], factory)
} else {
@michalskop
michalskop / argentina.csv
Last active February 15, 2017 12:46
AR: Debt to Federal Government
name slug lat lon population debt
Buenos Aires buenosaires -36.380504 -60.3888875 15625084 2093
Capital Federal capital -34.6160193 -58.4355560223 2890151 4
Catamarca catamarca -27.1910825 -67.105374 367828 3257
Chaco chaco -26.3829647 -60.8816092 1055259 1622
Chubut chubut -43.7127417 -68.7461847 509108 1946
Córdoba cordoba -32.0967361 -63.7940923 3308876 3773
Corrientes corrientes -28.5912315 -57.9394658 992595 1153
Entre Ríos entrerios -31.6252842 -59.3539578 1235994 2554
Formosa formosa -24.5955306 -60.4289718 530162 6709
@michalskop
michalskop / anal.r
Last active August 29, 2015 14:02
Scatterplot with Contour Lines (D3 + R)
setwd('~/uhk/dev/ar_ondrej_plachy/institution/')
data = read.table('data.tsv',sep="\t",header=TRUE)
data$time = data$year - 1983
data$random1 = rnorm(336, mean=0, sd=0.01)
data$random2 = rnorm(336, mean=0, sd=0.01)
attach(data)
fbalm2 =
ifelse(balance_of_parties_mandates<= 0.25, '0.0-0.25',
ifelse(balance_of_parties_mandates <= 0.5, '0.25-0.5',
@michalskop
michalskop / add_parents.py
Last active March 9, 2017 00:12
EU: Elections 2014 in Czechia, PCA
# -*- coding: utf-8 -*-
# python 3
import csv
i = 0
districts2towns = {}
towns2subr = {}
subr2reg = {}
dReader = csv.reader(open('ep_2014_okrsky.csv'))
@michalskop
michalskop / ano.html
Last active August 29, 2015 14:01
EU: Elections 2014 in Czechia, detailed
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>ANO vs. 15 %</title>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css">
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="d3.tip.js"></script>
<style>
#chart {
@michalskop
michalskop / epcz_2014.json
Last active July 31, 2017 20:38
EU: Elections 2014 in Czechia and Slovakia
This file has been truncated, but you can view the full file.
{"colors": {"snk-ed": "#888", "antibursik": "#888", "kdu-csl": "#fedc35", "rds": "#888", "vize-2014": "#888", "pirati": "#000", "moravane": "#888", "usvit": "#0ff", "hss": "#888", "vv": "#888", "cssd": "#f54200", "kscm": "#ff0000", "ods": "#008", "zeleni": "#0b0", "les": "#888", "lev-21": "#888", "top-09": "#808", "ano": "#009ee0", "ksc": "#888", "aneo": "#888", "sp-a-no": "#888", "ne-brusel": "#888", "rozumni": "#888", "svobodni": "#080"}, "votes": [{"votes": ["2163", "155", "543", "1030", "12207", "2028", "63791", "2007", "986", "14678", "135", "32", "81", "23653", "34247", "79", "104", "203", "20339", "481", "3729", "16693", "17207", "129", "566", "926", "97", "643", "108", "185", "14787", "242", "423", "118", "64", "611", "932", "203"], "lat": "50.087106", "winner": "TOP 09", "id": "554782", "population": 236605, "town": "Praha", "winner_class": ["top-09"], "lng": "14.421111"}, {"votes": ["230", "62", "86", "277", "8130", "494", "11340", "355", "251", "4953", "10", "23", "17", "9354", "10273", "19", "1164
@michalskop
michalskop / epsk_2014.json
Last active August 29, 2015 14:01
EU: Elections 2014 in Slovakia
{"votes": [{"winner": "SMER", "votes": ["10059", "6922", "13554", "151", "951", "425", "47", "120", "24", "2257", "793", "466", "155", "3373", "165", "577", "411", "68", "4460", "1051", "8876", "206", "708", "161", "44", "2158", "10890", "319", "751"], "lng": "17.065659", "town": "Bratislava", "id": "1.1", "population": 70142, "winner_class": ["smer"], "lat": "48.123018"}, {"winner": "SMER", "votes": ["2336", "2937", "5497", "47", "501", "285", "13", "371", "52", "1004", "281", "131", "22", "994", "101", "178", "91", "60", "2864", "515", "2238", "179", "282", "45", "76", "670", "2455", "65", "772"], "lng": "21.262436", "town": "Ko\u0161ice", "id": "2466.1", "population": 25062, "winner_class": ["smer"], "lat": "48.73989"}, {"winner": "SMER", "votes": ["896", "1581", "2468", "66", "195", "96", "5", "22", "3", "303", "139", "104", "16", "131", "281", "135", "51", "47", "1076", "168", "1119", "25", "130", "11", "9", "412", "1027", "49", "8"], "lng": "18.7419519", "town": "\u017dilina", "id": "1285", "population"
@michalskop
michalskop / epcz_2014.json
Last active March 9, 2017 00:04
EU: Elections 2014 in Czechia
This file has been truncated, but you can view the full file.
{"colors": {"snk-ed": "#888", "antibursik": "#888", "kdu-csl": "#fedc35", "rds": "#888", "vize-2014": "#888", "pirati": "#000", "moravane": "#888", "usvit": "#0ff", "hss": "#888", "vv": "#888", "cssd": "#f54200", "kscm": "#ff0000", "ods": "#008", "zeleni": "#0b0", "les": "#888", "lev-21": "#888", "top-09": "#808", "ano": "#009ee0", "ksc": "#888", "aneo": "#888", "sp-a-no": "#888", "ne-brusel": "#888", "rozumni": "#888", "svobodni": "#080"}, "votes": [{"votes": ["2163", "155", "543", "1030", "12207", "2028", "63791", "2007", "986", "14678", "135", "32", "81", "23653", "34247", "79", "104", "203", "20339", "481", "3729", "16693", "17207", "129", "566", "926", "97", "643", "108", "185", "14787", "242", "423", "118", "64", "611", "932", "203"], "lat": "50.087106", "winner": "TOP 09", "id": "554782", "population": 236605, "town": "Praha", "winner_class": ["top-09"], "lng": "14.421111"}, {"votes": ["230", "62", "86", "277", "8130", "494", "11340", "355", "251", "4953", "10", "23", "17", "9354", "10273", "19", "1164
@michalskop
michalskop / click_page.txt.tar.gz
Last active August 29, 2015 14:01
Users' behaviour (answering VAA) - VolebníKalkulačka.cz
@michalskop
michalskop / districts.xml
Last active August 29, 2015 14:00
Panamanian presidential elections 2014
<?xml version="1.0" standalone="yes"?>
<NewDataSet>
<Table>
<provincia>1</provincia>
<distrito>0</distrito>
<descripcion>BOCAS DEL TORO</descripcion>
</Table>
<Table>
<provincia>1</provincia>
<distrito>1</distrito>