Skip to content

Instantly share code, notes, and snippets.

addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
const openaiEndpoint = 'https://api.openai.com/v1/chat/completions';
const openaiApiKey = <store/fetch from cloudflare worker variable>;
async function handleRequest(request) {
// refuse all requests that are not 'POST'
@tagyro
tagyro / usb_hid_keys.h
Created February 25, 2023 07:04 — forked from MightyPork/usb_hid_keys.h
USB HID Keyboard scan codes
/**
* USB HID Keyboard scan codes as per USB spec 1.11
* plus some additional codes
*
* Created by MightyPork, 2016
* Public domain
*
* Adapted from:
* https://source.android.com/devices/input/keyboard-devices.html
*/
@tagyro
tagyro / get_title_and_url.applescript
Created December 14, 2022 20:03 — forked from dongyuwei/get_title_and_url.applescript
Applescript to get frontmost tab’s url and title of various browsers.
# Keep in mind that when asking for a `return` after another, only the first one will be output.
# This example is meant as a simple starting point, to show how to get the information in the simplest available way.
# Google Chrome
tell application "Google Chrome" to return URL of active tab of front window
tell application "Google Chrome" to return title of active tab of front window
# Google Chrome Canary
tell application "Google Chrome Canary" to return URL of active tab of front window
tell application "Google Chrome Canary" to return title of active tab of front window
# Chromium
Use any or all of these commands:
`sudo fdisk -l`
`sudo mount -l`
`df -h`
`sudo mkdir /mnt/usbdrive` — or whatever you want to call it
`sudo mount /dev/sda[number] /mnt/usbdrive` — this mounts the specified drive
`ls /mnt/usbdrive` — this should show that the drive is mounted
@tagyro
tagyro / raspiInfo.cpp
Created October 16, 2019 08:04 — forked from danjperron/raspiInfo.cpp
Raspberry Pi general information
/*
List difference between Raspberry Pi board version
The MIT License (MIT)
Copyright (c) 2015 Daniel Perron
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
@tagyro
tagyro / UIView+Tooltips.h
Created September 13, 2019 18:45 — forked from steventroughtonsmith/UIView+Tooltips.h
WIP tooltips for Mac Catalyst
//
// UIView+Tooltips.h
// Crossword
//
// Created by Steven Troughton-Smith on 13/09/2019.
// Copyright © 2019 Steven Troughton-Smith. All rights reserved.
//
#import <UIKit/UIKit.h>
import os
path = "conf_files"
if not os.path.exists(path):
os.makedirs(path)
t = open("httpTemplate.conf","r")
template = str(t.read())
@tagyro
tagyro / display_off.sh
Last active October 8, 2019 17:05
Turn off the display connected to a rpi
#!/bin/sh
# Turn display off
echo standby 0 | /usr/bin/cec-client -s -d 1
/usr/bin/vcgencmd display_power 0
/usr/bin/tvservice -o
# don't forget to
@tagyro
tagyro / display_on.sh
Last active October 8, 2019 17:04
Turn on the connected display from a rpi
#!/bin/sh
# Turn display on
echo on 0 | /usr/bin/cec-client -s -d 1
/usr/bin/tvservice -p
/usr/bin/vcgencmd display_power 1
sudo chvt 6
@tagyro
tagyro / xcode-filler.sh
Created October 23, 2016 22:39 — forked from terhechte/xcode-filler.sh
Fill Xcode Product with unused space so the app looks bigger than it is
# What crazy talk is this?
# See: https://twitter.com/myell0w/status/790245699694854145
#
# In a world where everything has to be bigger, faster, higher and more,
# users seem to have developed the expectation that the bigger the software
# package, the better the software. However, if you fill up your binary with
# useless data, the app store size might be too high and your app will
# require download over wifi.
#
# The following script can be added to your Xcode target as a shell script.