Skip to content

Instantly share code, notes, and snippets.

View mrcodetastic's full-sized avatar

mrcodetastic

View GitHub Profile
/*
RadioLib SX127x Ping-Pong Example
For default module settings, see the wiki page
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx127xrfm9x---lora-modem
For full API reference, see the GitHub Pages
https://jgromes.github.io/RadioLib/
Customised for a ESP32 S3 'hat' that uses the following PIN mappings:
Cool apps:
Universal Radio Hacker: https://github.com/jopohl/urh
SDR Sharp
-> Use 'Zadiag' on Windows to attach a WinUSB to the 'Bulk In Interface 0' for the RTL2832 device.
RTL-SDR read of 433Mhz relay switch like:
'kebidu 1Pc RF Transmitter 433 Mhz Remote Controls with Wireless Remote Control Switch DC 12V 1CH relay Receiver Module'
https://www.aliexpress.com/item/32956103016.html?spm=a2g0o.order_list.0.0.21ef1802ISdJsi
@mrcodetastic
mrcodetastic / WFH_Emulator.ino
Last active March 24, 2024 06:48
USB Mouse Jiggler (Work From Home (WFH) emulator)
/*
* Compile and flash this firmware onto a ESP32-S2 and then use a seperate micro USB connector
* to connect the S2's Pin 19 to USB D- and Pin 20 to USB D+ (and of course +5V to +5V and GND to GND)
*
* It will appear as a 'USB Mouse' in Windows/Linux/Mac, and move the mouse every 30 seconds or so
* that you are always online/green. The ESP's LED will flash briefly when this occurs.
*
* Even better, buy and ESP32-S2 Mini with USB-C and put it into DFU mode: https://www.youtube.com/watch?v=YPX2nlr-ySU
*
* If writing firmware to an ESP32-S2 Mini using Arduino IDE. Make sure you have 'USB CDC On Boot' set to 'False'
@mrcodetastic
mrcodetastic / WindowsAuthApacheHTTPConnect.java
Created July 6, 2021 17:29
Connect to a website using Apache HTTPClient5 using Windows Authentication
class Session {
/*
* Use Apache HTTPClient5 WinClient extensions to automatically gain SSO login via. domain credentials of
* currently logged in user.
*/
// Store SSO cookie's between httpclient and server to maintain session
private CookieStore cookieStore = new BasicCookieStore();
// Base http configuration used for all http requests
private RequestConfig requestConfig = RequestConfig.custom()
.setConnectTimeout(300, TimeUnit.SECONDS)
@mrcodetastic
mrcodetastic / webserver.go
Created June 6, 2021 17:22
Simple GoLang HTTP Server
# go run webserver.go
# Run this in whatever directory you're wanting to quickly serve on port 80
package main
import (
"fmt"
"log"
"net/http"
)
@mrcodetastic
mrcodetastic / qt-windows10-static-build.ps1
Last active April 5, 2024 03:31
Static build Qt 5.15.2 (or probably later versions) on Windows 10
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# Tested with QT 5.15.2 on Windows 10
# https://mrfaptastic.github.io
@mrcodetastic
mrcodetastic / rolling_moving_average.c
Created August 13, 2020 16:11
Rolling Moving Average in C
#ifndef MOVING_AVERAGE_H
#define MOVING_AVERAGE_H
#define ROLLING_AVERAGE_WINDOW 6
// Light Sensor (analogue read) - Moving average
int maverage_values[ROLLING_AVERAGE_WINDOW] = {0}; // all are zero as a start
int maverage_current_position = 0;
long maverage_current_sum = 0;
int maverage_sample_length = sizeof(maverage_values) / sizeof(maverage_values[0]);
@mrcodetastic
mrcodetastic / ffmpeg_reencode_5.1_audio_to_stereo.ps1
Last active March 5, 2023 07:10
ffmpeg Windows Powershell - Copy Video and Re-Encode DTS audio to two channel AAC codec
# Change 'F:\ffmpeg' to the path where your FFMPEG executable is
# Usefull on a cheap TV with USB that can't handle many audio codec versions.
# Pre-requisite: Download ffmpeg.exe (static version) and put it somewhere in your windows PATH variable.
Get-ChildItem -Recurse -File -Include *.mkv | Foreach { #*.mp4,*.mov,*.avi,*.mkv | Foreach {
$newname = $_.fullname.subString(0, $_.fullname.Length-4) + "_conv.mkv";
ffmpeg.exe -i $_.fullname -c:v copy -c:a mp3 -ac 2 -b:a 256k -y $newname;
echo "Saving as: $($newname)";
}
@mrcodetastic
mrcodetastic / README.md
Created January 13, 2020 20:57
A simple python script to scrape comments from one or many BBC News articles. This was tested to collect the Brexit related discourse posted on the BBC News website.

bbc-news-comments-scraper

A simple python script to scrape comments from one or many BBC News articles. This was tested to collect the Brexit related discourse posted on the BBC News website.

How to use

  1. Go to a BBC news article with comments you're interested in, and view the source of the webpage. Alternateively, in Chrome, right-click on the 'View Comments' button and select 'Inspect'. For example: http://www.bbc.co.uk/news/uk-politics-eu-referendum-36306681

  2. Look within the HTML and for the string 'forumId=CPS' (without the Single Quotes). After 'CPS' there will be a number, copy this number. For example '__CPS__43250035', then copy '43250035'

  3. Edit the 'articles' list in the python scraper code, add the relevant Article title and number as required. For example:

@mrcodetastic
mrcodetastic / FindAndCompressJPEGs.ps1
Created March 2, 2019 20:11
Windows Powershell to recurse through all directories and re-compress/ JPEGs
# Re-compress / Optimise all JPEGs in place (80% quality = approx. 70% disk saving, with little noticeable difference )
# NOTE: This will over-write the original JPED file! Also change the path to your executable.
# Requires jpegoptim: https://github.com/XhmikosR/jpegoptim-windows/releases
Get-ChildItem -Recurse -File -Include *.jpg,*.JPEG | Foreach {C:\<CHANGE_THIS_PATH>\jpegoptim --max=80 $_.fullname}