Skip to content

Instantly share code, notes, and snippets.

@flxai
flxai / geizhals.sh
Created November 18, 2015 03:31
Get lowest price via Geizhals
#!/bin/bash
# Gets lowest price of an item listen on geizhals.de
item="$1"
url="https://geizhals.de/${item}.html"
price=$(curl -s "$url" | grep lowPrice | sed 's/.*gh_price\">\&euro\;\ \([0-9]\+\),\([0-9]\{2\}\).*/\1.\2€/')
echo $price
@flxai
flxai / ffks-fix-ugly-keys.sh
Last active December 31, 2015 09:27
Fixes some ugly fastd peers' keys
grn='\e[0;32m'
red='\e[0;31m'
clr='\e[0m'
for i in $1/*; do
fn=$(basename $i)
# comment keys
grep -qc '^# \?key' $i
ckeyworks=$?
@flxai
flxai / ffks-sort-nodes.sh
Created December 31, 2015 09:28
Sets file system modification time according to files certain contents
#!/bin/bash
grn='\e[0;32m'
red='\e[0;31m'
clr='\e[0m'
for f in $1/*; do
fn=$(basename $f)
# file system time stamp
fsts=$(stat -c%y $f | awk '{print $1}')
# key file time stamp
#!/bin/bash
for f in $(ls -tr1 "$1"); do
d="$(stat -c%y $f | awk '{print $1}')T00:00:00"
echo $d $f
git add $f
GIT_COMMITER_DATE="$d" GIT_AUTHOR_DATE="$d" git commit -m "Add $f"
echo
done
@flxai
flxai / extractpartition.sh
Created April 22, 2016 17:57
Partition extraction from image files
#!/bin/bash
# Extracts a partition from a full disk image containing a partition table
# Colors
red='\033[0;31m'
green='\033[0;32m'
yellow='\033[0;33m'
cyan='\033[0;36m'
nc='\033[0m' # no color
@flxai
flxai / flipdots.py
Created April 26, 2016 23:47
Send image to flipdot display
#!/usr/bin/env python3
import socket
import sys
from PIL import Image
host = '192.168.3.36';
port = 2323;
w = 48
#!/bin/bash
# Count users currently logged into a list of Freifunk Kassel nodes
url_base=https://graphite.freifunk-kassel.de
url_params="rawData=true"
time_offset="5min"
node_pre="ffks.nodes."
node_post=".clients"
@flxai
flxai / fd-wol.sh
Created September 8, 2016 21:31
flipdot Wake On LAN
#!/bin/bash
# Pings a list of hosts and send a Wake On LAN request on success
wake_mac='e8:9a:8f:fd:e6:ce'
declare -a ping_hosts=(\
192.168.3.36 \ # flipdot display
guest.fd \
drinks-touch.fd \
drinks.fd \
)
@flxai
flxai / fd-power-watch.sh
Last active September 13, 2016 15:48
flipdot Shutdown on disconnected power supply
#!/bin/bash
# When the power supply is disconnected, shut down machine after a defined time
# and warning messages
# Time in seconds to shutdown device after disconnected power supply
grace_time=500
timeout=0
while :; do
state=$(upower -i "$battery" | grep state | awk '{print $2}')
@flxai
flxai / seatfinder-download-and-plot.py
Created October 26, 2018 00:20
Download and plot seatfinder data
import requests
import os
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
BASE_URL = 'https://seatfinder.bibliothek.kit.edu/kassel/getdata.php?location%5B0%5D=UBA0EP,UBA1EP,UBA2EP,UBA3EP,UBB0EP,UBB0GP,UBB1EP,UBB1GP,UBB2EP,UBB2GP,LeoEG,LeoOG&values%5B0%5D=manualcount,seatestimate&after%5B0%5D=-1year&before%5B0%5D=now'
DELIMITER = ';'
FILE_MANUAL_COUNT = 'seatfinder_manual_count.csv'