Skip to content

Instantly share code, notes, and snippets.

View droserasprout's full-sized avatar

Lev Gorodetskii droserasprout

  • Montevideo, Uruguay
  • 12:08 (UTC -03:00)
View GitHub Profile
@droserasprout
droserasprout / time-series.sql
Created August 9, 2021 20:01
PostgreSQL time series without TimescaleDB
CREATE MATERIALIZED VIEW users_30m AS
SELECT
a.exchange_id,
COUNT(DISTINCT a.trader_id) as users,
to_timestamp(
floor(
(
extract(
'epoch'
from
@droserasprout
droserasprout / userChrome.css
Created June 7, 2019 09:42
userChrome for Tree Style Tabs
/* Copy to ~/Library/Application\ Support/Firefox/Profiles/*.default/chrome/ */
#TabsToolbar {
visibility: collapse !important;
}
#TabsToolbar, #sidebar-header {
visibility: collapse !important;
}
@droserasprout
droserasprout / datediff.py
Last active December 22, 2017 09:47
timedelta for humans ([-]YMDhms format)
#!/bin/python3
import datetime, re
def datediff(date, diff):
sign = 1
datere = '((?P<sign>[+-])?)(?:(?P<Y>\d+)Y)?(?:(?P<M>\d+)M)?(?:(?P<D>\d+)D)?(?:(?P<h>\d+)h)?(?:(?P<m>\d+)m)?(?:(?P<s>\d+)s)?'
rx = re.match(datere, diff)
if rx.group('sign') == '-':
sign = -1
if rx.group('Y'):
date += sign * datetime.timedelta(days = (356 * int(rx.group('Y'))))
@droserasprout
droserasprout / batchscrobbler.py
Created June 13, 2017 14:30
Batch Last.fm scrobbler for quick start
#!/usr/bin/python -u
import sys, os, time
try:
import pylast, taglib
except:
print("Please install python-pylast and python-pytaglib first.", file=sys.stderr)
API_KEY = "b01fb9eac7dc07d6712dee8986af73ce"
API_SECRET = "887363c94049af9f82c1dd9ea76e0c12"