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 / twitterWidget.class.php
Created August 9, 2014 10:36
A WordPress Twitter Widget Class
<?php
class twitterWidget extends WP_Widget {
public function config() {
return 'twitterWidget'; // Obj
}
function __construct() {
parent::__construct(
'twitter_widget', // Base ID
@forkbombe
forkbombe / sorting-example.js
Last active August 29, 2015 14:16
Example of sorting numbers in a weight-based order
var items = function(num) {
var arr = [1,3,3,5,2,7,4,10,6,4];
/*
* Sort array low-high first
*/
arr.sort(function(a,b) {
return a - b;
});
@forkbombe
forkbombe / backupdb.sh
Created September 1, 2015 07:54
Automated backup of MySQL database via cron
#!/bin/sh
USER=$1
PASS=$2
DB=$3
HOST=''
DATE=`date +"%Y%m%d"`
cd ~/db-daily
mysqldump -u $USER -p$PASS -h $HOST $DB | gzip > $DB.sql.gz
@forkbombe
forkbombe / post-type.php
Created June 16, 2016 10:04
An example of how to create a WordPress Custom Post type using an Object Oriented approach
<?php
/**
* Use namespace to avoid conflict
*/
namespace PostType;
/**
* Class Event
* @package PostType
*
@forkbombe
forkbombe / monit.py
Created July 21, 2016 15:43
Python Consol Args Example using psutil
#!/usr/bin/env python
import sys
import getopt
import psutil
def main(argv):
# Define variables
cpuout = False
@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]
@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 / @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 / 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 / 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') {