Skip to content

Instantly share code, notes, and snippets.

@jarek
jarek / gist:354423854a7cc20b1e91
Created February 20, 2015 21:52
rounding microseconds for display in python
#!/usr/bin/env python2
# this is an answer for http://stackoverflow.com/questions/28633986/
# showing correct way of rounding microseconds and printing the result,
# which isn't straightforward using normal strftime()
import datetime
def round_microseconds(date, digits_to_show):
fraction = date.microsecond / 1000000.0
@jarek
jarek / gist:a459b233a1fba1b74a42
Created February 25, 2015 08:56
key verification
$ md5sum gpg_public.key
9f23531032a11f7b68df48f720579444 gpg_public.key
$ sha256sum gpg_public.key
c7dd1e0c729072f364c7186d69ecfc22339aaa11d6b31446d7105c97ee6e1bb0 gpg_public.key
$ sha512sum gpg_public.key
b94f713e56c4c63008ce8045f1131cd8c8e2b43495c89c2594517cb2fe9d7385689dfa68009982bc491594106f879ae366f841fced5bbef996d093aa8b62ac5c gpg_public.key

Keybase proof

I hereby claim:

  • I am jarek on github.
  • I am jarek (https://keybase.io/jarek) on keybase.
  • I have a public key whose fingerprint is BAB1 6106 B642 371F 0AB8 A5BA D8B0 0764 962E 826B

To claim this, I am signing this object:

#!/usr/bin/env python3
# coding=utf-8
# An experiment from October 2015 in getting data out of DBpedia. It's proving to be a pain so not integrated anywhere yet.
import requests
URL = 'http://dbpedia.org/data/{}.jsod'
first_url = URL.format('Toronto')
@jarek
jarek / analyze.py
Created August 25, 2016 15:25
parking and trip charting/plotting code 2016-08-25
#!/usr/bin/env python2
# coding=utf-8
from __future__ import print_function
import sys
import simplejson as json
import datetime
import numpy as np
import matplotlib.pyplot as plt
@jarek
jarek / lastfm-export.py
Created October 10, 2016 19:54
last fm export script - author unknown, will update when known
#!/usr/bin/env python
#-*- coding: utf-8 -*-
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
// inner data-parsing code from view-source:https://w3.sev.fo/framleidsla/36177_SEV_El-orka-i-foroyum.hyperesources/36177sevelorkaiforoyum_hype_generated_script.js?15852
// extracted and beautified
// there is another script for "LoadXMLMobil", it appears to do the same thing except for specifying different DOM IDs
// (e.g. "heyga_vandstand_1Mobil" instead of "heyga_vandstand_1")
// original code below
// ---
function(hypeDocument, element, event) {
@jarek
jarek / 2017-06-18 canada electricity.ipynb
Created June 18, 2017 18:42
Canadian electricity carbon intensity investigation
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jarek
jarek / 2018-03-24 analysis of HVDC_RTX_20180302-20180302.csv
Created March 24, 2018 21:36
Philippines - Visayas electricity on 2018-03-02
We can make this file beautiful and searchable if this error is corrected: It looks like row 9 should actually have 25 columns, instead of 10. in line 8.
DATE,HOUR,,ID,"RUN TYPE","HVDC RTX MW",scraped:,"Vis demand","generation total",,"MPS load ex-post sum","MPS gen ex-post sum",,,"Luzon demand","generation total",,,,,,,,,
2018/02/03,1,2018/03/02,HVDC,RTX,162.33,,1309.1,1053,256.0999999999999,1259.2,1440.1,,,7565,6866,699,,,,,,,,
2018/02/03,2,"2018/03/02 01:00:00",HVDC,RTX,198.96,,1244.2,979,265.20000000000005,,1417,,,7300,6634,666,,,,,,,,
2018/02/03,3,"2018/03/02 02:00:00",HVDC,RTX,219.89,,1193.7,1010,183.70000000000005,,1417.6,,,7251,6503,748,,,,,,,,
2018/02/03,4,"2018/03/02 03:00:00",HVDC,RTX,237.99,,1195.7,1012,183.70000000000005,,1419.9,,,7185,6438,747,,,,,,,,
2018/02/03,5,"2018/03/02 04:00:00",HVDC,RTX,201.86,,1226.8,1014,212.79999999999995,,1422.3,,,7221,6503,718,,,,,,,,
2018/02/03,6,"2018/03/02 05:00:00",HVDC,RTX,161.9,,1283.3,1062,221.29999999999995,,1427.5,,,7394,6674,720,,,,,,,,
2018/02/03,7,"2018/03/02 06:00:00",HVDC,RTX,247.21,,1206,1031,175,,1442.4,,,7073,6318,755,,,,,,,,
2018/02/03,8,"2018/03/02 07:00:00",HVDC,RTX,195.92,,1307.2,1124,183.2000000
We can make this file beautiful and searchable if this error is corrected: It looks like row 10 should actually have 7 columns, instead of 5. in line 9.
date_system,date_pe,wind_pe,oil_pe,exch_pe,date_nb,exch_nb
2018-05-02 19:18:59.669208+00:00,2018-05-02 19:01:01+00:00,51.54,0,110.93,2018-05-02 19:18:00+00:00,91.0
2018-05-02 19:22:03.604494+00:00,2018-05-02 19:01:01+00:00,51.54,0,110.93,2018-05-02 19:22:00+00:00,91.0
2018-05-02 19:23:03.580133+00:00,2018-05-02 19:01:01+00:00,51.54,0,110.93,2018-05-02 19:23:00+00:00,91.0
2018-05-02 19:24:03.671867+00:00,2018-05-02 19:01:01+00:00,51.54,0,110.93,2018-05-02 19:24:00+00:00,91.0
2018-05-02 19:25:04.025070+00:00,2018-05-02 19:11:01+00:00,58.99,0,103.14999999999998,2018-05-02 19:25:00+00:00,91.0
2018-05-02 19:26:03.688525+00:00,2018-05-02 19:11:01+00:00,58.99,0,103.14999999999998,2018-05-02 19:26:00+00:00,91.0
2018-05-02 19:27:03.936384+00:00,2018-05-02 19:11:01+00:00,58.99,0,103.14999999999998,2018-05-02 19:27:00+00:00,91.0
2018-05-02 19:28:03.745912+00:00,2018-05-02 19:11:01+00:00,58.99,0,103.14999999999998,2018-05-02 19:28:00+00:00,91.0
2018-05-02 19:29:03.835466+00:00,2018-05-02 19:11:01+00:00,58.99,0,103.149999