Skip to content

Instantly share code, notes, and snippets.

View joewils's full-sized avatar

Joe Wilson joewils

View GitHub Profile
#!/usr/bin/perl
# Old CGI script from 1996
# https://web.archive.org/web/20000829140422id_/http://www.joecode.com/news/news_cgi.txt
# Usage
# /news.cgi?url=http://fullcoverage.yahoo.com/fc/Business/Internet_Taxes_and_Regulation/&subject=internet_tax&title=Internet%20Tax%20News:
if ($ENV{'REQUEST_METHOD'} eq 'GET') {
@pairs = split(/&/, $ENV{'QUERY_STRING'});
@joewils
joewils / NSMutableAttributedString.rb
Created April 13, 2023 14:22
Ruby method to process NSMutableAttributedString blob values from iMessage chat.db.
# Parse attributedBody blob values into ASCII text.
# Grab HEX(attributedBody) from chat.db and unfark it
def unfark_imessage_attributed_body(hex_string)
wtf_string = [hex_string].pack("H*").encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: ' ')
wtf_string.gsub!(/\s+/, ' ')
if wtf_string.include? 'NSNumber'
wtf_string = wtf_string.split('NSNumber')[0]
if wtf_string.include? 'NSString'
wtf_string = wtf_string.split('NSString')[1]
@joewils
joewils / backup.sh
Last active December 29, 2020 17:55
Backup WordPress to S3 using WP-CLI and Amazon CLI
#!/bin/bash
source /home/username/.bashrc
# Shell
SHELL=/bin/bash
# Email
MAILTO=foo@bar.com
# WordPress Command Line Interface
@joewils
joewils / hubspot_form
Last active August 1, 2016 21:52
WordPress ShortCode for Embedding HubSpot Forms
<?php
// Usage: [hubspot_form form_id="1234-5678-90123-45676"]
// Inspiration: https://rschu.me/an-easy-way-to-embed-hubspot-forms-in-wordpress/
// API Documentation: http://developers.hubspot.com/docs/methods/forms/advanced_form_options
add_shortcode('hubspot_form', function($atts) {
extract(shortcode_atts(array(
'form_id' => null,
'redirect_url' => null
@joewils
joewils / currency.rb
Last active March 7, 2022 20:05
USD currency formatting filter for Liquid templates
# Custom text filters
module TextFilter
# USD Currency
def currency(input)
return sprintf('$%0.2f',input).gsub(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1,")
end
end
# Globally register custom text filters
Liquid::Template.register_filter(TextFilter)
@joewils
joewils / btwb-to-jekyll.rb
Created January 29, 2015 23:05
Beyond The White Board to Jekyll
# ruby btwb-to-jekyll.rb
# (execute from Jekyll blog root)
puts 'BTWB To Jekyll'
require 'yaml'
require 'httparty'
require 'nokogiri'
# Beyond The White Board Credentials
@joewils
joewils / login.js
Created December 2, 2013 19:06
Login to BarraOne BDTI service using Node.js with the soap and soap-cookie packages.
var soap = require('soap'),
Cookie = require('soap-cookie'),
util = require('util'),
wsdl = 'bdti.wsdl';
soap.createClient(wsdl, function(err, client) {
client.Login({User: "USERNAME", Client: "CLIENTID", Password: "PASSWORD"}, function(err, result) {
// Cookie based security
client.setSecurity(new Cookie(client.lastResponseHeaders));
// GetCalcServers (This action requires login.)
@joewils
joewils / get_models.rb
Created October 10, 2013 19:04
Login to BarraOne SOAP service using Ruby and Savon
#https://www.barraone.com
#http://savonrb.com
require 'savon'
def barra_xml_to_hash (dirty_xml)
# Clean up the response, not sure why the payload from BarraOne is so dirty
xml = dirty_xml.gsub(/--.*<\?/m,'<?')
xml = xml.gsub(/--.*--/,'')