Skip to content

Instantly share code, notes, and snippets.

View mammuth's full-sized avatar

Max Muth mammuth

View GitHub Profile
@mammuth
mammuth / backlinks.php
Last active December 19, 2023 18:41
Get Backlinks to URL in PHP via Google [Warning: deprecated]
@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 / starcounter.js
Created July 3, 2019 09:27 — forked from yyx990803/starcounter.js
Count your total stars!
var https = require('https'),
user = process.argv[2],
opts = parseOpts(process.argv.slice(3))
request('/users/' + user, function (res) {
if (!res.public_repos) {
console.log(res.message)
return
}
var pages = Math.ceil(res.public_repos / 100),
@mammuth
mammuth / mvg_departures.py
Created October 8, 2019 19:48
MVG Live unofficial API demo.
"""
Demo / usage of the API endpoint which mvg.de uses itself.
Printed example output:
['21:58: S8 nach München Flughafen Terminal ', '22:02: S8 nach Weßling(Oberbay) ', '22:22: S8 nach Herrsching ']
"""
import requests
import datetime
@mammuth
mammuth / google_light.yaml
Last active December 12, 2019 09:21
Fixed Google Home Light theme for Home Assistant
# Original: https://github.com/liri/lovelace-themes
Google - Light - Fixed:
### Fonts ###
primary-font-family: "'Open Sans','Rubik',Roboto,sans-serif"
paper-font-common-base_-_font-family: "var(--primary-font-family)"
paper-font-common-code_-_font-family: "var(--primary-font-family)"
paper-font-body_-_font-family: "var(--primary-font-family)"
paper-font-subhead_-_font-family: "var(--primary-font-family)"
paper-font-headline_-_font-family: "var(--primary-font-family)"
paper-font-caption_-_font-family: "var(--primary-font-family)"
@mammuth
mammuth / HaasaLittle.py
Created November 1, 2019 11:54 — forked from unaiur/HaasaLittle.py
Simpler and faster version of Haaska AWS Lambda in https://github.com/mike-grant/haaska
#!/usr/bin/env python3.7
# coding: utf-8
# Copyright (c) 2019 Unai Uribarri <unaiur@gmail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
@mammuth
mammuth / hreflang_templatetag.py
Created July 24, 2019 13:49
Template tag for django-cms which renders hreflang alternate meta-tags for CMS pages as well as app detail pages.
@register.inclusion_tag('templatetags/hreflangs.html', takes_context=True)
def render_hreflangs(context):
"""
This templatetag renders hreflang alternate tags for all available languages.
It supports CMS pages and detail pages of app hooks
The apps detail view needs to have `slug` as last part in the url, eg. /de/produkte-a-z/napura` (slug: napura`)
:param context:
:return:
"""
@mammuth
mammuth / apartment-distances.js
Last active July 17, 2019 18:33
Calculate your transit time between 1-n locations. Use if you want to compare travel time from a new flat to your favorite spots
/*
* What?
* A JavaScript script that prints out travel times between one origin and multiple targets.
*
* Example output
* $ node apartment-distances.js
* Marienplatz, Munich "24 mins"
* Google Munich "25 mins"
* Jetbrains GmbH, Munich "26 mins"
*
@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;
window.addEventListener('touchstart', function onFirstTouch() {
// we could use a class
document.body.classList.add('user-is-touching');
// or set some global variable
window.USER_IS_TOUCHING = true;
// or set your app's state however you normally would
myFrameworkOfChoice.dispatchEvent('USER_IS_TOUCHING', true);