Skip to content

Instantly share code, notes, and snippets.

View andrashann's full-sized avatar

andrashann

View GitHub Profile
@andrashann
andrashann / kozterulet
Last active August 29, 2015 14:26
Reguláris kifejezés közterületnevek kereséséhez / A Regular Expression that finds Hungarian street names including suffixes
((((?!(Az |A ))\p{Lu}(\p{L}|-)*|[0-9]+)\W*)+(\p{L}|[0-9])*\W{1,3}(?!(között|után))(akn[aá]|árok|árko|átjáró|básty[aá]|dűlő[uú]t|dűlő|erdősor|fasor|forduló|gát|határsor|határ[uú]t|h[ií]d|kapu|kolóni[aá]|körönd|kört[eé]r|kör[uú]t|köz|lejáró|lejtő|lépcső|liget|mély[uú]t|orom|ormo|ösvény|park|part|pincesor|puszt[aá]|rakpart|sétány|sor|sugár[uú]t|tany[aá]|ter[eé]|tér|udvar|utc[aá]|[uú]t|üdülőpart)(j[aáeé]|))
@andrashann
andrashann / google_maps_distance_api.R
Created January 27, 2016 21:22
Get distance and value for origin-destination pairs from Google Maps API
require(jsonlite)
require(curl)
google_maps <- function(datafile, gapikey, save_file = FALSE){
# This function takes origin-destination pairs and returns the distance and
# trip duration between these pairs as a data frame
#
# _datafile_ is a string that is the name of a csv file in which each line
# contains an origin and a destination separated by a comma.
#
@andrashann
andrashann / from_unixtime.sh
Last active April 13, 2016 14:48
Easily print unix epoch timestamp in human-readable form on the command line
# take a Unix timestamp and print it in human-readable form;
# works both on Linux and OS X.
#
# copy this to your .bash_profile, then you can use it as:
# from_unixtime 1460558700
# returns: Wed Apr 13 16:45:00 CEST 2016
from_unixtime() {
thedate="$1"
thedate=${thedate:0:10}
@andrashann
andrashann / camel_chart.csv
Last active June 8, 2018 06:55
hány teve élt a teveclub.hu honlapon? megmondja az archive.org / how many camels were on teveclub.hu? archive.org tells us
We can make this file beautiful and searchable if this error is corrected: It looks like row 9 should actually have 4 columns, instead of 3. in line 8.
camel_count,timestamp,url,parsed_timestamp
47045.0,20011023075905,https://web.archive.org/web/20011023075905/http://www.teveclub.hu/cgi-bin/farm/farm.cgi,2001-10-23 07:59:05
58769.0,20011213235955,https://web.archive.org/web/20011213235955/http://www.teveclub.hu/cgi-bin/farm/farm.cgi,2001-12-13 23:59:55
74500.0,20020214002239,https://web.archive.org/web/20020214002239/http://www.teveclub.hu/cgi-bin/farm/farm.cgi,2002-02-14 00:22:39
93191.0,20020606135002,https://web.archive.org/web/20020606135002/http://www.teveclub.hu/cgi-bin/farm/farm.cgi,2002-06-06 13:50:02
95242.0,20021002181254,https://web.archive.org/web/20021002181254/http://www.teveclub.hu/cgi-bin/farm/farm.cgi,2002-10-02 18:12:54
95871.0,20021201083309,https://web.archive.org/web/20021201083309/http://www.teveclub.hu/cgi-bin/farm/farm.cgi,2002-12-01 08:33:09
101449.0,20030201092235,https://web.archive.org/web/20030201092235/http://www.teveclub.hu/cgi-bin/farm/farm.cgi,2003-02-01 09:22:35
101449.0,20030404102612,https://web.archive.org/web/20030404102
@andrashann
andrashann / cyrillic-latin-intersection.ipynb
Last active December 3, 2018 08:57
Which English words could we write using only letters that also appear in the Cyrillic alphabet?
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@andrashann
andrashann / cl.sh
Last active February 16, 2024 19:30
Command line notes – a collection of useful one-liners
# Copyright 2019 A. H.
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@andrashann
andrashann / programmatic_design.ipynb
Created April 16, 2020 21:19
programmatic design
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@andrashann
andrashann / Tram 6 renovation visualization.ipynb
Last active June 17, 2020 21:34
A time-space graph showing construction works on tram line 6 in Budapest. This code is released under the MIT license.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@andrashann
andrashann / cmap_map.py
Created October 17, 2020 13:49
Companion notebook to my article about population density and social distancing
import matplotlib
import numpy as np
import matplotlib.pyplot as plt
#https://scipy-cookbook.readthedocs.io/items/Matplotlib_ColormapTransformations.html
def cmap_map(function, cmap):
""" Applies function (which should operate on vectors of shape 3: [r, g, b]), on colormap cmap.
This routine will break any discontinuous points in a colormap.
"""