Skip to content

Instantly share code, notes, and snippets.

View blizzrdof77's full-sized avatar

Ben Wagner blizzrdof77

View GitHub Profile
@blizzrdof77
blizzrdof77 / 0_reuse_code.js
Last active August 29, 2015 14:15
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
/**
* Force GFORM Scripts inline next to Form Output
*
* force the script tags inline next to the form. This allows
* us to regex them out each time the form is rendered.
*
* see strip_inline_gform_scripts() function below
* which implements the required regex
*/
function force_gform_inline_scripts() {
@blizzrdof77
blizzrdof77 / namei-simple
Created November 29, 2017 06:58
Short/simple output of namei
#!/bin/bash
[[ $# -eq 1 ]] || exit 1
FILEPATH="$1"
while true ; do
ls -ld "$FILEPATH"
[[ "$FILEPATH" != "/" ]] || exit
FILEPATH="$( dirname "$FILEPATH" )"
@blizzrdof77
blizzrdof77 / which-all
Created November 29, 2017 07:37
Shell (bash/zsh) script to return all paths of an executable command (symlinks, function definition, etc)
## -----------------------------------------
# Return any and all paths and/or symlinks of a command
#
# @1 = command name
##
function which-all () {
if [[ -z "$1" ]]; then
echo "Script name or file path?"
read SCRPTNAME
@blizzrdof77
blizzrdof77 / turdpress-htaccess-remote-uploads-fallback
Last active November 29, 2017 08:11
Load TurdPress uploads from stage/production when files don't exist locally (complex version w/ multiple environments/fallbacks)
# LOAD UPLOADS FROM STAGE/PRODUCTION
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wp-content/uploads/
RewriteCond %{REQUEST_FILENAME} !-f
# Rewrite local to stage
RewriteCond %{HTTP_HOST} ^example\.dev$
RewriteRule ^wp-content/uploads/(.*)$ http://example.stage.com/wp-content/uploads/$1 [L]
RewriteCond %{HTTP_HOST} ^example\.dev$
RewriteRule ^wp-content/uploads/(.*)$ http://example.stage.com/wp-content/uploads/$1 [L]
@blizzrdof77
blizzrdof77 / convert-a-font
Created December 31, 2017 17:14
Convert font to specified font types using ruby gem 'convert_font'
# -----------------------------------------
# Convert font to specified font types using ruby gem 'convert_font'
#
# @1 = Font to convert (e.g. 'fonts/ComicSansMS.ttf')
# @2 = Font types to convert to (e.g 'svg,woff')
# -----------------------------------------
function convert-a-font() {
if [[ $(command -v convert_font) = "" ]]; then
echo "Ruby gem 'convert_font' must be installed."
if [[ $(command -v gem) = "" ]]; then
@blizzrdof77
blizzrdof77 / String.prototype.dashToCamelCase.js
Last active January 4, 2018 19:15 — forked from youssman/dash-to-camelCase.js
Javascript convert dash (hyphen) to camelcase
/**
* Convert string with dashes to camel case
*
* @return String
*/
String.prototype.dashToCamelCase = function() {
return this.replace(/-([a-z])/g, function(g) {
return g[1].toUpperCase();
});
};
@blizzrdof77
blizzrdof77 / String.camelCaseToDashed.js
Last active January 4, 2018 19:21 — forked from youssman/regex-camelCase-to-dash.js
Javascript convert camelcase to dash (hyphen)
/**
* Convert camelCase string to lowercase string with dashes (pretty permalink style ;-)
*
* @return String
*/
String.prototype.camelCaseToDashed = function() {
return this.replace( /([a-z])([A-Z])/g, '$1-$2' ).toLowerCase();
};
@blizzrdof77
blizzrdof77 / trim.sh
Last active January 5, 2018 01:39
Trim a string or variable shell script.
# -----------------------------------------
# Trim string
#
# @1 = string
# -----------------------------------------
function trim () {
local s2 s="$*"
# note the tab character in the expressions of the following two lines when copying
until s2="${s#[ ]}"; [ "$s2" = "$s" ]; do s="$s2"; done
until s2="${s%[ ]}"; [ "$s2" = "$s" ]; do s="$s2"; done
@blizzrdof77
blizzrdof77 / count-new-lines
Created January 5, 2018 01:40
Bash Function: Count the number of lines in a string as variable
# -----------------------------------------
# count the number of lines in a string as variable
#
# @1 = string
# -----------------------------------------
function count-new-lines() {
if [ -z "$1" ]; then
echo "Must provide string as variable.."
return
else