Skip to content

Instantly share code, notes, and snippets.

View phaer's full-sized avatar
💭

Paul Haerle phaer

💭
View GitHub Profile
#
# This file is the units database for use with GNU units, a units conversion
# program by Adrian Mariano adrianm@gnu.org
#
# August 2015 Version 2.13
#
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2006
# 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015
# Free Software Foundation, Inc
#
@phaer
phaer / ostatus_tag.rb
Created April 10, 2011 16:06
Simple Jekyll tag which displays the notices in a given status.net/ostatus feed.
require 'date'
require 'ostatus'
module Jekyll
class RenderOStatus < Liquid::Tag
def render(context)
site = context.registers[:site]
feed = OStatus::Feed.from_url(site.config['ostatus_feed'])
result = "<h2>#{feed.author.name}'s microblog</h2>"
@phaer
phaer / wikidata-versions.sh
Last active March 6, 2018 23:22
query software versions on wikidata.org
# See https://wikidata.org/wiki/P348 https://wikidata.org/wiki/Q83, https://wikidata.org/wiki/Q13166 for a
# definition of the arguments. Or paste the query to https://query.wikidata.org for a nice online editor.
curl -sSH 'Accept: application/sparql-results+json' --data-urlencode query@- https://query.wikidata.org/sparql <<EOF \
| jq '.results.bindings | map({"key": .softwareLabel.value, "value": .version.value}) | from_entries'
SELECT ?softwareLabel ?version WHERE {
?software wdt:P348 ?version;
FILTER ( ?software IN (wd:Q13166, wd:Q83))
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en" .
}
@phaer
phaer / ansible-snippets.sh
Created February 26, 2017 23:52
ansible-snippets
# filter setup module through jq.
ansible -i inventory '*' -m setup -o | sed 's/^\(.*\) | SUCCESS => \(.*\)/{"\1": \2}/' | jq .
#!/usr/bin/env python3
"""
A litte tool to generate a .mrconfig file for https://myrepos.branchable.com/
from a https://gitea.io/ account.
sudo apt install python3 python3-requests
Check possible values for your MR_REPO_TEMPLATE with
$ curl --user ${GITEA_USER}:{$GITEA_PASS} https://${GITEA_HOST}/api/v1/user/repos | jq .
"""
@phaer
phaer / metalab-teletext-remote.ino
Last active January 14, 2017 22:10
Metalab Teletext Remote control code.
#include <IRremote.h>
#include <Keypad.h>
const byte ROWS = 4;
const byte COLS = 4;
// define the symbols of the buttons on the keypads.
const char hexaKeys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
@phaer
phaer / sshjail.py
Created December 23, 2016 14:51
connection_plugin for Ansible and FreeBSD jails, connecting through ssh on the jailhost.
# connection_plugin for Ansible and FreeBSD jails, connecting
# through ssh on the jailhost.
# inspiration: https://github.com/austinhyde/ansible-sshjail
from ansible.errors import AnsibleError
from ansible.plugins.connection import ConnectionBase
from ansible.plugins.connection import ssh
try:
from __main__ import display
except ImportError:
@phaer
phaer / broker.ml
Last active September 19, 2016 22:34
open Lwt.Infix
open Websocket_lwt
open Ppx_lwt
open Frame
let ip_port = ("127.0.0.1", 3000);;
let clients = Hashtbl.create 10;;
let section = Lwt_log.Section.make "stream_shape";;
Lwt_log.(add_rule "*" Debug);;
@phaer
phaer / overpass-query.txt
Created April 14, 2016 01:17
Get RBL number for viennese public transport stops around a given location
/*
This has been generated by the overpass-turbo wizard.
The original search was:
“(railway=station or railway=tram_stop or highway=bus_stop) around Semperdepot”
*/
[out:json][timeout:25];
// adjust the search radius (in meters) here
{{radius=600}}
// gather results
(
@phaer
phaer / private.py
Last active December 23, 2015 07:28
Mediagoblin m*e*ddleware to keep your instance private.
from mediagoblin.meddleware import BaseMeddleware
from mediagoblin.tools.response import redirect
class PrivateMeddleware(BaseMeddleware):
"""Private Meddleware
Redirects requests by unauthenticated clients to the login form.
"""
public_views = [