Skip to content

Instantly share code, notes, and snippets.

View avoidwork's full-sized avatar

Jason Mulligan avoidwork

View GitHub Profile
@avoidwork
avoidwork / gist:1423758
Created December 2, 2011 16:03
(Proof of concept) Facade for HTML5 dataset attributes with fallback to data- attributes
/**
* Data attributes facade
*
* @type {Object}
*/
var data = {
/**
* Getter
*
* @param {Object} obj Element to query
@avoidwork
avoidwork / filesize.js
Created March 24, 2012 01:05
filesize.js
filesize(500); // "3.91Kb"
filesize(500, true); // "3.9k"
filesize(1500); // "1.46KB"
filesize("1500000000"); // "1.40GB"
filesize("1500000000", 0); // "1GB"
filesize(1212312421412412); // "1.08PB"
filesize(1212312421412412, true); // "1.1P" - shorthand output, similar to *nix "ls -lh"
@avoidwork
avoidwork / gist:3745240
Created September 18, 2012 19:24
Stored procedure which generates a comma delimited string of UUIDs of related records
BEGIN
DECLARE `uuid` CHAR(50);
DECLARE parent CHAR(255);
DECLARE singular CHAR(255);
DECLARE source CHAR(255);
SET `uuid` = (SELECT udf_uuid(guid));
SET parent = (SELECT udf_type(guid));
SET singular = (SELECT udf_singular(type));
SET source = (SELECT CONCAT(type, udf_capitalize(parent), 's'));
@avoidwork
avoidwork / gist:3749846
Created September 19, 2012 14:01
MySQL delimited insert
# The second SET statement is optional, and could be ignored if you have a well formed delimited string
SET @var = 'test, w00t, w00tz';
SET @var := REPLACE(@var, ' ', '');
SET @var := CONCAT("('", REPLACE(@var, ",", "'),('"), "')");
SET @sql := CONCAT('INSERT INTO table VALUES ', @var);
# Verify the query, exeute via prepared statement
SELECT @sql AS `query`;
@avoidwork
avoidwork / gist:3749973
Created September 19, 2012 14:29
MySQL sp_split() splits a comma delimited string into a recordset & inserts it into target table or returns it
-- ----------------------------
-- Procedure structure for `sp_split`
-- ----------------------------
DROP PROCEDURE IF EXISTS `sp_split`;
delimiter ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_split`(IN toSplit text, IN target char(255))
BEGIN
# Temp table variables
SET @tableName = 'tmpSplit';
SET @fieldName = 'variable';
@avoidwork
avoidwork / gist:4698968
Last active September 12, 2021 20:14
filesize.js examples
filesize(500); // "500 B"
filesize(500, {bits: true}); // "4 kbit"
filesize(265318, {base: 2}); // "259.1 KiB"
filesize(265318); // "265.32 kB"
filesize(265318, {round: 0}); // "265 kB"
filesize(265318, {output: "array"}); // [265.32, "kB"]
filesize(265318, {output: "object"}); // {value: 265.32, symbol: "kB", exponent: 1, unit: "kB"}
filesize(1, {symbols: {B: "Б"}}); // "1 Б"
filesize(1024); // "1.02 kB"
filesize(1024, {exponent: 0}); // "1024 B"
@avoidwork
avoidwork / gist:6215773
Created August 12, 2013 22:08
groc test
<!DOCTYPE html><html lang="en"><head><title>test</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content=""><meta name="groc-document-path" content="test"><meta name="groc-project-path" content="src/test.js"><link rel="stylesheet" type="text/css" media="all" href="assets/style.css"><script type="text/javascript" src="assets/behavior.js"></script><body><div id="meta"><div class="file-path">src/test.js</div></div><div id="document"><div class="segment"><div class="comments doc-section"><div class="wrapper"><p><span class='doc-section-header'>Method renderChildViews </span></p>
<p>Renders collection child views.</p>
<p>Parameters:</p>
<ul>
<li><p><strong>collection must be an Array.</strong><br/>(- collection of child models who have views created.)</p></li>
<li><p><strong>$el must be an Object.</strong><br/>(- Element to append child view
@avoidwork
avoidwork / gist:6436452
Last active December 22, 2015 07:09
CAP sample shape
{
"identifier": "",
"sender": "",
"sent": "",
"status": "",
"msgType": "",
"scope": "",
"restriction": "",
"addresses": "",
"incidents": "",
### Keybase proof
I hereby claim:
* I am avoidwork on github.
* I am jasonmulligan (https://keybase.io/jasonmulligan) on keybase.
* I have a public key whose fingerprint is A46E 0C2C 229C 5068 236E 4D1E FD34 0167 2668 CACA
To claim this, I am signing this object:
Wordlist ver 0.732 - EXPECT INCOMPATIBLE CHANGES;
acrobat africa alaska albert albino album
alcohol alex alpha amadeus amanda amazon
america analog animal antenna antonio apollo
april aroma artist aspirin athlete atlas
banana bandit banjo bikini bingo bonus
camera canada carbon casino catalog cinema
citizen cobra comet compact complex context
credit critic crystal culture david delta
dialog diploma doctor domino dragon drama