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.
Get ADB for MacOS: brew install android-platform-tools
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); |
#!/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) |
package main | |
import ( | |
"fmt" | |
"os" | |
"os/exec" | |
"syscall" | |
"time" | |
"unsafe" | |
) |
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
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 |
Promise.defer = function () { | |
return (_ => { | |
let resolve, reject | |
let p = new Promise((res, rej) => { | |
resolve = res | |
reject = rej | |
}) | |
return {promise: p, reject, resolve} | |
})() | |
} |
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 { |