Skip to content

Instantly share code, notes, and snippets.

View coreequip's full-sized avatar

Baxter coreequip

View GitHub Profile
@coreequip
coreequip / Energy-Hamburg.js
Last active June 12, 2024 13:33
Google Apps Script - Energy Hamburg - Last 14 days playlist
const CACHE_TOKEN = 'NRJ14D_TOKEN'
const SPOTIFY_CLIENT_ID = PropertiesService.getScriptProperties().getProperty('CLIENT_ID')
const SPOTIFY_CLIENT_SECRET = PropertiesService.getScriptProperties().getProperty('CLIENT_SECRET')
const REFRESH_TOKEN = PropertiesService.getScriptProperties().getProperty('REFRESH_TOKEN')
const PLAYLIST_ID = PropertiesService.getScriptProperties().getProperty('PLAYLIST_ID')
const ENERGY_HAMBURG_API_URL = 'https://api.nrjnet.de/webradio/playlist/energy/hamburg?day=0&hour=-1';
// fetch a new Spotify access token
function getSpotifyAccessToken() {
let token = CacheService.getScriptCache().get(CACHE_TOKEN);
@coreequip
coreequip / !DimmTrigger.md
Last active October 31, 2024 12:46
DimmTrigger™

DimmTrigger™

A little daemon that detect screen sleep and wakeup and triggers shell script(s) to run an action. Here to toggle the power state of a connected Android TV.

0. Prerquisites

Get ADB for MacOS: brew install android-platform-tools

@coreequip
coreequip / !Generate-HTML.md
Created September 20, 2022 12:57
Generate HTML rollup.js plugin

Generate HTML Rollup.js Plugin

Usage

generateHtml(templatePath, outputFilename, contect, doCompress

Example:

// rollup.config.js plugin part
@coreequip
coreequip / !README.md
Last active February 8, 2022 12:37
FS-Launch - a FirstSprit™ launcher

FS-Launch - a FirstSprit™ launcher

FS-Launch is a powershell script to login, download and run a FirstSpirit config file.

Installing

Just copy the script in a folder of your choice.

Setup

@coreequip
coreequip / i18n-convert.py
Last active September 2, 2020 14:14
Convert a multi-level JSON to a CSV and back
#!/usr/bin/env python3
import csv
import json
import os
import sys
if len(sys.argv) < 2:
print('Usage: {} <convertfile.(json|csv)>'.format(os.path.basename(sys.argv[0])))
exit(0)
@coreequip
coreequip / mumble-muter.go
Last active November 20, 2019 15:31
Listens to the global hotkey MEDIA_PLAY_PAUSE and toggles mumble's self mute.
package main
import (
"fmt"
"os"
"os/exec"
"syscall"
"time"
"unsafe"
)
@coreequip
coreequip / !Shorty.md
Last active November 3, 2020 15:23
Bookmarklet that copies a shortened URL from popular shopping sites into the clipboard.

Shorty

Bookmarklet that copies a shortened URL from popular shopping sites into the clipboard.

Just drag & drop this link -> Shorty <- to your bookmark bar. Edit it an paste as URL this text:

javascript:u=location.href;[[/^(https?:\/\/[a-z]+\.aliexpress\.com\/item\/[0-9]+\.html)\??.*$/,'$1'],[/^(https?:\/\/www\.ebay(?:\.[a-z]+)+\/itm\/)[^\/]+(\/[0-9]+)\??.*$/,'$1-$2'],[/^(https?:\/\/www\.gearbest\.com\/)[^\/]+(\/pp_[0-9]+\.html)\??.*$/,'$1-$2'],[/^(https?:\/\/\w+\.amazon\.[\w.]+\/).*?\/(B[A-Z0-9]+).*$/,'$1dp/$2'],[/^(https?:\/\/\w+\.alternate\.de\/).*?\/(product\/\d+).*$/,'$1$2'],[/^(https?:\/\/\w+\.conrad\.de\/).*?-(\d+\.html).*$/,'$1$2'],[/^(https:\/\/\www\.heise\.de\/).*(-\d+)\.html/,'$1$2'],[/^(https:\/\/\www\.golem\.de\/).*-(\d+)-(\d+)\.html/,'$1$2/$3']].forEach(r=>u=u.replace(r[0],r[1]));d=document;t=d.createElement('textarea');t.textContent=u;d.body.appendChild(t);s=d.getSelection();s.removeAllRanges();t.select();d.execCommand('copy');s.removeAllRanges();d.bo
@coreequip
coreequip / PinningTrustManager.groovy
Created October 30, 2019 17:55
Simple certificate pinning in groovy.
package dev.coreequip.security
import javax.net.ssl.HttpsURLConnection
import javax.net.ssl.SSLContext
import javax.net.ssl.TrustManager
import javax.net.ssl.X509TrustManager
import java.security.MessageDigest
import java.security.cert.CertificateException
import java.security.cert.X509Certificate
@coreequip
coreequip / defer.js
Created September 3, 2019 09:20
ECMAScript Defer Pattern
Promise.defer = function () {
return (_ => {
let resolve, reject
let p = new Promise((res, rej) => {
resolve = res
reject = rej
})
return {promise: p, reject, resolve}
})()
}
@coreequip
coreequip / GrayLogHandler.groovy
Last active July 15, 2019 08:09
Groovy Util.Logging Graylog Handler
package com.acme.logging
import groovy.json.JsonOutput
import java.nio.charset.StandardCharsets
import java.util.logging.Handler
import java.util.logging.Level
import java.util.logging.LogRecord
class GrayLogHandler extends Handler {