Skip to content

Instantly share code, notes, and snippets.

View mammuth's full-sized avatar

Max Muth mammuth

View GitHub Profile
@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 <[email protected]>
#
# 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 / 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 / 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 / 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),
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);
@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