Skip to content

Instantly share code, notes, and snippets.

View blizzrdof77's full-sized avatar

Ben Wagner blizzrdof77

View GitHub Profile
@blizzrdof77
blizzrdof77 / keybase.md
Created January 7, 2020 02:58
Keybase Proof

Keybase proof

I hereby claim:

  • I am blizzrdof77 on github.
  • I am blizzrdof77 (https://keybase.io/blizzrdof77) on keybase.
  • I have a public key ASDvmPKv9H4qgAUEEFgHXoMfeJsXDgSaxfRp31cYzkc_0go

To claim this, I am signing this object:

@blizzrdof77
blizzrdof77 / JavaScript 'loadStyle' Dynamically
Created October 23, 2019 23:49
Load CSS stylesheet or insert raw CSS dynamically with JavaScript.
SDG = SDG || {};
SDG.loadStyle = function(cssSource, append) {
var append = typeof append === 'undefined' ? true : append,
external = !(cssSource.indexOf('{') > 0 && cssSource.indexOf('}') > 1),
newElem = external ? ((function() {
i = document.createElement('link');
i.rel = 'stylesheet';
i.href = cssSource;
i.type = 'text/css';
@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"
@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 / 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 / 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 / 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 / TP-Link Smart Plug Web Client Vendor Scripts
Last active August 22, 2018 06:25
TP-Link Smart Plug Web Client
@blizzrdof77
blizzrdof77 / ping.sh
Last active January 17, 2019 21:05
Better `ping` support to allow for mixed domains/hostnames w/ protocals (e.g. `ping 'https://who.is/my/ping/?example=this'`)
# ------------------------------------------
# Better `ping` support to allow for mixed
# domains/hostnames with protocols (e.g. 'http://..')
#
# @1 = host
# -> Example usage:
# ping http://google.com/
# ------------------------------------------
function ping {
local pingdomain="$1"
@blizzrdof77
blizzrdof77 / split-string.sh
Created May 11, 2018 22:10
Split a string simple bash function
#!/bin/bash
# Split a string returning the specified index (or 2nd instance by default)
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Provide split delimiter and string"
else
delim="$1"
string="$2"
if [ -z "$3" ]; then