Skip to content

Instantly share code, notes, and snippets.

View forkbombe's full-sized avatar
🎯
Focusing

Joe Buckle forkbombe

🎯
Focusing
View GitHub Profile
@forkbombe
forkbombe / GPRS.waveshare.serial.py
Last active April 1, 2021 16:14
Get NMEA and parse to LatLong using Waveshare GNSS, GPRS hat - https://www.waveshare.com/wiki/GSM/GPRS/GNSS_HAT
##!/usr/bin/python
import serial
import time
import pynmea2
import json
# Change to location of device
serialPort = "/dev/ttyS0"
class Commands(object):
@forkbombe
forkbombe / Linode.ObjectStorage.class.php
Last active April 14, 2020 08:29
PHP Class for Putting, Getting and Deleting objects from Linode Object Storage
<?php
/**
* A class for reading and writing to
* Linode Object Storage Buckets
*
* Usage
* -----
* $los = new \Linode\ObjectStorage(
* $apikey,
* $accesskey,
@forkbombe
forkbombe / Delete WooCommerce Customers with 0 orders
Last active August 2, 2019 09:03
Delete WooCommerce Customers with 0 orders using WP-CLI
# Download file to WordPress root directory
wget https://gist.githubusercontent.com/bambattajb/7868fa24423d9dc25da91651dfd8f100/raw/3b98a06fc84bd2f569ee9829842de29fa15073c5/delete-0-order-customers-wc.sh
# Make executable
chmod +x delete-0-order-customers-wc.sh
# Run
./delete-0-order-customers-wc.sh --admin=1
# Params
@forkbombe
forkbombe / countWords.php
Last active October 3, 2018 09:51
I was asked in a job interview to count all words in a string ignoring capitals and special characters
<?php
$str = "About nine o'clock the moon was sufficiently bright for me to proceed on my way and I had no difficulty in following the trail at a fast walk, and in some places at a brisk trot until, about midnight, I reached the water hole where Powell had expected to camp. I came upon the spot unexpectedly, finding it entirely deserted, with no signs of having been recently occupied as a camp.
I was interested to note that the tracks of the pursuing horsemen, for such I was now convinced they must be, continued after Powell with only a brief stop at the hole for water; and always at the same rate of speed as his.
I was positive now that the trailers were Apaches and that they wished to capture Powell alive for the fiendish pleasure of the torture, so I urged my horse onward at a most dan1gerous pace, hoping against hope that I would catch up with the red rascals before they attacked him.
Further speculation was suddenly cut short by the faint report of two shots far ahead of me. I knew that Powell would need
@forkbombe
forkbombe / dealCards.php
Created October 3, 2018 09:49
I was asked in a job interview to deal 5 random playing cards to n number of players
<?php
class Deck {
protected $suits = array('Hearts', 'Spades', 'Clubs', 'Diamonds');
protected $ranks = array('Ace', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King');
public function cards() {
$cards = [];
foreach($this->suits as $suit) {
foreach($this->ranks as $rank) {
$cards[] = $rank . " of " . $suit;
@forkbombe
forkbombe / listener.php
Last active October 3, 2018 12:34
Create WordPress action hooks for Stripe Hooks
<?php
class Stripe_Hook {
public function __construct() {
$this->listener();
}
public function listener() {
if (isset($_GET['wps-listener']) && $_GET['wps-listener'] == 'stripe') {
@forkbombe
forkbombe / statuscake_ips.php
Created February 22, 2017 11:57
Generate a list of Status Cake Ip addresses To add allowed IPs to Nginx or Firewall or whatevs
<?php
/**
* Generate a list of Status Cake Ip addresses
* To add allowed IPs to Nginx or Firewall
*/
$statuscake_locations_json = "https://www.statuscake.com/API/Locations/json";
$locations = json_decode(file_get_contents($statuscake_locations_json));
$output = "#STATUS CAKE IPs" . "\n";
@forkbombe
forkbombe / @import.regex
Created November 17, 2016 15:26
Regex - find all lines starting with @import and ending with ;
/([@import]*)(@import+)(.*;)(\r?\n|$)/g
@forkbombe
forkbombe / modal-object.js
Created August 24, 2016 13:54
Re-usable modal using jquery-ui plus extension for WordPress AJAX
/**
* Example init
*
* new Modal('login-form', {
* title = 'Please Log In',
* content = preloader.spawn();
* });
*
* @param name
* @param options
@forkbombe
forkbombe / install.sh
Created July 26, 2016 12:45
A basic bash install executable script
#!/bin/bash
cd /tmp
## Get the executable
wget https://path/to/bin
## Make home for command
mkdir ~/bin
## Copy executable to command directory
cp /tmp/[bin] ~/bin/[command]