Skip to content

Instantly share code, notes, and snippets.

View morriq's full-sized avatar
🐢
Focusing

Dawid Winiarczyk morriq

🐢
Focusing
View GitHub Profile
#!/bin/bash
#based off: https://gist.github.com/naholyr/4275302
set -e
template=$'#!/bin/sh\n### BEGIN INIT INFO\n# Provides: <NAME>\n# Required-Start: $local_fs $remote_fs $network $named $time $syslog\n# Required-Stop: $local_fs $remote_fs $network $named $time $syslog\n# Default-Start: 2 3 4 5\n# Default-Stop: 0 1 6\n# Description: <DESCRIPTION>\n### END INIT INFO\n\nSCRIPT=<COMMAND>\nRUNAS=<USERNAME>\n\nPIDFILE=/var/run/<NAME>.pid\nLOGFILE=/var/log/<NAME>.log\n\nstart() {\n if [ -f /var/run/$PIDNAME ] && kill -0 $(cat /var/run/$PIDNAME); then\n echo \'Service already running\' >&2\n return 1\n fi\n echo \'Starting service…\' >&2\n local CMD="$SCRIPT &> \\"$LOGFILE\\" & echo \\$!"\n su -c "$CMD" $RUNAS > "$PIDFILE"\n echo \'Service started\' >&2\n}\n\nstop() {\n if [ ! -f "$PIDFILE" ] || ! kill -0 $(cat "$PIDFILE"); then\n echo \'Service not running\' >&2\n return 1\n fi\n echo \'Stopping service…\' >&2\n pkill -P $(cat "$PIDFILE") && rm -f "$PIDFILE"\n
@morriq
morriq / fan
Last active December 16, 2020 23:27
fan
#!/bin/bash
# /etc/init.d/fan
### BEGIN INIT INFO
# Provides:fan
# Required-Start:$remote_fs $syslog
# Required-Stop:$remote_fs $syslog
# Default-Start:2 3 4 5
# Default-Stop:0 1 6
@morriq
morriq / fan.py
Last active December 17, 2020 01:45
#!/usr/bin/python3
import sys
import time
from gpiozero import LED # doc: https://gpiozero.readthedocs.io/
from systemd import journal
# define the GPIO to control the transistor's B pin
fan = LED(17)
def cpu_temp():
"use strict";
var addEventCallback = require('addEventCallback');
var callInWindow = require('callInWindow');
var makeString = require('makeString');
addEventCallback(function (containerId, eventData) {
var tags = eventData.tags.map(function (tag) {
return {
containerId: containerId,
@morriq
morriq / europe-countries.json
Last active August 29, 2015 14:13
Europe Countries JSON
[
"Albania",
"Andorra",
"Austria",
"Belarus",
"Belgium",
"Bosnia and Herzegovina",
"Bulgaria",
"Croatia",
"Cyprus",