This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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 | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular-animate.min.js"></script> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular-cookies.min.js"></script> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular-aria.min.js"></script> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular-messages.min.js"></script> | |
<script src="https://ajax.googleapis.com/ajax/libs/angular_material/1.1.4/angular-material.min.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ------------------------------------------ | |
# 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
hist=$(history | tail -1 | awk '{ print $1 }'); history -d $hist; history -d $(expr $hist - 1); unset hist |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ----------------------------------------- | |
# 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ----------------------------------------- | |
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ----------------------------------------- | |
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Helper String Methods/Extensions to the JS String Object | |
* | |
* @param String search | |
* @return Bool | |
*/ | |
/* Easier way to check if a string contains a substring */ | |
String.prototype.contains = String.prototype.contains || function(search) { | |
return (this.indexOf(search) !== -1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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(); | |
}; |