Skip to content

Instantly share code, notes, and snippets.

@rplnt
rplnt / sql2md.sh
Created December 22, 2021 12:35
Convert `mysql --table` output to markdown table
# remove first line; remove last line; replace `+` in header with `|`
sed -e "1d; $$ d; s/+/|/g"
@rplnt
rplnt / merge.py
Last active August 8, 2018 09:12
merge json files
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from collections import defaultdict
import json
import sys
import os
@rplnt
rplnt / pcs.py
Created March 27, 2018 07:33
PCS GC Scraper
from bs4 import BeautifulSoup as bs
import requests
import time
import os
server = 'http://www.procyclingstats.com/'
stages = 'race/Tour_de_France_{year}-stages'
years = [2015]
#!/usr/bin/env python
# coding=utf-8
from __future__ import print_function
import operator
import sys
operators = [
operator.add,
@rplnt
rplnt / rfl_2015.json
Created April 10, 2016 16:04
RFL 2015 results
{
"Tour_de_Romandie": [
{
"country": "ru",
"name": "Ilnur Zakarin",
"team": "Team Katusha 2015"
},
{
"country": "si",
"name": "Simon Spilak",
@rplnt
rplnt / tips.json
Created March 5, 2016 09:36
tipovanie vysledkov volieb 2016
{
"Kubris": [7.0, 8.0, 8.0, 7.0, 11.0, 32.0, 11.0, 3.0],
"akira": [7.2, 8.5, 6.1, 5.4, 13.5, 34.0, 8.0, 3.4],
"Kajsi": [7.5, 12.0, 7.0, 5.0, 10.0, 30.0, 8.0, 3.5],
"repelent": [8.3, 10.6, 8.8, 6.8, 11.82, 30.3, 7.4, 3.2],
"kacica": [7.0, 8.0, 5.0, 6.0, 14.0, 29.0, 8.0, 4.0],
"chav": [6.7, 9.8, 8.4, 6.4, 13.8, 32.1, 7.9, 3.9],
"aztec": [6.3, 8.5, 8.0, 7.4, 13.8, 32.0, 8.5, 3.2],
"mirex": [8.0, 8.0, 9.0, 7.0, 13.0, 33.0, 9.0, 4.9],
"shulo": [7.9, 9.6, 6.9, 6.5, 13.5, 31.9, 7.5, 4.2],
@rplnt
rplnt / nrsr_age.py
Created February 24, 2016 16:33
Candidates' ages in Slovak parliamentary election (2016)
data = {
'Tip': [38, 44, 39, 46, 28, 43, 35, 33, 31, 30, 27, 51, 56, 48, 50, 38, 42, 43, 66, 24, 45, 49, 38, 40, 48, 55, 30, 61, 38, 43, 35, 31, 33, 38, 48, 48, 24, 40, 34, 48, 30, 21, 41, 43, 53, 46, 62, 50, 38, 44, 57, 35, 48, 42, 47, 44, 56, 51, 30, 40, 42, 27, 32, 47, 53, 31, 50, 43, 28, 41, 53, 37, 35, 61, 42, 42, 65, 52, 51, 34, 64, 59, 24, 37, 24, 62, 24, 39, 59, 30, 32, 29, 27, 26, 53, 23, 41, 28, 48, 40, 33, 38, 50, 48, 37, 30, 50, 68, 23, 34, 24, 39, 35, 32, 44, 52, 22, 38, 26, 22, 25, 45, 28, 30, 22, 60, 56, 36, 42, 59, 74, 30, 33, 37, 38, 26, 33, 27, 34, 40, 55, 61, 55, 60, 56, 27, 31, 25, 38, 27],
'Strana moderného Slovenska': [71, 52, 34, 45, 58, 27, 48, 56, 49, 52, 27, 48, 43, 31, 31, 44, 35, 50, 40, 32, 63, 43, 51, 36, 48, 54, 53, 64, 32, 52, 46, 55, 27, 46, 47, 59, 45, 73, 45, 34, 36, 59, 53, 56, 53, 42, 68, 56, 36, 39, 46, 62, 36, 50, 50, 35, 35, 33, 31, 21, 54, 34, 58, 35, 30, 40, 27, 47, 65, 32, 32, 63, 48, 51, 36, 62, 35, 23, 50, 44, 45, 42, 29, 28, 36, 48, 34, 32, 33, 45, 23, 51,
@rplnt
rplnt / pivnibeh
Last active August 29, 2015 14:03
Beer Run Live Map
//run = {id: {'run': [{'stopName': stopName, 'timeIn': timeIn, 'timeOut': timeOut}, ...], 'name': teamName}};
//stops = {stopName: {"name": fullName, "pos":{'x': x, 'y': y}, "teams": teamCount}, ...}
/*
* Object containing live team information
*/
function Team(teamId, teamName, run) {
this.teamId = parseInt(teamId);
this.teamName = teamName;
this.run = run;
@rplnt
rplnt / hbomusicscraper.py
Created November 23, 2012 18:46
Scrape music from HBO shows
#!/usr/bin/python
from bs4 import BeautifulSoup as bs
from datetime import datetime
import requests
import sqlite3
import time
import sys
import os
import re
from math import sqrt
# straightforward
def pri1(n):
primes = []
for p in xrange(2,n+1):
for k in primes:
if p % k == 0:
break