Skip to content

Instantly share code, notes, and snippets.

View sleemanj's full-sized avatar

James Sleeman sleemanj

View GitHub Profile
@sleemanj
sleemanj / zoho-mail-undelete-restore-trash-bulk.js
Created December 1, 2023 06:21
Undelete (Restore From Trash) bulk Zoho Mail messages (more than 300 messages to restore).
/* Javascript snippet for when you accidentially move thousands of emails to the Zoho Mail Trash and want to restore them
* Zoho only lets you restore up to 300 at a time, you can't select all.
*
* This hacky javascript works around it. Open Zoho Mail and go into the Trash, open the console with CTRL-SHIFT-J
* paste this in, and then it will just sit there hitting the select-all checkbox and then the restore button for gogoCycleCount times
* to restore 50 emails at a time. Set the cycle count to however many emails you are restoring divided by 50.
*
* DO NOT TOUCH THE ZOHO MAIL WINDOW WHILE IT IS WORKING, no checks are made that it is in the Trash folder.
*
*/
#!/usr/bin/python
# Convert a step file (or other) into a wrl file (or other) with FreeCAD
# You must provide an absolute input and output file path (NO RELATIVE!)
# A freecad window will open, the conversion will happen, and it will
# close. The export requires gui functions it seems so this is unavoidable.
# PROTIP:
# sudo startx -display :1 -- :1 vt8
# CTRL-ALT-F8 to switch to the new X session on VT8 and run `xhost +` in the terminal
@sleemanj
sleemanj / mt-recap-fix.js
Last active November 16, 2023 10:47
Fix for Mootools 1.3 with 1.2 compatibility layer to work with Recaptcha due to bind being incorrect with 1.2 compatibility enabled.
/* Quick Dirty Patch for Recaptcha with Mootools 1.2 Compatability Layer
*
* Make sure that all your mootools core/more source is loaded before this
* fix is loaded.
*
* @author James Sleeman <james@gogo.co.nz>
* @see https://github.com/google/recaptcha/issues/374
*
*/
@sleemanj
sleemanj / freecad-linear-pattern-step-wrl.py
Last active April 29, 2023 20:40
Use FreeCAD to take an input STEP file and create a series of files which contain a series of copies of that file. For example creating a series of PCB headers, your initial step file is a single pole of the header (or 2 poles in the case of a double row) and then it will create files for 1x2, 1x3, 1x4 and so forth.
#!/usr/bin/python
# Take an input step file and duplicate it along the X axis
# creating files named by the pattern
#
# Example:
# ./freecad-linear-pattern-step-wrl.py /tmp/hdr-1x1t_2.54.step "/tmp/hdr-1x%dt_2.54.wrl"
# Where "%d" will be replaced by the copy number...
# will generate hdr-1x1t_2.54.wrl
# hdr-1x2t_2.54.wrl
@sleemanj
sleemanj / max6675.ino
Created May 18, 2016 07:43
MAX6675 Thermocouple Reader Example Arduino Code
/** MAX6675 Thermocouple Reader Example Code
*
* This is so simple a library would be silly!
*
* 6675 Module ==> Arduino
* CS ==> D10
* SO ==> D12
* SCK ==> D13
* Vcc ==> Vcc (5v OK)
* Gnd ==> Gnd
@sleemanj
sleemanj / ESP32_HelloWorld.ino
Created September 7, 2022 22:53
A simple Arduino example of connecting an ESP32 to WIFI and requesting (HTTP GET) a page from the internet.
#include <WiFi.h>
#include <HTTPClient.h>
const String ssid = "PUT_YOUR_WIFI_NAME_HERE";
const String password = "PUT_YOUR_WIFI_PASS_HERE";
HTTPClient http;
String url = "http://sparks.gogo.co.nz/esp32/hello.html";
void setup() {
@sleemanj
sleemanj / lcsc-to-superbuy.js
Last active September 5, 2022 05:00
Load LCSC Cart Export Into Superbuy Forwarding Order
/** Kludgy script for fillling out a Superbuy Forwarding Order
* From LCSC Cart export
*
* Add stuff to your LCSC cart, export the cart (don't purchase yet)
* open the export in spreadsheet, add column 1 for type
* in column one record, for example "Capacitors", "Diodes",
* "Inductors"...
*
* Ensure that all parts have Customer # from BOM
* (set it to LCSC if none)
@sleemanj
sleemanj / pronto-keywood-codes-to-nec-device-function-decoder.php
Created January 3, 2022 00:14
Quick kludgy script to take a Pronto Hex format of code from the remotecentral.com database and blindly assuming it is NEC format with a single pulse lead-in and 32 bits, convert to NEC device and Function.
<?php
$Pronto = "0000 006d 0022 0002 0155 00ab 0015 0015 0015 0015 0015 0015 0015 0040 0015 0040 0015 0040 0015 0015 0015 0040 0015 0040 0015 0040 0015 0040 0015 0015 0015 0015 0015 0015 0015 0040 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0040 0015 0015 0015 0040 0015 0040 0015 0040 0015 0040 0015 0040 0015 0040 0015 0015 0015 0040 0015 0015 0015 0015 0015 05ea 0155 0055 0015 0e3d";
$Pronto = preg_split('/ /', $Pronto);
// Remove header
array_shift($Pronto);
array_shift($Pronto);
array_shift($Pronto);
array_shift($Pronto);
#!/usr/bin/php
<?php
/* Yes this is terribly cobbled togethor, no there are no tests, it does what it needs to do,
which is to allow you to dump a bind format zonefile over the WHM API, and to update a
WHM domain from a bind zonefile, over the API, so you only need usual WHM access, resellers are fine. */
if(count($argv) < 2)
{
echo "\nBind To/From WHM API, Especially For Resellers\n";
@sleemanj
sleemanj / aliexpress-order-list-collapse.js
Last active April 28, 2021 02:07
Tampermonkey Script to Collapse your Aliexpress "My Orders" page and highlight orders which are Awaiting Delivery based on days remaining, light blue more than 28 days remain, orange more than 7 days, RED less than 7 days.
// ==UserScript==
// @name Collapse Order History on Aliexpress and highlight time remaining for orders awaiting delivery.
// @namespace https://gist.github.com/sleemanj/352f095f6f67564dae825f79204f1f01
// @updateURL https://gist.github.com/sleemanj/352f095f6f67564dae825f79204f1f01/raw/aliexpress-order-list-collapse.js
// @downloadURL https://gist.github.com/sleemanj/352f095f6f67564dae825f79204f1f01/raw/aliexpress-order-list-collapse.js
// @version 1.2
// @description Collapse the orders in My Orders to make the page more compact, highlight "Awaiting Delivery" ones.
// @author James Sleeman
// @match *://trade.aliexpress.com/orderList.htm*
// @grant GM_addStyle