Skip to content

Instantly share code, notes, and snippets.

@FloStar3000
FloStar3000 / th-bingen-sign-in-autoclicker.md
Last active August 14, 2022 20:22
TH Bingen (Olat) Auto-click on sign in button

Use the Tampermonkey Plugin: https://www.tampermonkey.net Firefox: https://addons.mozilla.org/de/firefox/addon/tampermonkey/

For the olat.vcrp.de page, on the first page visit the script will not work because you have to select your school. For the Password Prompt: A password manager (like LastPass or Bitwarden) is needed that auto-fills the password on page load.

On the OLAT front page

// ==UserScript==
// @name         Auto-Click Olat Front Page
@FloStar3000
FloStar3000 / esp-idf-fix-component-error
Created November 25, 2021 00:30
ESP-IDF with VSCode. Get rid of warning when importing ESP-IDF specific components like FreeRTOS
## Fix Red Marking of ESP-IDF Includes (Header files)
e.g. `#include "freertos/FreeRTOS.h"`
Right click on the red marked line, click quick fixes, add include path
Add the esp-idf components path to the "include paths" of the C/C++ Extenstions. Something like /home/user/esp/esp-idf/components/**
@FloStar3000
FloStar3000 / downloadText.js
Created July 20, 2021 14:27
Download Text as File in Javascript
const element = document.createElement('a');
const file = new Blob([text], { type: 'text/plain' });
element.href = URL.createObjectURL(file);
element.download = `${filename}.txt`;
document.body.appendChild(element);
element.click();
@FloStar3000
FloStar3000 / ts
Created June 11, 2021 07:45
Download File programmatically on website / JS/TS
const download = async () => {
const fetchResult = await fetch("http://mywebsite.com/download")
if(fetchResult.status === 200){
const blob = await fetchResult.blob();
var url = window.URL.createObjectURL(blob)
var a = document.createElement("a")
a.href = url
a.download = `DownloadFilename.csv`
document.body.appendChild(a) // we need to append the element to the dom -> otherwise it will not work in firefox
a.click()
@FloStar3000
FloStar3000 / gist:959c917a858e3c2aec35c372de8366f2
Created June 10, 2021 13:54
Styled Components with Typescript and defined (default) props
import styled, { DefaultTheme } from "styled-components";
import { defaultTheme } from "../styles/theme";
type ButtonProps = Partial<{
size: 's'|'m'|'l',
theme?: DefaultTheme,
block: boolean,
backgroundColor: string;
borderColor?: string;
@FloStar3000
FloStar3000 / gist:79ebaf9e24ed1b57fd385463010051d5
Created March 23, 2021 15:22
Nodejs: Format CA Cert for WiFiClientSecure
// use exported ca root cert from browser
const rawCert = fs.readFileSync('certfile','utf-8')
const lines = rawCert.split('\r\n')
const linesFormatted = lines.map(line=>`\"${line}\\n\" \\`)
//
fs.writeFileSync('cert.txt',linesFormatted.join('\n'))
@FloStar3000
FloStar3000 / gist:c286f49088a8569f328cd3907f12eaca
Created December 5, 2020 13:31
Deutsche Telekom: Anrufe ins Mobilfunknetz sperren
Wir haben den Magenta Hybrid Tarif und nutzen Festnetztelefonie. Die Telekom verlangt immer noch
einen Pauschalbetrag plus 17 cent für Anrufe ins Mobilfunknetz. Da alle bei uns in der Familie auf dem Handy
eine Telefonflat besitzen, unterdrücke ich folgendermaßen, dass jemand mit unserem Festnetzanschluss das Mobilfunknetz anruft:
1. Telefoniecenter öffnen und anmelden: telefoniecenter.t-online.de/
2. Sicherheit -> Wahlsperre
3. Ganz unten, auf Negativliste klicken
4. Der Negativliste die Vorwahlen aller Mobilfunknummern hinzufügen, eine Liste siehe unten
5. "Nummern auf Negativliste sperren" aktivieren
fertig!
@FloStar3000
FloStar3000 / gist:3b8400133b4f115eb6baf413253cdd13
Created November 23, 2020 11:26
InvalidSignatureException : AWS Amplify API Requests fail
When calling a manually calling an API Gateway Endpoint, you get a 403 Response with Response Header x-amzm-error-type:InvalidSignatureException
When configuring your endpoint with Amplify.configure({...}) (see https://docs.amplify.aws/lib/restapi/getting-started/q/platform/js#configure-your-application)
add a region:
{
...
API: {
@FloStar3000
FloStar3000 / gist:0e2c953f1a54e9147d7e203cbeb156b1
Created November 11, 2020 13:32
Serverless Framework: Easy shortcut to test a function with event JSON
Normally, you would test a serverless function like this:
serverless invoke local -f methodName --path path/to/event.json
Shortcut:
1. All event files must be in the same folder (e.g. mocks-folder/) and named like this: [methodname].json
2. In package.json, add script: "test":"serverless invoke local -f $method --path mocks-path/$method.json"
3. Test a function with: method=functionName npm run test