Skip to content

Instantly share code, notes, and snippets.

View Telling's full-sized avatar

Stephan Telling Telling

View GitHub Profile
@Telling
Telling / create-daemon-user.bash
Last active November 1, 2022 17:52
create-daemon-user
#!/usr/bin/env bash
# Make sure we are root
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
if [ -z "$1" ]; then
echo "Provide the user name as the first argument." 1>&2
@Telling
Telling / le-renew-webroot
Last active March 6, 2016 11:23 — forked from thisismitch/le-renew-webroot
Let's Encrypt Auto-Renewal using the Webroot Plugin with multiple configurations and more.
#!/usr/bin/env bash
# exit on error
set -e
# unset vars
unset configs
unset letsencrypt_path
# Arguments parsing
@Telling
Telling / f2bufwnginx.md
Created February 14, 2016 13:35
Setup fail2ban (v0.8.11) with ufw and nginx

Setup fail2ban (v0.8.11) with ufw and nginx on Ubuntu 14.04

Install fail2ban & ufw

If you haven't already, install fail2ban and ufw:

sudo apt-get install fail2ban ufw

Now make a copy of the fail2ban configuration, and name it jail.local:

@Telling
Telling / sort_by_year_month.py
Created August 20, 2015 21:36
sort by yeah, month on wierd string
@property
def by_year_month(self):
""" Sorts the list, and returns it sorted by year and month.
"""
self.webalizer_months.sort(
key=lambda x: (int(x.split(' ', 1)[0]), int(x.split(' ', 2)[1]))
)
return self.webalizer_months
@Telling
Telling / bitlbee.conf
Created February 15, 2015 15:19
Upstart script for bitlbee
# Bitlbee
description "Bitlbee startup script"
# When to start the service
start on runlevel [2345]
# When to stop the service
stop on runlevel [016]
@Telling
Telling / gist:7b5ebaba6497e4d8c821
Created February 2, 2015 22:14
count stuff with pdftotext
# Count how many pages approximately in PDF (1 page = 2400 chars)
pagecount() {
echo $(( $(pdftotext "$*" - | tr -d '.' | wc -m) / 2400.00 ))
}
# Count characters in PDF
charcount() { pdftotext "$*" - | tr -d '.' | wc -m }
# Count words in PDF
wordcount() { pdftotext "$*" - | tr -d '.' | wc -w }
@Telling
Telling / twinfo.py
Last active August 29, 2015 14:12
Python script to show whom of those one follow on twitch.tv is live and capable of opening them with livestreamer.
""" twinfo will show you which of the channels you follow are currently live,
and allow you to input a number to open it with livestreamer[0].
[0]: https://github.com/chrippa/livestreamer
"""
import grequests
import requests
import argparse
import os
#!/bin/bash
hosts=(
ftp.dk.debian.org
ftp.cn.debian.org
)
for host in ${hosts[@]}; do
IP=`nslookup $host | sed 's/Address: //' | tail -n 2 | head -n 1`
echo ==== TESTING $IP \($host\) ====
echo Ping: `ping -c 64 $IP | grep rtt`
#!/usr/bin/env python
""" .ics parser
Usage:
ics_parser.py [start_date] [end_date] <file>
"""
from icalendar import Calendar
from docopt import docopt