Skip to content

Instantly share code, notes, and snippets.

View alloyking's full-sized avatar
🎧
.

Tim Shultis alloyking

🎧
.
View GitHub Profile
@alloyking
alloyking / pagespeed_optimize_images.sh
Created November 17, 2020 04:30 — forked from julianxhokaxhiu/pagespeed_optimize_images.sh
Recursively optimize all PNG and JPG files wherever they are from the script position and inner ( based on OPTING, PNGCRUSH, ADVANCECOMP and JPEGOPTIM )
#!/bin/bash
# Improved as per feedback from @pascal - https://gist.github.com/julianxhokaxhiu/c0a8e813eabf9d6d9873#gistcomment-3086462
find . -type f -iname "*.png" -exec optipng -nb -nc {} \;
find . -type f -iname "*.png" -exec advpng -z4 {} \;
find . -type f -iname "*.png" -exec pngcrush -rem gAMA -rem alla -rem cHRM -rem iCCP -rem sRGB -rem time -ow {} \;
find . -type f \( -iname "*.jpg" -o -iname "*.jpeg" \) -exec jpegoptim -f --strip-all {} \;
@alloyking
alloyking / FreightRatesAndService.php
Created November 27, 2018 16:02 — forked from antongorodezkiy/FreightRatesAndService.php
UPS Freight API dummy class
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class FreightRatesAndService {
protected $username = '';
protected $password = '';
protected $accessKey = '';
protected $sandbox = '';
protected $endpointUrl = '';
protected static $endpointUrls = array(
@alloyking
alloyking / canvas-upload.php
Created May 5, 2016 03:30 — forked from fazlurr/canvas-upload.php
Function to save base64 image to png with PHP
<?php
// requires php5
define('UPLOAD_DIR', 'images/');
$img = $_POST['img'];
$img = str_replace('data:image/png;base64,', '', $img);
$img = str_replace(' ', '+', $img);
$data = base64_decode($img);
$file = UPLOAD_DIR . uniqid() . '.png';
$success = file_put_contents($file, $data);
print $success ? $file : 'Unable to save the file.';
@alloyking
alloyking / nginx.conf
Created April 7, 2016 16:19 — forked from thoop/nginx.conf
Official prerender.io nginx.conf for nginx
# Change YOUR_TOKEN to your prerender token and uncomment that line if you want to cache urls and view crawl stats
# Change example.com (server_name) to your website url
# Change /path/to/your/root to the correct value
server {
listen 80;
server_name example.com;
root /path/to/your/root;
index index.html;
<?php
/**
* Plugin Name: Multisite: Passwort Reset on Local Blog
* Plugin URI: https://gist.github.com/eteubert/293e07a49f56f300ddbb
* Description: By default, WordPress Multisite uses the main blog for passwort resets. This plugin enables users to stay in their blog during the whole reset process.
* Version: 1.0.0
* Author: Eric Teubert
* Author URI: http://ericteubert.de
* License: MIT
*/
@alloyking
alloyking / install_ffmpeg_ubuntu.sh
Last active February 25, 2016 15:51 — forked from xdamman/install_ffmpeg_ubuntu.sh
Install latest ffmpeg on ubuntu 14.04
#!/bin/bash
# Bash script to install latest version of ffmpeg and its dependencies on Ubuntu 12.04 or 14.04
# Inspired from https://gist.github.com/faleev/3435377 && https://gist.github.com/xdamman/e4f713c8cd1a389a5917
# Remove any existing packages:
sudo apt-get -y remove ffmpeg x264 libav-tools libvpx-dev libx264-dev
# Add multiverse. Not all deps are in the main repo
sudo apt-add-repository multiverse && sudo apt-get update
<?php
/*
Plugin Name: Authenticate Users Remotely
Author: Christopher Davis
Author URI: http://www.christopherguitar.net/
License: GPL2
*/
add_filter('xmlrpc_methods', 'wpse39662_add_login_method' );
/**
<?php
/*
Plugin Name: Remote Login
Description: Log into the site with creds that work on remote site (as defined in plugin). The remote site must have XML-RPC enabled.
Author: Kailey Lampert
Author URI: http://kaileylampert.com/
THIS IS NOT COMPLETE - DO NOT USE IN PRODUCTION
The remote site (defined below in $server) is the "master" site.
/**
* Constructor Invocation Pattern
* Requires use of the "new" keyword, allows for inheritance, but no information hiding
* The Functional Pattern is recommended over the Constructor Invocation Pattern
*/
// create a constructor function for the base class
var Person = function (spec) {
// pseudo-class vars
spec.name = spec.name || '';
// all objects inherit from Object.prototype,
// we can add capabilities like so:
console.log('adding capabilities to Object.prototype');
if (typeof Object.prototype.totalBills != 'function') {
Object.prototype.totalBills = function () {
if (this.bills && this.bills.constructor === Array) {
var total = 0;
for (var i=0; i<this.bills.length; i++) {