Skip to content

Instantly share code, notes, and snippets.

View Grayda's full-sized avatar

David Gray Grayda

View GitHub Profile
@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.
@Grayda
Grayda / error codes
Last active August 29, 2015 14:21
Error codes from recovery.sh
Extracted from https://github.com/ninjasphere/sphere-factory-reset/blob/cba5514d118bd9bf8df8825acd2e380a9deea8e1/ninjapack/root/opt/ninjablocks/factory-reset/bin/recovery.sh using these Regexs:
^((?!progress).)*$
^((?!ERR).)*$
progress "0040" "Writing partition table..."
progress "0043" "Partition table write was successful."
progress "0042" "Partition table update failed - $?."
progress "0044" "Probing '$drive' partition table..."
progress "0047" "Partition table probe of '$drive' completed successfully."
@Grayda
Grayda / main.go
Created May 13, 2015 04:09
main.go for Ninja Sphere driver
package main
import (
"fmt"
"os"
"os/signal"
)
func main() {