Skip to content

Instantly share code, notes, and snippets.

View otsaloma's full-sized avatar

Osmo Salomaa otsaloma

  • Helsinki, Finland
View GitHub Profile
@otsaloma
otsaloma / r.py
Last active November 26, 2020 16:22
R query runner for Redash
from __future__ import print_function
import itertools
import logging
import re
import traceback
from redash import models
from redash.query_runner import BaseQueryRunner
from redash.query_runner import register
@otsaloma
otsaloma / .Rprofile
Last active September 19, 2023 19:20
Project specific snapshot dependencies for R
local({
# Source any possible project-specific .init.R first
# as it might set .libPaths for custom dependencies.
# https://gist.github.com/otsaloma/f3b8f61a39bf81df0bcc0e5fd80e9ad1
components = unlist(strsplit(getwd(), "/"))
for (i in length(components):1) {
args = as.list(c(components[1:i], ".init.R"))
path = do.call(file.path, args)
if (file.exists(path)) {
source(path)
@otsaloma
otsaloma / fake-position.diff
Created March 17, 2018 21:40
Fake position in WhoGo Maps for testing
diff --git a/qml/Map.qml b/qml/Map.qml
index edb95f3..8c74c35 100644
--- a/qml/Map.qml
+++ b/qml/Map.qml
@@ -138,7 +138,7 @@ MapboxMap {
}
onPositionChanged: {
- map.autoCenter && map.centerOnPosition();
+ // map.autoCenter && map.centerOnPosition();
@otsaloma
otsaloma / attrdict.py
Last active October 14, 2018 00:50
Python dictionary with attribute access to keys
# -*- coding: utf-8 -*-
# Copyright (c) 2017 Osmo Salomaa
#
# 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:
@otsaloma
otsaloma / remove-duplicate-subs
Last active June 25, 2017 22:37
Remove duplicate subtitles with aeidon
#!/usr/bin/env python3
import aeidon, sys, time
if len(sys.argv) < 2:
print("Usage: {} SUBTITLE_FILE...".format(__file__))
raise SystemExit(1)
for fname in sys.argv[1:]:
print("{}:".format(fname))
project = aeidon.Project()
project.open_main(fname, "utf_8")
before = len(project.subtitles)
@otsaloma
otsaloma / gnome-do-hidpi.patch
Last active January 9, 2017 01:48
GNOME Do HiDPI partial alleviation hack
diff -rub gnome-do-0.95.3.orig/Do.Interface.Linux.AnimationBase/src/Do.Interface/Do.Interface.AnimationBase/BezelDrawingArea.cs gnome-do-0.95.3/Do.Interface.Linux.AnimationBase/src/Do.Interface/Do.Interface.AnimationBase/BezelDrawingArea.cs
--- gnome-do-0.95.3.orig/Do.Interface.Linux.AnimationBase/src/Do.Interface/Do.Interface.AnimationBase/BezelDrawingArea.cs 2013-12-28 05:51:22.827272000 +0200
+++ gnome-do-0.95.3/Do.Interface.Linux.AnimationBase/src/Do.Interface/Do.Interface.AnimationBase/BezelDrawingArea.cs 2017-01-07 06:25:03.992928851 +0200
@@ -182,7 +182,7 @@
Gdk.Rectangle drawing_area;
Surface surface;
- double text_box_scale, window_fade = 1, window_scale=1;
+ double text_box_scale, window_fade = 1, window_scale=2;
@otsaloma
otsaloma / Circle.qml
Last active July 21, 2017 20:05
Poor Maps position centering testing circle
Rectangle {
id: circle
color: "red"
opacity: 0.2
radius: width/2
z: 10000
}
// onPositionChanged:
@otsaloma
otsaloma / PositionSource.qml
Last active March 17, 2018 21:09
A drop-in replacement for PositionSource.qml for testing
// -*- coding: utf-8-unix -*-
import QtQuick 2.0
import QtPositioning 5.2
// A drop-in replacement for PositionSource.qml for testing.
Item {
id: gps
property var direction: 0
@otsaloma
otsaloma / openptmap.json
Created September 27, 2015 11:34
OpenStreetMap public transportation definitions for Poor Maps
{
"attribution": "© OpenStreetMap contributors",
"extension": ".png",
"format": "slippy",
"name": "OpenPTMap",
"source": "openptmap.org",
"type": "overlay",
"url": "http://openptmap.org/tiles/{z}/{x}/{y}.png",
"z": 20
}
@otsaloma
otsaloma / kelkkapoi.json
Created February 8, 2015 20:40
Kelkkareitit definitions for Poor Maps
{
"attribution": "© OpenStreetMap contributors\nhttp://www.openstreetmap.org/copyright",
"extension": ".png",
"format": "slippy",
"name": "Kelkkapisteet",
"source": "kelkkareitit.fi",
"type": "overlay",
"url": "http://tiles.kelkkareitit.fi/kelkkapoi/{z}/{x}/{y}.png",
"z": 30
}