Skip to content

Instantly share code, notes, and snippets.

View friartuck6000's full-sized avatar

Kyle Tucker friartuck6000

  • Gainesville, FL
View GitHub Profile
@friartuck6000
friartuck6000 / gzsize.sh
Last active October 19, 2017 14:37
Calculate the raw and gzipped size of a file + compression percentage
function gzsize {
if [[ $1 =~ :// ]]; then
real=$(curl -L $1 2>/dev/null | wc -c | xargs)
gzipped=$(curl -L $1 2>/dev/null | gzip | wc -c | xargs)
else
real=$(cat $1 | wc -c | xargs)
gzipped=$(cat $1 | gzip | wc -c | xargs)
fi
compression=$(awk -v a=$real -v b=$gzipped 'BEGIN { printf "%.2f", (1 - b / a) * 100 }')
echo "Real: $real"
@friartuck6000
friartuck6000 / camel2snake.php
Last active September 7, 2016 13:22
Convert camel case to snake case
<?php
/**
* Convert camel case to snake case.
*
* DISCLAIMER: Not mine. Got it from {@link http://stackoverflow.com/a/35719689}.
*
* @param string $camelString The source string.
* @return string The converted string.
*/
@friartuck6000
friartuck6000 / camel2snake.php
Created September 7, 2016 13:15
Convert camel case to snake case
<?phpunction camel2snake($camelString)
{
return strtolower(preg_replace(['/([a-z\d])([A-Z])/', '/([^_])([A-Z][a-z])/'], '$1_$2', $camelString));
}
@friartuck6000
friartuck6000 / snake2camel.php
Last active September 7, 2018 14:13
Convert snake case to camel case
<?php
/**
* Convert a snake-cased string to a camel-cased one.
*
* @param string $snakeString The original snake-cased string.
* @param bool $first Whether the first letter should be capitalized
* (useful for classnames vs. properties).
* @return string The converted string.
*/
@friartuck6000
friartuck6000 / svg-icon.js
Created July 14, 2016 20:24
Gulp plugin - takes a bunch of SVG files and builds a Sass partial
'use strict';
var _ = require('lodash');
var consolidate = require('consolidate');
var gutil = require('gulp-util');
var path = require('path');
var through = require('through2');
var File = gutil.File;
var PluginError = gutil.PluginError;
@friartuck6000
friartuck6000 / acf-field-group-schema.json
Created April 12, 2016 18:34
JSON schema for Advanced Custom Fields (ACF) field groups
{
"$schema": "http://json-schema.org/schema#",
"id": "http://advancedcustomfields.com/json-schema/field_group",
"type": "object",
"definitions": {
"empty": {
"type": "string",
"maxLength": 0
},
"intOrEmpty": {
@friartuck6000
friartuck6000 / getwp
Last active August 29, 2015 13:58
Install any version of WordPress with a single command
#!/bin/bash
# USAGE:
# getwp [-v version] dest
# Help screen
function usage()
{
echo
echo "getwp -- Made with <3 by @friartuck6000"
#!/bin/bash
# Red Bull for Hard Drives
# ------------------------------------------------------------------------
# Run this script once to keep your mounted Time Machine or other external
# hard drive(s) from falling asleep and making your system hang every time
# the drive wakes up.
#
# Usage:
# 1. Be sure to chmod +x this file before trying to execute it.
@friartuck6000
friartuck6000 / theme.js
Created October 10, 2013 16:23
jQuery wrappers for WordPress friendliness
(function($) {
// Write plugins
})(jQuery);
jQuery(document).ready(function($) {
// Call plugins and do other stuff
});
@friartuck6000
friartuck6000 / fluidAffix.js
Last active December 19, 2015 15:39
Make sidebars using Bootstrap's affix play nicely with responsive designs
$.fn.fluidAffix = function(opts){
return this.each(function(){
var $this = $(this);
var $parent = $this.parent();
// Match width of parent container
$this.css('width', $parent.width()+'px');