Skip to content

Instantly share code, notes, and snippets.

@koma5
koma5 / mqttHeartbeat.py
Last active December 13, 2016 18:43
every minute like that: byteli/mqtt/heartbeat 19:40:01 up 6 days, 4:42, 1 user, load average: 0.00, 0.00, 0.00
import os, time, mosquitto, subprocess
# cronjon
# */2 * * * * /usr/bin/python /root/mqttHeartbeat.py 2>&1 > /dev/null
pidFile = '/var/run/mqttHeartbeatPid'
def on_connect(userdata, flags, rc):
print "connected..."
@koma5
koma5 / mqttThermostat.py
Created December 13, 2016 18:32
Usage : ./mqttThermostat.py minTempC maxTempC stopTime
#!/usr/bin/python
import mosquitto, sys, datetime
min = float(sys.argv[1])
max = float(sys.argv[2])
stopTime = datetime.datetime.strptime(sys.argv[3], "%H:%M").time()
@koma5
koma5 / mqttTempColorScale.py
Last active December 15, 2016 16:51
mqtt color temp scale from blue for -15 C° to red for 40 C° via green
# -*- coding: utf-8 -*-
import mosquitto
def on_connect(client, userdata, rc):
client.subscribe("vw/temp/1")
def on_message(client, userdata, msg):
rgb = colorWheel(scaleTempToColor(float(msg.payload)))
client.publish("vw/neo/color", ','.join(str(x) for x in rgb))
@koma5
koma5 / pingLoop.bat
Created January 21, 2014 07:11
ping until it pings back and than do something...
:wooot
ping -n 5 example.com
IF "%ERRORLEVEL%"=="0" GOTO :end
GOTO :wooot
:end
@koma5
koma5 / bigFile.bat
Last active January 3, 2016 21:19
generate 10k 1MB (1048576 bytes) files.
@echo off
title bigFile.bat
set /a x=0
del bigFile
mkdir bigFile
:loopname
fsutil file createnew bigFile\F%x%.tmp 1048576
@koma5
koma5 / backup.bat
Created May 18, 2012 11:39
automated mysql dumps on windows - dumps all dbs which user sees
set MYSQLUSER=username
set MYSQLPASS=password
set BATCHFILE=C:\Temp\auto_built_sql_dump.bat
set DUMPPATH=Z:\
set DRIVE=Z:
net use %DRIVE% \\somehost\some\networkdrive /user:domain\user password
rem building time stamp
set tmp_time=%time:~-11,2%.%time:~-8,2%.%time:~-5,2%
@koma5
koma5 / delete-utf8-bom.vbs
Created February 24, 2012 09:45
this script removes the UTF-8 BOM "" 0xEFBBBF from the beginning of a file / just drag and drop a file on this script
Option Explicit
Const UTF8_BOM = ""
Const ForReading = 1
Const ForWriting = 2
Dim fso
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
@koma5
koma5 / scp_films.sh
Created April 9, 2011 19:51
copy all films in a given directory
#! /bin/sh
torrent=$1
#destination=$2
destination="root@172.16.52:/streamer/movie/"
extension="\
.avi \
.mp4 \
.mkv \
@koma5
koma5 / prowl.sh
Created April 9, 2011 13:09
send prowl push notifications to your iOS device; requires curl -> for debian based distros # apt-get update && apt-get install curl -y
#! /bin/sh
# Usage: ./prowl.sh priority(-2 to 2) app event description
# Example: ./prowl.sh 0 "transmission" "torrent has finished" "Coen Brothers Compilation has finised downloading"
priority=$1
app=$2
event=$3
description=$4
apikey=fill_in_your_API_key_here
if [ $# -ne 4 ]; then
@koma5
koma5 / delo.sh
Created March 23, 2011 22:03
removes oldest file in a given folder, if the filesystem only has 10 Gigs remaining.
#!/bin/sh
dir=$1
minGigs=$2
available=`df --sync $dir | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{print $4}'`
#10 Gbytes in Kbytes
min=$(($minGigs*1024*1024))
if [ $min -gt $available ]