Skip to content

Instantly share code, notes, and snippets.

View KiNgMaR's full-sized avatar

Ingmar Runge KiNgMaR

  • Europe
View GitHub Profile
@KiNgMaR
KiNgMaR / select-port.bash
Created April 21, 2021 10:29
Bash script that atomically selects a port from the range 30000-40000 on Linux
# ref: https://unix.stackexchange.com/a/274499
#
RANDOM_PORT=$(expr `(flock -x 200; cat /tmp/nextport; expr \( \`cat /tmp/nextport 2>/dev/null\` + 1 \) % 10000 > /tmp/nextport;) 200>/tmp/nextport.lock` + 30000)

Keybase proof

I hereby claim:

  • I am kingmar on github.
  • I am kingmar (https://keybase.io/kingmar) on keybase.
  • I have a public key ASD3hf41MIJ2YFMUweQrg3_DmLWJObSoe9lYYE179eK8BQo

To claim this, I am signing this object:

--- collectd-5.4.1.ebuild 2014-06-30 21:31:02.000000000 +0200
+++ collectd-9999.ebuild 2014-07-21 17:52:57.350132618 +0200
@@ -10,12 +10,19 @@
DESCRIPTION="A a daemon which collects system statistic and provides mechanisms to store the values"
-HOMEPAGE="http://collectd.org"
-SRC_URI="${HOMEPAGE}/files/${P}.tar.bz2"
+if [[ ${PV} == *9999* ]]; then
+ inherit git-2
@KiNgMaR
KiNgMaR / radiation.js
Created February 9, 2014 16:18
Reads data from a Mighty Ohm Geiger Counter that is connected via RS232, makes it available via a callback and a TCP socket.
/**
* RADIATION WIDGET - SERVER BIT
*/
var
serialport = require('serialport'),
net = require('net');
exports.widget = function(eventTarget) {
const CONFIG = {
@KiNgMaR
KiNgMaR / gist:6371170
Created August 28, 2013 20:57
This VBA script for MS Outlook counts all unique *recipient* addresses from emails in the current inbox and writes them to a text file.
' This VBA script for MS Outlook counts all unique recipient addresses
' from emails in the current inbox and writes them to a text file.
Option Explicit
' REQUIRED: Add Project Reference to "Microsoft Scripting Library" for Dictionary class!
Sub ListReceivedMailAddrs()
Dim oApp As Outlook.Application
Dim oNS As Outlook.NameSpace
@KiNgMaR
KiNgMaR / cloudflare-ipset.sh
Last active January 22, 2024 17:28
Cloudflare IPTABLES and IPSET scripts - fixed 2022-02-23
#!/bin/bash
# name of the ipset - v4 or v6 will be appended.
IPSET_NAME=cloudflare-
# argument: v4 or v6 (defaults to v4)
cloudflare_ipset ()
{
local ipv
local inetv
@KiNgMaR
KiNgMaR / gist:1926569
Created February 27, 2012 19:46 — forked from nanha/gist:1385106
node.js CRC32
var crypto = require('crypto');
/**
* Calculates the hash/checksum of a string. Default algorithm is MD5.
*
* @param {String} str
* @param {String} algorithm
* @return {String} checksum
* @api public
*/
@KiNgMaR
KiNgMaR / blitzortung_data.class.php
Created June 29, 2011 19:52
blitzortung.mobi DB update
<?php
/* (c) Ingmar Runge 2011 */
class blitzortung_data
{
protected $cache_dir = NULL;
protected $ch = NULL;
protected $bo_user = '', $bo_pass = '';
protected $interface = '';