Skip to content

Instantly share code, notes, and snippets.

Florian Klien flowolf

Block or report user

Report or block flowolf

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View getBlockLists.sh
#!/usr/bin/env sh
# Download lists, unpack and filter, write to gzipped file
curl -s https://www.iblocklist.com/lists.php \
| grep -A 2 Bluetack \
| sed -n "s/.*value='\(http:.*\)'.*/\1/p" \
| xargs wget -O - \
| gunzip \
| egrep -v '^#' \
| gzip - > bt_blocklist.gz
View setup_button.sh
#!/bin/bash
# setup-shutdown.sh
# Installs python script to enable safe shutdown of Raspberry Pi on PIN5/GPIO3 Logic LOW
# Author: 8bitjunkie.net
# Adapted from https://svn.nwesd.org/linuxdev/config_samples/lenny_setup/setup-denyhosts
# INSTRUCTIONS:
# Download and run this setup script in the terminal using the following command:
# curl http://pie.8bitjunkie.net/shutdown/setup-shutdown.sh | bash
View shutdown.rc
#! /bin/sh
### BEGIN INIT INFO
# Provides: pi_shutdown
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: S
# Default-Stop:
# Short-Description: Shutdown on GPIO trigger
# Description: Python script listens for GPIO and runs shutdown command
### END INIT INFO
View shutdown.py
#!/usr/bin/python
import RPi.GPIO as GPIO
import time
import subprocess
GPIO.setmode(GPIO.BOARD)
# we will use the pin numbering to match the pins on the Pi, instead of the
# GPIO pin outs (makes it easier to keep track of things)
# use the same pin that is used for the reset button (one button to rule them all!)
View fail2ban_ctry_stats.sh
#!/bin/bash
# get a country statistic for Fail2Ban blocks:
# this just accounts for IPs once. Multiple failed attempts by one IP just show up once for a country.
for i in `sudo cat /var/log/fail2ban.log | sed 's/.*[Bb]an \(.*\)/\1/' | sort | uniq | cut -d ' ' -f 1 | grep "\."`;
do
echo $i; whois $i | grep country\: |head -n 1 >> fail2ban_ctry.log ;
done
cat fail2ban_ctry.log | sed 's/country: //g' |sort | uniq -c | sort -nr
View RFID door opener
/**
* door lock application (c) 2011 Florian Klien
* some code parts are borrowed from different authors ;) thx
*/
#include <NewSoftSerial.h>
#define rxPin 2
#define txPin 3
View Salt postgres config
# my working salt postgres config (updated since first post on IRC #salt)
postgres_server:
pkg:
- installed
- pkgs:
- postgresql
service:
- running
- name: postgresql
- enable: True
@flowolf
flowolf / transmission_sum_up.py
Last active Feb 22, 2016
Sum up your transmission uploads
View transmission_sum_up.py
#!/usr/bin/python
# tested with transmission-remote 2.51 (13280)
# call like:
# $ transmission-remote -l | ./sum_up.py
# units: https://en.wikipedia.org/wiki/Megabyte
import sys
total = 0
input = sys.stdin
for l in input:
@flowolf
flowolf / phone_booth_austria
Last active Jan 25, 2016
query all phone booths in Austria
View phone_booth_austria
/*
This is an Overpass query.
It queries all phone booths in Austria.
*/
area
[admin_level=2]
["boundary"="administrative"]
["name"="Österreich"]->.a;
node
(area.a)
@flowolf
flowolf / gist:7247585
Last active Dec 27, 2015
simple python solution to puddle problem found here: http://qandwhat.apps.runkite.com/i-failed-a-twitter-interview/
View gist:7247585
# Python solution to the puddle problem
# from: http://qandwhat.apps.runkite.com/i-failed-a-twitter-interview/
#
# single pass, streaming capable. O(n), memory as much as wall size.
#
def calc_vol(a):
vol = 0
count = [0]
maxi = 0
last = 0
You can’t perform that action at this time.