Skip to content

Instantly share code, notes, and snippets.

View mammuth's full-sized avatar

Max Muth mammuth

View GitHub Profile
@mammuth
mammuth / book_notes_to_evernote.py
Last active January 15, 2019 20:10
Export book quotes/notes from FBReader to Evernote
"""
Reads in the export file from FBReader and imports your notes / bookmarkes / quotes to evernote.
It's done by sending a mail to your evernote-mail which then creates a note in your default notebook.
It creates one evernote note per quote. Each titled with the book title.
Additionally, it creates an optional summary note, which contains all quotes from the given book.
To use, fill out the settings variables below.
"""
@mammuth
mammuth / read_dotenv_variable.sh
Created December 17, 2018 10:54
Read a certain .env variable in bash
DATABASE_NAME=$(cat .env | grep DATABASE_NAME | sed -E 's/(.*)=(.*)/\2/' | xargs);
@mammuth
mammuth / goodreads_shelf_average_page_number.py
Last active December 8, 2018 11:50
Get the average number of pages of your books on a given Goodreads shelf
#!/usr/bin/python3
"""
This script returns the average number of pages of the books on a given Goodreads shelf.
Example Output:
> $ python3 goodreads_shelf_average_page_number.py
Average page number: 354
Number of books in shelf to-read-next with known page numbers: 19/24
Total number of pages in your shelf: 8496
To read that within one year, you need to read 23 pages a day
@mammuth
mammuth / create_iptables.sh
Last active February 18, 2018 15:09
Script to create minimal iptables and store them via iptables-persistent
#!/bin/sh
# This script sets iptables rules vor IPv4 and IPv6. Currently IPv6 just has a drop anything policy.
# ToDo: Drop outgoing packages with spoofed source address - add local address as src in output rules.
###################
# RESET ALL RULES #
###################
iptables --flush
ip6tables --flush
# models.py
class Job(models.Model):
slug = models.SlugField(max_length=60)
@models.permalink
def get_absolute_url(self):
return 'career:job-detail', (self.pk, self.slug)
# urls.py
path('<int:id>/<slug:slug>/', JobDetailView.as_view(), name='job')
@mammuth
mammuth / email_obfuscation.py
Created November 21, 2017 10:21
Methods for obfuscating E-Mail addresses via HTML comments and JavaScript to prevent some spam in Django
"""
Requires django (mark_safe and escape)
Add the following two properties to your model (and update the naming of the email field)
In your templates: <a href="{{ person.email_obfuscated_href }}">{{ person.email_obfuscated_name }}</a>
Result: <a href="javascript:window.location.href = 'mailto:' + ['max', 'mustermann.com'].join('@')">max<!---->@<!---->mustermann.com</a>
Inspired by https://github.com/Blueshoe/djangocms-link2
"""
.correct,
.incorrect {
background: none !important;
}
.questioncorrectnessicon {
display: none;
}
.multichoiceset input[type=checkbox] {
display: none;
}
@mammuth
mammuth / comdirect.css
Last active July 8, 2017 16:40
Comdirect CSS Changes
/*
* Overview
* https://kunde.comdirect.de/itx/persoenlicherbereich/anzeigen
*/
/* Remove IBAN Column */
form#j_idt67-j_idt68-0-j_idt70 table tr th:nth-of-type(3),
form#j_idt67-j_idt68-0-j_idt70 table tr td:nth-of-type(3) {
display: none !important;
}
/* ---------------
name: Clean Google Calendar
author: @Gambloide
matches: https://google.com/calendar/*
version: 1.0
------------------ */
/* Calendar */
@mammuth
mammuth / github_bot.py
Last active March 8, 2017 15:23
Simple script that allows us to comment to pull requests with a GitHub bot
#!/usr/bin/env python
from __future__ import print_function
import os
import sys
import json
import requests
GITHUB_API_URL = 'https://api.github.com'
TOKEN = 'YOUR_SECRET_TOKEN_HERE'