Skip to content

Instantly share code, notes, and snippets.

@michalskop
michalskop / api.example.com.conf
Last active February 13, 2024 09:35
Setting up an Ubuntu server
<VirtualHost *:80>
# example of settings for Postgrest API
ServerAdmin admin@example.com
ServerName api.example.com
ProxyPreserveHost On
# setup the proxy
<Proxy *>
Order allow,deny
Allow from all
@michalskop
michalskop / create_testing_calcs.py
Last active September 2, 2023 10:15
Create testing files for Slovak calculators
"""Create testing files for calcs."""
# import gspread
import json
import pandas as pd
import random
import string
path = "calc/"
path1 = path + "kalkulacka/"
@michalskop
michalskop / countries.json
Last active May 22, 2022 09:42
EU map: leaflet, topojson
{"bn": {"population": "408786", "region": "Asia", "id": "bn", "name": "Brunei Darussalam", "sub-region": "South-Eastern Asia", "latitude": "4.5", "longitude": "114.666666667", "code": "bn"}, "us": {"population": "313847465", "region": "Americas", "id": "us", "name": "United States", "sub-region": "Northern America", "latitude": "38", "longitude": "-97", "code": "us"}, "cx": {"population": "1496", "region": "", "id": "cx", "name": "Christmas Island", "sub-region": "", "latitude": "-10.5", "longitude": "105.666666667", "code": "cx"}, "li": {"population": "36713", "region": "Europe", "id": "li", "name": "Liechtenstein", "sub-region": "Western Europe", "latitude": "47.2666666667", "longitude": "9.5333333333", "code": "li"}, "la": {"population": "6586266", "region": "Asia", "id": "la", "name": "Lao People's Democratic Republic", "sub-region": "South-Eastern Asia", "latitude": "18", "longitude": "105", "code": "la"}, "pn": {"population": "48", "region": "Oceania", "id": "pn", "name": "Pitcairn", "sub-region": "Poly
@michalskop
michalskop / algorithm.py
Last active November 22, 2020 12:52
Hemicycle chart (general)
# calculates optimal numbers of representives for hemicycle chart
import math
import csv
import numpy as np
import timeit
start = timeit.default_timer()
#benchmark:
#n0 = 200 : 4:23s, 5:52s, 6:132s, 7:285s, 8:579s, 9:1167s , 10:2342s, 11: 4632s
<div>
<script type="text/javascript">window.PlotlyConfig = {MathJaxConfig: 'local'};</script>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<div id="52dc101e-066a-4cb9-bd22-9445f42a0556" class="plotly-graph-div" style="height:500px; width:100%;"></div>
<script type="text/javascript">
window.PLOTLYENV=window.PLOTLYENV || {};
if (document.getElementById("52dc101e-066a-4cb9-bd22-9445f42a0556")) {
@michalskop
michalskop / README.md
Last active March 25, 2020 01:27
CZ+DE: Covid19 by regions

Covid-19: Comparison of Czech and German regions.

I joined several Czech regions to make them of similar size as the German states.

@michalskop
michalskop / README.md
Last active March 5, 2020 00:04
CZ: support by age

Distribution of voters' support by age

Czechia, 10-11/2019

@michalskop
michalskop / README.md
Last active October 23, 2019 19:06
Regions of Czechia - cartogram

Kraje ČR - kartogram

@michalskop
michalskop / README.md
Last active September 20, 2019 19:07
Prague: spatial distribution 2018-2019

WPCA Analysis of Prague Assembly

2018 - 06/2019

Analysis flow

  • Raspberry update data: home/pi/project/praha.eu-scraper/scraper.py
  • update local data: download_datapackage.py
  • cd /home/michal/dev/wpca/praha_2018-2019/
  • cp data/votes.csv x_source.csv
  • correct paths in wpca.py, load_datapackage.py
@michalskop
michalskop / d3.tip.js
Last active August 4, 2019 13:55
CZ: Euroelections 2019
// 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 {