Skip to content

Instantly share code, notes, and snippets.

View Grayda's full-sized avatar

David Gray Grayda

View GitHub Profile
@Grayda
Grayda / README.md
Last active December 27, 2024 04:56
Infobox for Trilium Next Notes

This is an (in-progress) infobox for Trilium Next Notes.

Installation

Installing the template

  1. Create a new note somewhere (preferably under a Scripts note or something to keep everything organized)
  2. Create a new note called Infobox
  3. Create a new note under Infobox called template and make the Note Type HTML
  4. Create a new note under template and call it js and make the Note Type JS Frontend
  5. Create two new notes under js. Call the first one dayjs_plugin_relativeTime and call the second one dayjs_plugin_advancedFormat. Set both Note Types to JS Frontend
@Grayda
Grayda / WIN11-INSTALL.txt
Last active December 29, 2024 02:04
Autopilot / Intune onboarding BadKB scripts
REM This script automates the Windows 11 installation from a USB stick.
REM You'll probably need to adjust the delays to match your hardware,
REM because each machine takes a different amount of time to load various screens
DEFAULTDELAY 300
REM Move to the locale selector and select English (Australia), then press Next and then Install Now
TAB
STRING English (Australia)
ALT N
@Grayda
Grayda / index.php
Created March 26, 2019 04:14
Verify a Patreon webhook hash with PHP
<?php
// This example can be copied and pasted into Laravel.
// If you're not using Laravel, change the $request related stuff into PHP's native stuff (e.g. file_get_contents("php:///input") etc.)
function verifyPatreonHash(Request $request) {
$patreonBody = $request->getContent(); // This is the raw **body** of the request, which will be JSON (but don't json_decode it!)
$patreonSignature = $request->header('X-Patreon-Signature'); // And this is the header from Patreon
$webhookSecret = "Patreon Webhook Secret Here"; // This'll be the secret Patreon gave you when you created the webhook
$webhookHash = hash_hmac('md5', $patreonBody, $webhookSecret); // This is the hash we've calculated, based on the body and the secret
@Grayda
Grayda / usbrelay.js
Last active July 12, 2018 01:11
Control 5v dcttech.com relay using node.js
var HID = require('node-hid');
var _ = require("lodash")
var device
device = setup()
setInterval(function() {
setState(!getState())
console.log("Relay enabled? " + getState())
}, 1000)
@Grayda
Grayda / start_of_calendar.ics
Created October 10, 2017 04:29
Timezone demo
BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VTIMEZONE
TZID:Australia/Melbourne
TZURL:http://tzurl.org/zoneinfo-outlook/Australia/Melbourne
X-LIC-LOCATION:Australia/Melbourne
BEGIN:STANDARD
TZOFFSETFROM:+1100
TZOFFSETTO:+1000
TZNAME:AEST
@Grayda
Grayda / getKey.sh
Last active June 11, 2019 13:23
Extract the Kepler key
# This downloads kepler.apk from orvibo.com and uses strings and grep with regex to find the line that contains the key.
echo Downloading the Kepler APK from www.orvibo.com..
wget http://www.orvibo.com/software/android/kepler.apk -qO /tmp/kepler.apk
echo Download complete. Extracting and searching for the key. The key should be displayed below.
echo
unzip -p /tmp/kepler.apk classes.dex | strings | grep -e '^[A-Za-n1-9]\{16\}$'
echo
@Grayda
Grayda / weather-icons.css
Created December 3, 2016 01:23
yr.no weathericon mappings
/*!
* Weather Icons 2.0
* Updated August 1, 2015
* Weather themed icons for Bootstrap
* Author - Erik Flowers - erik@helloerik.com
* Email: erik@helloerik.com
* Twitter: http://twitter.com/Erik_UX
* ------------------------------------------------------------------------------
* Maintained at http://erikflowers.github.io/weather-icons
*
@Grayda
Grayda / gulpfile.js
Created September 10, 2016 15:48
Gulpfile for effortlessly switching between paid and free building
var gulp = require('gulp');
var gutil = require('gulp-util');
var bower = require('bower');
var concat = require('gulp-concat');
var sass = require('gulp-sass');
var minifyCss = require('gulp-minify-css');
var rename = require('gulp-rename');
var sh = require('shelljs');
var cp = require("child_process")
@Grayda
Grayda / kepler.md
Last active June 11, 2019 13:20
Information about the Orvibo Kepler

These are some rough notes regarding the Orvibo Kepler

The Kepler uses a different protocol to the previous devices (S20, AllOne etc.), but once you get past the changes in protocol, the commands are very much the same.

The Kepler uses UDP on port 9999. The header of the packet is the same (e.g. 646400 ..., but the body is now encrypted JSON. The encryption is AES ECB and the decryption key is stored in the app. Simply decompile the app and look in com\orvibo\lib\kepler\core\AESCoder.java. Use something like http://aes.online-domain-tools.com/ to quickly decrypt and check data. The start of the encrypted data is denoted by 0x09 and runs right to the end of the packet (?).

As mentioned above, the protocol is rather similar to the other devices. Here's a sample packet from the Kepler app, showing discovery:

6864004a706be1d7b623202020202020202020202020202020202020202020202020202020202020202009411a140e9dc338948829f770b2e65d3f9c5e7eedfcb9e552aff1a74e7c6ca6

@Grayda
Grayda / index.js
Created July 17, 2016 13:35
Move screenshots to folder based on size
// Run `npm install --save image-size mv` to install mv (for easily moving files) and image-size (for determining image dimensions)
var fs = require("fs")
var mv = require("mv")
var sizeOf = require('image-size');
var dest = 'C:\\Users\\David\\Downloads' // The location of your downloads folder in Firefox.
// Watch the folder and report when an event has happened
fs.watch(dest, (event, filename) => {
// Try block because I'm lazy. This did exactly what I needed.