Skip to content

Instantly share code, notes, and snippets.

View K-Ko's full-sized avatar

Knut Kohl K-Ko

  • Germany
View GitHub Profile
@K-Ko
K-Ko / adminer-update.sh
Last active August 29, 2015 14:06
Hold Adminer up-to-date
#!/bin/bash
### Set pathe to Adminer document root
path=/var/www/html/adminer/public_html
### Fetch latest Adminer for MySQL only
wget -qO $path/.new http://www.adminer.org/latest-mysql.php
### Check if the download was successful and move the just downloaded file to its correct name
### (sometimes the downlaoded file is empty, I think it happens on timeouts)
@K-Ko
K-Ko / apt_check.py
Last active September 11, 2017 18:55
apt_check.py is not more available in jessie/stretch, so remember it here
#!/usr/bin/python
# sudo apt-get install python-apt
# sudo mkdir -p /usr/lib/update-notifier
# sudo wget -qO /usr/lib/update-notifier/apt-check https://gist.githubusercontent.com/K-Ko/3bf63ce8fb55a8add54db570fd6b600c/raw/apt_check.py
# sudo chmod +x /usr/lib/update-notifier/apt-check
# /usr/lib/update-notifier/apt-check --human-readable
# nice apt-get -s -o Debug::NoLocking=true upgrade | grep ^Inst
@K-Ko
K-Ko / S0.py
Last active May 15, 2017 09:58
S0 GPIO reader enhanced
#!/usr/bin/env python
# http://raspberrypi.stackexchange.com/a/36245
import sys, getopt, datetime, time, signal
import RPi.GPIO as GPIO
try:
from urllib.request import Request, urlopen # Python 3
except:
@K-Ko
K-Ko / sysup
Last active December 25, 2019 12:01
Update debian based systems shell script
#!/bin/bash
###
### sudo wget -qO /usr/local/bin/sysup https://gist.github.com/K-Ko/f247facdc73392e3c736a2e09d3136ed/raw/sysup
### sudo chmod +x /usr/local/bin/sysup
###
e () {
echo "::: ----------------------------------------------------------------------"
echo "::: $@"
}
@K-Ko
K-Ko / dynmotd
Last active July 9, 2017 13:01
Dyn. motd for debain based systems
#!/bin/bash
###
### sudo wget -qO /usr/local/bin/dynmotd https://gist.github.com/K-Ko/7eb8d2e8abdf36195efe6e1d814907b9/raw/dynmotd
### sudo chmod +x /usr/local/bin/dynmotd
### echo /usr/local/bin/dynmotd >> ~/.profile
###
echo
uname -srvm
echo
@K-Ko
K-Ko / currant_pi_from_scratch.sh
Last active September 22, 2017 22:56
Full automatic install of https://github.com/ColinWaddell/CurrantPi from scratch incl. web server
#!/bin/bash
#
# wget -q -O - https://gist.githubusercontent.com/K-Ko/30301a7bbb6c15b5bdda8aeeb512eb6c/raw/currant_pi_from_scratch.sh | bash
#
# Web server
sudo apt-get install lighttpd php-cgi -y
sudo lighttpd-enable-mod fastcgi fastcgi-php
sudo service lighttpd force-reload
@K-Ko
K-Ko / shutdown.py
Created January 22, 2018 10:18
Shutdown script for Raspberry Pi
#!/usr/bin/env python
#
# Shutdown script for Raspberry Pi
#
# Based on
# http://www.forum-raspberrypi.de/Thread-tutorial-hoch-und-runterfahren-mittels-taster-incl-status-led
#
# Watch LOW level on pin 5 to enter sleep mode
# Use power LED as status LED on pin 35: BLINK = confirm button
import os, time
@K-Ko
K-Ko / git.nigthly
Last active August 9, 2018 20:08
Automatic push daily work
#!/bin/bash
#
# sudo wget -O /usr/local/bin/git.nigthly https://gist.githubusercontent.com/K-Ko/bd91fa6980819e749069f6714714a318/raw/git.nigthly
# sudo chmod 755 /usr/local/bin/git.nigthly
#
# set -x
[ -z "$1" ] && printf "\nUsage: $0 <repo directory> [<repo directory> ...]\n" && exit 1
@K-Ko
K-Ko / fn.slugify.sql
Last active June 4, 2019 17:15 — forked from jareis-zz/fn.slugify.sql
slugify function for MySQL
/*
The MIT License (MIT)
Copyright (c) 2014 jose reis<jose.reis@artbit.pt>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@K-Ko
K-Ko / curl-code.sh
Last active October 13, 2021 00:11
Curl exit codes as bash array
#
# curl-code.conf
#
# Curl exit Codes
#
# https://curl.haxx.se/docs/manpage.html
# https://curl.haxx.se/libcurl/c/libcurl-errors.html
#
declare -a curl_code