Skip to content

Instantly share code, notes, and snippets.

View kiler129's full-sized avatar

Gregory House kiler129

  • noFlash
  • Chicago, IL (USA)
View GitHub Profile
@kiler129
kiler129 / twilio_sms_to_telegram.js
Created February 28, 2024 03:57
CloudFlare worker to redirect SMS to Telegram
// Receives Twilio SMS WebHook and sends message via Telegram
//
//Define the following as variables on CF:
// - ACCESS_USER (encrypt): long unpredictible string, shared with Twilio
// - ACCESS_PASS (encrypt): long unpredictible string, shared with Twilio
// - TELEGRAM_CHAT_ID: chat id for Telegram conversation
// - TELEGRAM_API_TOKEN (encrypt): API token for Telegram intragration
//
// Configure Twilio with SMS WebHook to call https://<ACCESS_USER>:<ACCESS_PASS>@<worker name>.<cf login>.workers.dev/notify
// e.g. https://foo:[email protected]/notify
@kiler129
kiler129 / iommu.sh
Last active December 20, 2023 02:34 — forked from Roliga/iommu.sh
#!/bin/bash
### Improved IOMMU/PCIe list script
# The script was originally authored by Roliga (https://gist.github.com/Roliga/d81418b0a55ca7682227d57af277881b)
# This version changes:
# 1) enable listing of devices even if IOMMU is disabled
# 2) add support for NVMe & SAS block devices
# 3) display disks serial & firmware (if available)
# 4) QOL improvements: disabled paging by default; don't crash on missing lsusb
@kiler129
kiler129 / scrypted-webhook-disable-enable-homekit.ts
Created June 12, 2023 04:36
Scrypted WebHook to disable/enable HomeKit via webhook
class DisableEnableHomeKitWebHook implements HttpRequestHandler {
readonly devType = 'Camera';
readonly roomName = 'Inside';
// readonly roomName = 'Outside';
readonly sharedSecret = 'kfjshflhwfiwheifhawleichiewchewiucahewihc';
async onRequest(request: HttpRequest, response: HttpResponse) {
const query = this.getQueryParams(request);
if (!this.verifySecret(query)) {
response.send("Invalid secret");
@kiler129
kiler129 / generate_smbios.sh
Created April 12, 2023 07:38
Script to generate real SMBIOS for QEMU
#!/bin/bash
# See https://www.qemu.org/docs/master/system/invocation.html?highlight=smbios#hxtool-4
declare -A smb0
declare -A smb1
declare -A smb2
declare -A smb3
declare -A smb4
declare -A smb11
declare -A smb17
#!/bin/bash
set -e -o errexit -o pipefail -o nounset
###################################
# This script can be used by itself, but it's recommended that you read
# a tutorial on Proxmox forum first: https://forum.proxmox.com/threads/hey-proxmox-community-lets-talk-about-resources-isolation.124256/
###################################
# Do not modify these variables (set by Proxmox when calling the script)
vmId="$1"
@kiler129
kiler129 / cf-worker-twilio-to-telegram.js
Last active January 25, 2023 06:29
CloudFlare worker code forwards text messages from Twilio to your Telegram chat
/**
* This CloudFlare worker code forwards text messages from Twilio to your Telegram chat.
*
* You need to define the following variables in CloudFlare:
* ACCESS_USER - any user
* ACCESS_PASS - any password
* TELEGRAM_API_TOKEN - get from @BotFather
* TELEGRAM_CHAT_ID - get from https://api.telegram.org/bot<TELEGRAM_API_TOKEN>/getUpdates after messaging the bot
*
* Then set the following URL in Twilio as a POST WebHook:
<?xml version="1.0"?>
<ruleset name="Lab Companion" namespace="NoFlash\LabCompanion\CS\Standard">
<config name="installed_paths" value="../../slevomat/coding-standard"/>
<ini name="memory_limit" value="512M"/>
<arg name="colors"/>
<arg name="basepath" value="."/>
<arg name="parallel" value="8" />
<autoload>./vendor/autoload.php</autoload>
<file>src</file>
@kiler129
kiler129 / backup-truenas.sh
Created October 6, 2022 02:27
Backups TrueNAS installation configuration
#!/bin/bash
set -e
if [ "$#" -ne 3 ]; then
# Example to keep 7 copies: backup-truenas.sh tnsHome /mnt/backup/server 7
echo "Usage: ${0} StableID DestinationDir KeepCopies"
exit 1
fi
stableId="${1}"
@kiler129
kiler129 / replace-cert.sh
Last active August 10, 2023 09:25
Replace certificate for an isolated service running on TrueNAS SCALE and restart the service if needed
#!/bin/bash
#set -e
set -o errexit -o pipefail -o noclobber -o nounset
if [ "$#" -ne 4 ]; then
echo "Usage: ${0} CertTargetDir CertName OutputFormat<pem|p12> AssociatedService"
exit 1
fi
certTargetDir="${1}"
@kiler129
kiler129 / watchdog.c
Created October 31, 2020 02:13
Simple process watchdog & restarter
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
int main(int argc, char* argv[]) {
char *args[]={argv[0], "UDP4-LISTEN:123,fork", "UDP:example.com:123", NULL};
setuid(0);
pid_t pid;