Skip to content

Instantly share code, notes, and snippets.

@npilk
npilk / phone-hook.py
Created Apr 25, 2022
python script that toggles DNS blocking when a landline phone is taken on or off the hook (using a Raspberry Pi + door sensor)
View phone-hook.py
import RPi.GPIO as GPIO
import time
import subprocess
# input/output setup for the door sensor
GPIO.setmode(GPIO.BOARD)
GPIO.setup(7, GPIO.IN, pull_up_down = GPIO.PUD_UP)
is_off_hook = None
old_off_hook = None
@npilk
npilk / custom-web-search.js
Created Jan 17, 2022
Cloudflare Worker script for customizing web search
View custom-web-search.js
// Cloudflare Worker script to automatically redirect search queries based on trigger words
addEventListener("fetch", event => {
event.respondWith(handleRequest(event.request))
})
// status code for redirect response; need something that won't cache
var statuscode = 303