Skip to content

Instantly share code, notes, and snippets.

View mammuth's full-sized avatar

Max Muth mammuth

View GitHub Profile
@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.
/* ---------------
name: Clean Google Calendar
author: @Gambloide
matches: https://google.com/calendar/*
version: 1.0
------------------ */
/* Calendar */
@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;
}
.correct,
.incorrect {
background: none !important;
}
.questioncorrectnessicon {
display: none;
}
.multichoiceset input[type=checkbox] {
display: none;
}
@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
@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
"""
# 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 / 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;
@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 / 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);