Skip to content

Instantly share code, notes, and snippets.

View mammuth's full-sized avatar

Max Muth mammuth

View GitHub Profile
@mammuth
mammuth / aspect-ratio-mixin.less
Created October 31, 2018 13:22
Less aspect ratio mixin
.m-aspect-ratio (@width, @height) {
position: relative;
&:before {
display: block;
content: "";
width: 100%;
padding-top: (@height / @width) * 100%;
}
> .content {
position: absolute;
# 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
"""
@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
.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 / compress-pdf-with-gs.md
Last active August 11, 2023 19:59 — forked from guifromrio/compress-pdf-with-gs.md
Compress PDF files with ghostscript

This can reduce files to ~15% of their size (2.3M to 345K, in one case) with no obvious degradation of quality.

ghostscript -r72 -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/default -dNOPAUSE -dQUIET -dBATCH -dCompressFonts=true -sOutputFile=output.pdf input.pdf

Change -r for the resolution.

Other options for PDFSETTINGS:

  • /screen selects low-resolution output similar to the Acrobat Distiller "Screen Optimized" setting.
  • /ebook selects medium-resolution output similar to the Acrobat Distiller "eBook" setting.
@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'

Keybase proof

I hereby claim:

  • I am mammuth on github.
  • I am muth (https://keybase.io/muth) on keybase.
  • I have a public key whose fingerprint is A5A6 0414 169C 05C0 2D9D 60C5 2227 B61A 9E20 EA50

To claim this, I am signing this object: