Skip to content

Instantly share code, notes, and snippets.

Joe Buckle bambattajb

View GitHub Profile
bambattajb / countWords.php
Last active Oct 3, 2018
I was asked in a job interview to count all words in a string ignoring capitals and special characters
View countWords.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
bambattajb / dealCards.php
Created Oct 3, 2018
I was asked in a job interview to deal 5 random playing cards to n number of players
View dealCards.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;
bambattajb / listener.php
Last active Oct 3, 2018
Create WordPress action hooks for Stripe Hooks
View listener.php
class Stripe_Hook {
public function __construct() {
public function listener() {
if (isset($_GET['wps-listener']) && $_GET['wps-listener'] == 'stripe') {
bambattajb / statuscake_ips.php
Created Feb 22, 2017
Generate a list of Status Cake Ip addresses To add allowed IPs to Nginx or Firewall or whatevs
View statuscake_ips.php
* Generate a list of Status Cake Ip addresses
* To add allowed IPs to Nginx or Firewall
$statuscake_locations_json = "";
$locations = json_decode(file_get_contents($statuscake_locations_json));
$output = "#STATUS CAKE IPs" . "\n";
bambattajb / @import.regex
Created Nov 17, 2016
Regex - find all lines starting with @import and ending with ;
View @import.regex
bambattajb / modal-object.js
Created Aug 24, 2016
Re-usable modal using jquery-ui plus extension for WordPress AJAX
View modal-object.js
* Example init
* new Modal('login-form', {
* title = 'Please Log In',
* content = preloader.spawn();
* });
* @param name
* @param options
bambattajb /
Created Jul 26, 2016
A basic bash install executable script
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]
bambattajb /
Created Jul 21, 2016
Python Consol Args Example using psutil
#!/usr/bin/env python
import sys
import getopt
import psutil
def main(argv):
# Define variables
cpuout = False
bambattajb / post-type.php
Created Jun 16, 2016
An example of how to create a WordPress Custom Post type using an Object Oriented approach
View post-type.php
* Use namespace to avoid conflict
namespace PostType;
* Class Event
* @package PostType
bambattajb /
Created Sep 1, 2015
Automated backup of MySQL database via cron
DATE=`date +"%Y%m%d"`
cd ~/db-daily
mysqldump -u $USER -p$PASS -h $HOST $DB | gzip > $DB.sql.gz
You can’t perform that action at this time.