Skip to content

Instantly share code, notes, and snippets.

Avatar

Oleg Lavrovsky loleg

View GitHub Profile
@loleg
loleg / shuffle.js
Last active Apr 3, 2022
Populates a column of random numbers for shuffling the order of an Airtable
View shuffle.js
// Select a table containing a "Sort Order" number column
const TABLE_NAME = "<Your Table Name Here>"
// A time limit comfortably within the allowable script runtime
const MAX_TIME = 25;
// Maximize shuffle within the time limit
const startTime = new Date();
function timeElapsed() {
const endTime = new Date().getTime();
@loleg
loleg / geoadmincoding.js
Last active Jul 18, 2022
Airtable script for geocoding addresses using the swisstopo REST API
View geoadmincoding.js
/* Geocoding utility script by @loleg
* Latest version: https://gist.github.com/loleg/2e38752732e29472993dd74da988d7e6
*
* - fills location coordinates based on an "Address" field
* - uses the open data API service of swisstopo (Switzerland only)
* - currently auto-throttled by Airtable, with fetch limits
* - retries continuously to let you fix addresses in your table
* - add this to a "create record" automation and also limit by time
*
* Required fields:
@loleg
loleg / DDA.p5.js
Created Jan 24, 2022
The simplest line drawing algorithm
View DDA.p5.js
/*
* @name DDA graphics algorithm
* @description A simple implementation of line rasterization using the Digital differential analyzer.
* Press the mouse button on any two points to draw a line. A color will be picked at random.
* See https://en.wikipedia.org/wiki/Digital_differential_analyzer_(graphics_algorithm)
*/
let i = x1 = y1 = x2 = y2 = dx = dy = step = 0;
let pickStart = pickEnd = false;
@loleg
loleg / combine_data_by_egid.py
Created Nov 13, 2021
Combine geodata referenced by EGID (building identifier) #DataHackdaysBE
View combine_data_by_egid.py
import csv, io
# Configuration
input_addresses = "Gebaeudeadressen_1636760957021_53445 - Gebäudeadressen.csv"
egidcol_addresses = "Eidg. Gebäude-ID (EGID)"
input_opendata = "V20211111.csv"
egidcol_opendata = "egid"
output_filename = "combined.csv"
# Preload address file
@loleg
loleg / emojipedia-cheatsheet.js
Created Jun 26, 2021
Console script to generate an Emoji cheatsheet
View emojipedia-cheatsheet.js
/*
1. Go to any emoji list page on Emojipedia, e.g.
https://emojipedia.org/google/
2. Scroll down until every icon has loaded
3. Run this script in your console
4. Print!
*/
$('li a img').each(function() { nm = $(this).attr('title'); $(this).parent().append('<ttl>' + nm + '</ttl>') });
$('header,.ad-header,.ad-footer,section,.vsfilter,.sidebar,footer').hide();
@loleg
loleg / santa.py
Created Dec 6, 2020 — forked from will-bainbridge/santa.py
Secret Santa script
View santa.py
#!/usr/bin/python3
"""
Ye olde Secret Santa script based on https://gist.github.com/will-bainbridge/a4666a196fb5833cf37035647b74c064
You will need to prepare a "people file", which is in CSV format (UTF-8, comma delimited) and has the following columns (without a header row)
Name, E-mail, Extra content 1, Extra content 2
We used the postal address as extra content 1 and a link to Google Street View as extra content 2. Then you can specify a plain text message file which includes %s for the buyer name, recipient name, recipient extra 1, and recipient extra 2 (in that order!). For example:
View Oleg @ OpenDataBeer 12.md
title tags description slideOptions
Oleg @ OpenDataBeer 12
dribdat
View the slide with "Slide Mode".
theme
white

OpenDataBeer logo

@loleg
loleg / corona-mix.ino
Created Oct 30, 2020
A zombie remix of tamberg's SwissCovid-detector and ganda1f's PartyNoise-detector
View corona-mix.ino
// Just getting my hands dirty with Arduino! Please don't be upset ...
/* Sources:
*
* https://github.com/gand417/mz2020_audio/blob/main/mz2020_audio.ino
* https://github.com/make-zurich/makezurich-hardware-intro/blob/master/Arduino/Neno33BleSense_CoronaAppScanner/Neno33BleSense_CoronaAppScanner.ino
*/
#include <Adafruit_NeoPixel.h>
#include <ArduinoBLE.h>
@loleg
loleg / lindas-sparql-example.r
Created Oct 23, 2020
An example of how to connect to the LINDAS service with the R package for SPARQL
View lindas-sparql-example.r
library(SPARQL)
endpoint <- "https://lindas.admin.ch/query"
rdf_query <- "
PREFIX : <http://voc.zazuko.com/zack#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX gont: <https://gont.ch/>
SELECT DISTINCT ?Haltestelle WHERE
{ GRAPH <https://linked.opendata.swiss/graph/FOT/didok> {
@loleg
loleg / corona-data.user.js
Created Oct 6, 2020
Light mode for Corona-Data.ch (Greasemonkey script)
View corona-data.user.js
// ==UserScript==
// @name Corona-Data.ch Light edition
// @description This adjusts the theme of the Swiss Covid-19 data visualization by Daniel Probst
// @version 0.0.1
// @grant GM.xmlhttpRequest
// @grant GM.addStyle
// @include https://www.corona-data.ch/*
// @include https://corona-data.ch/*
// ==/UserScript==