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 / 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 / histdel.sh
Created May 9, 2018 10:04 — forked from josephabrahams/histdel.sh
Delete previous line in .bash_history
#!/bin/sh
hist=$(history | tail -1 | awk '{ print $1 }'); history -d $hist; history -d $(expr $hist - 1); unset hist
@blizzrdof77
blizzrdof77 / json_storage.js
Created September 17, 2018 16:24 — forked from danott/json_storage.js
Override localStorage and sessionStorage's getter and setter function to allow for objects/arrays to be stored as well.
/* json_storage.js
* @danott
* 26 APR 2011
*
* Building on a thread from Stack Overflow, override localStorage and sessionStorage's
* getter and setter functions to allow for storing objects and arrays.
*
* Original thread:
* http://stackoverflow.com/questions/2010892/storing-objects-in-html5-localstorage
*/
@blizzrdof77
blizzrdof77 / http-redirect-target.php
Created November 29, 2018 19:52
Get HTTP redirect destination for a URL in PHP
<?php
// FOLLOW A SINGLE REDIRECT:
// This makes a single request and reads the "Location" header to determine the
// destination. It doesn't check if that location is valid or not.
function get_redirect_target($url)
{
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
@blizzrdof77
blizzrdof77 / slugify.js
Last active December 6, 2018 00:13 — forked from mathewbyrne/slugify.js
Javascript Slugify
/**
* Slugify
*
* @param string text
* @return string
*/
function cleanSlug(text) {
return (
text.toString().toLowerCase()
.replace(/\s+/g, '-') /* Replace spaces with - */
@blizzrdof77
blizzrdof77 / mysql.legacy-methods.php
Last active December 17, 2018 23:18 — forked from rubo77/fix_mysql.inc.php.md
Legacy PHP & MySQL Compatibility Functions - Replaces all MySQL functions with the corresponding MySQLi functions
<?php
/**
* Legacy PHP & MySQL Compatibility Functions
*/
/**
* replacement for all mysql functions
*
* Be aware, that this is just a workaround to fix-up some old code and the resulting project
* will be more vulnerable than if you use the recommended newer mysqli-functions instead.
@blizzrdof77
blizzrdof77 / manage-etc-hosts.sh
Created January 21, 2019 19:59 — forked from irazasyed/manage-etc-hosts.sh
Bash Script to Manage /etc/hosts file for adding/removing hostnames.
#!/usr/bin/env bash
# Path to your hosts file
hostsFile="/etc/hosts"
# Default IP address for host
ip="127.0.0.1"
# Hostname to add/remove.
hostname="$2"