Skip to content

Instantly share code, notes, and snippets.

View wolph's full-sized avatar

Rick van Hattem wolph

View GitHub Profile
@wolph
wolph / mikrotik_dashboard.json
Created December 12, 2019 18:18
mikrotik exporter prometheus dashboard
{
"__inputs": [
{
"name": "DS_PROMETHEUS",
"label": "Prometheus",
"description": "",
"type": "datasource",
"pluginId": "prometheus",
"pluginName": "Prometheus"
}
@wolph
wolph / to_json.sql
Created April 6, 2012 10:35
Some functions to convert arrays/hstore to json :)
CREATE OR REPLACE FUNCTION escape_json (text) RETURNS text AS $$
SELECT replace($1, '''', '\'''); $$ LANGUAGE SQL IMMUTABLE;
CREATE OR REPLACE FUNCTION to_json(text) RETURNS text AS $$
SELECT escape_json($1) $$ LANGUAGE SQL IMMUTABLE;
CREATE OR REPLACE FUNCTION to_json(KEY text, value text) RETURNS text AS $$
SELECT '''' || to_json($1) || ''': ''' || to_json($2) || ''''; $$ LANGUAGE SQL IMMUTABLE;
DEBUG_TOOLBAR = DEBUG
if DEBUG_TOOLBAR:
def show_toolbar(request):
if request.user.is_superuser:
return True
elif request.META['REMOTE_ADDR'] in INTERNAL_IPS:
return True
return False
@wolph
wolph / ibood.js
Created July 16, 2019 15:53
Show ibood prices for expired deals
// ==UserScript==
// @name ibood old prices
// @namespace http://tampermonkey.net/
// @version 0.1
// @description add prices to old/expired ibood deals
// @author You
// @match https://www.ibood.com/*
// @grant none
// ==/UserScript==
@wolph
wolph / activetable.js
Last active July 4, 2019 15:27 — forked from stevesouders/activetable.js
ActiveTable is a bookmarklet that makes any table sortable. It also allows you to remove columns, and it remembers the removed columns for next time. Use alt+click to UNhide all columns (and clear memory). This version sorts numerically if possible and if that's not possible it puts the numbers first and letters after
// ActiveTable - a bookmarklet to make tables sortable and editable
function init() {
var aHrows = getHrows();
var numHrows = aHrows.length;
var aHidden = getHiddenColumns();
ATpopup = document.createElement("div");
ATpopup.style.cssText = "position: absolute; visibility: hidden; padding: 0; font-family: Arial; background-color: rgba(255, 255, 255, 0.9); border-radius: .5em; text-align: center; box-shadow: .05em .05em .5em #00C;";
upstream sonarr {
server 127.0.0.1:1234;
}
server {
server_name sonarr;
include includes.d/restricted.conf;
include includes.d/ssl_server.conf;
include includes.d/proxy.conf;
# - alias: close curtains
# trigger:
# - event: sunset
# platform: sun
# condition: []
# action:
# - data:
# entity_id: cover.qubino_zmnhod1_flush_shutter_dc_level
# service: automation.turn_off
@wolph
wolph / non_blocking_read.py
Created September 19, 2018 11:57
Read all available data from file handle and return (with optional timeout)
def read(fh, timeout=0):
output = []
while select.select([fh], [], [], timeout)[0]:
output.append(fh.read(1))
return ''.join(output)
@wolph
wolph / sj1221.ino
Created April 2, 2018 11:19
SJ1221 led strip test
/* vim: ts=8
Example code for the SJ1221 control protocol
Based on: http://wp.josh.com/2014/05/11/ws2812-neopixels-made-easy/
*/
// Change this to be at least as long as your pixel string (too long will work fine, just be a little slower)
#define PIXELS 96*11 // Number of pixels in the string
// color multiplier since we've got 0-4096 instead of 0-256
#!/bin/sh
exec <"$0" || exit; read v; read v; exec /usr/bin/osascript - "$@"; exit
-- the above is some shell trickery that lets us write the rest of
-- the file in plain applescript
-- Usage:
-- For a simple reload and nothing else:
-- # sh reload_chrome.sh
-- For a reload with activating a different app after (iTerm in this case):
-- # sh reload_chrome.sh iTerm