Skip to content

Instantly share code, notes, and snippets.

View gka's full-sized avatar
🐢

Gregor Aisch gka

🐢
View GitHub Profile
<h1>Hello {chart.title} (svelte 2)!</h1>
<input type="text" bind:value="chart.title" />
<div class="svelte3-here" style="border:2px solid red"></div>
<script>
import AppV3 from './bundle.js';
let app;
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@gka
gka / index.html
Last active May 4, 2020 08:36
simple tables in D3
<!DOCTYPE html>
<html>
<head>
<title>Simple tables in D3</title>
<meta charset="utf-8">
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="https://rawgit.com/gka/d3-jetpack/master/d3-jetpack.js"></script>
<style type="text/css">
body { font-family: 'Helvetica Neue', Helvetica; font-weight: 300; padding: 20px;}
th { text-align: left; }
# ---------------------
# This is the R script that generates the charts, maps and tables for the Datawrapper blog post http://blog.datawrapper.de/coronavirus-charts, written by Lisa Charlotte Rost.
# This is NOT great R code. It works, but much of it could have been achieved with shorter code, more elegant, more efficiently, less confusing and without so many libraries; especially the further you go down the script (I got better in the process, among others thanks to my coworker Gregor Aisch who's still a R pro). Please don't use this code to learn R.
# ---------------------
# load libraries
needs(dplyr, readr, reshape2, jsonlite, data.table, tidyr, htmltab, zoo)
# ^ if this command fails, run
@gka
gka / better-slack.css
Created April 8, 2020 22:22
this style helps me get along with the recent slack redesign
@-moz-document url-prefix("https://app.slack.com") {
.p-top_nav {
background: transparent !important;
box-shadow: none;
pointer-events: none;
}
.p-workspace {
margin-top:-38px;
}
.p-top_nav__sidebar {
@gka
gka / corona-growth.R
Created March 25, 2020 17:51
covid-19 cases growth rates
needs(dplyr, readr, reshape2, tidyr, zoo)
read_csv("https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv") %>%
rename(country = `Country/Region`,
province = `Province/State`) %>%
select(-Lat, -Long) %>%
pivot_longer(-c(country, province), names_to = "date", values_to = "confirmed") %>%
mutate(date = as.Date(date, "%m/%d/%y")) %>%
mutate(country = ifelse(country == "China" & province == "Hong Kong",
"Hong Kong", country)) %>%
@gka
gka / twitter_follower_intersect.py
Created September 15, 2011 16:16
Looks up how many followers two Twitter accounts do have in common
#!/usr/bin/env python
"""
This script looks up how many followers two different Twitter accounts do have in common.
Usage:
twitter_follower_intersect.py username username
You'll need Python and the Python Twitter Tools to get this running.
@gka
gka / _graph.png
Last active February 21, 2020 15:14
d3 dependency network
_graph.png
@gka
gka / index.html
Created July 11, 2012 06:40
How to use HCL in d3.js
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<style>
body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
padding: 14px;
}
@gka
gka / index.html
Last active December 10, 2019 23:18
Parliament seating diagrams
<!DOCTYPE html>
<html>
<head>
<script src="http://d3js.org/d3.v3.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
path { stroke: red; fill: none; stroke-width:2; opacity: 0.4}
</style>
</head>