Skip to content

Instantly share code, notes, and snippets.

@gkralik
gkralik / docker-compose.yml
Created March 24, 2018 08:54
Elasticsearch + Kibana
version: '2'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch-oss:6.2.3
environment:
- "discovery.type=single-node"
ports:
- "9200:9200"
- "9300:9300"
networks:
@gkralik
gkralik / firefox-import-from-chromium.md
Last active March 24, 2018 08:55
Import Chromium data to Firefox on Linux

If Firefox does not find Chromium in the Import wizard, create a symlink from ~/.config/chromium to /.config/google-chrome. Then Chrome and Chromium should appear in the Import wizard window. Select Chromium, what type of data to import and it should work.

@gkralik
gkralik / sabToKodi.sh
Last active April 22, 2017 06:52
sabnzbd post processing script: update kodi library
#!/usr/bin/bash
# Copyright 2017 Gregor Kralik <g.kralik (at) gmail.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@gkralik
gkralik / speedtest.md
Last active March 24, 2022 09:39
Periodically measure internet connection speed using speedtest-cli

install speedtest-cli

$ pip install speedtest-cli

add to crontab

$ crontab -e

# run speedtest every 10 min
@gkralik
gkralik / readme.txt
Created April 20, 2017 19:24
Raspberry Pi 3: simultaneous audio output via HDMI and analogue jack
Secenario: running Kodi and MPD. Kodi should output sound via HDMI,
MPD should use the 3.5mm jack.
aplay -l lists available devices:
**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
Subdevices: 7/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
@gkralik
gkralik / cdata.php
Created April 12, 2017 09:02
PHP: embed string in CDATA section
function embedInCData($str)
{
$dom = new \DOMDocument();
$cdata = $dom->createCDATASection($str);
return $dom->saveXML($cdata);
}
// usage:
echo embedInCData('<strong>foobar</strong>');
// <![CDATA[<strong>foobar</strong>]]>
@gkralik
gkralik / blacklisted.zones
Last active March 8, 2018 11:52
Bind DNS Sinkhole
zone "blacklisted.domain" {type master; file "/etc/bind/blockeddomains.db";};
@gkralik
gkralik / check_ssl_expiry.py
Last active June 8, 2018 02:21
Nagios script to check SSL certificate expiry for a domain
#!/usr/bin/env python3
import sys
import socket
import ssl
import datetime
# based on https://serverlesscode.com/post/ssl-expiration-alerts-with-lambda/
#
# Usage: check_ssl_expiry.py <hostname> [port] [gracetime_days]
# port Port to check (defaults to 443)
# from http://stackoverflow.com/a/246128
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
BASE_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
BASE_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
@gkralik
gkralik / README
Last active August 29, 2015 14:26
Detect ClickOnce support of browser
Detect if ClickOnce is (or rather: might be) supported by the browser.
This is partly based on https://gist.github.com/adunkman/2371101.
If the userAgent string does not contain a .NET feature hint,
we settle for everything that looks like an IE, because .NET
is installed nearly everywhere nowadays.
It might also be a good idea to check for the X-ClickOnceSupport
header on the server side.