This file contains 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
<?php | |
/** | |
* Convert a SimpleXMLElement to an associative array. | |
* | |
* Note: ignores attributes. | |
* | |
* @param SimpleXMLElement $sxe A SimpleXMLElement. | |
* @param array $repeating_elements A array of names of elements that repeat. Optional. | |
* @return mixed Returns null when the element is empty/doesn't exist. |
This file contains 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
/** | |
* Useful string functions | |
*/ | |
/** | |
* Replace any whitespace character or sequence of whitespace characters into a single space | |
* | |
* @param string $str | |
* @return string $str with any sequence of whitespace collapsed into a single space | |
*/ |
This file contains 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
/** | |
* Creates a string that can be used for dynamic id attributes | |
* Example: "id-so7567s1pcpojemi" | |
* @returns {string} | |
*/ | |
var uniqueId = function() { | |
return 'id-' + Math.random().toString(36).substr(2, 16); | |
}; |
This file contains 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
/** | |
* Test whether/not $array is associative | |
* | |
* Got annoyed when I saw a coworker using the accepted answer at http://stackoverflow.com/questions/173400/how-to-check-if-php-array-is-associative-or-sequential?page=1&tab=active#tab-top | |
* It seems overly complicated, and fails if the linear array's keys aren't contiguous (as do several other solutions I found). | |
* | |
* Sample test arrays: | |
* ---------------------------------------- | |
* | |
* $empty_array = array ( ); |
This file contains 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
/** | |
* Given an array, return its contents as a <table> | |
* | |
* @param mixed $r | |
* @return string If $r is an array, returns HTML of a <table> representing its contents. | |
* If $r is a string, returns that string with HTML entities converted. | |
* If $r is not a string or array, returns var_export($r, true) with HTML entities converted. | |
*/ | |
function output_array_as_table($r) { | |
// function for doing some entitifying of strings |
This file contains 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
// ==UserScript== | |
// @name Github-hosted user script test | |
// @namespace http://garvinggarvin.com/monkies | |
// @include http://* | |
// @include https://* | |
// @version 1 | |
// ==/UserScript== | |
console.log('i am working yes'); |
This file contains 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
/** | |
* Generate a timestamp (in # of milliseconds) | |
* | |
* @return string | |
*/ | |
function millitime() { | |
$microtime = microtime(); | |
$comps = explode(' ', $microtime); | |
// Note: Using a string here to prevent loss of precision |
This file contains 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
;(function(Modernizr, window) { | |
Modernizr.addTest('positionfixed', function () { | |
var test = document.createElement('div'), | |
control = test.cloneNode(false), | |
fake = false, | |
root = document.body || (function () { | |
fake = true; | |
return document.documentElement.appendChild(document.createElement('body')); | |
}()); |
This file contains 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
// ==UserScript== | |
// @name Black bg chat text for baby | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Black bg chat text | |
// @author Gravin | |
// @match https://www.tumblr.com/* | |
// @icon https://www.google.com/s2/favicons?domain=tumblr.com | |
// @grant none | |
// ==/UserScript== |
This file contains 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
// ==UserScript== | |
// @name Focused-thing outliner | |
// @namespace http://garvinggarvin.com/monkies | |
// @description Outline/highlight the focused thingy. | |
// @match *://*.mbsbooks.com/* | |
// @match *://*.cgarvin.com/* | |
// @match *://bookstore.mbsdirect.net/* | |
// @match *://bncvirtual.com/* | |
// @exclude *://*.mbsbooks.com/misi-test/dashboard/modules/webauth/* | |
// @exclude *://*.mbsbooks.com/misi/dashboard/modules/webauth/* |