Skip to content

Instantly share code, notes, and snippets.

View blizzrdof77's full-sized avatar

Ben Wagner blizzrdof77

View GitHub Profile
@blizzrdof77
blizzrdof77 / paths-ls.sh
Created January 5, 2018 01:41
Bash Function: List out all directories included in $PATH
# -----------------------------------------
# list out all directories included in $PATH
#
# @1 = separator (New line by default)
# -> Example usage:
# paths-ls ' '
# -----------------------------------------
function paths-ls() {
if [ -z "$1" ]; then
local SEP="\n"
@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 / 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
@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 / 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 / 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 / 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"