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
var fileStorage = { | |
/** | |
* Saves a file on the device | |
* @param {string} name - filename (can include sub folders) | |
* @param {string} data - file contents | |
* @param {boolean} useSandbox - uses protected sandbox if true, otherwise external (default false) | |
* @returns {Promise} executes .then with saved file path as first param | |
*/ | |
write: function (name, data, useSandbox) { |
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
/** | |
* Converts a string to JSON safe key (property name) by removing unsafe | |
* characters and converting to camel case | |
* @param {string} src - string to convert | |
* @Example | |
* stringToJsonSafeKey('r@ndAm wo5d') // rndamWo5d | |
* @returns {string} id/key safe string | |
*/ | |
function stringToJsonSafeKey(src) { |
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
/** | |
* Removes invalid XML characters from a string | |
* @param {string} str - a string containing potentially invalid XML characters (non-UTF8 characters, STX, EOX etc) | |
* @param {boolean} removeDiscouragedChars - should it remove discouraged but valid XML characters | |
* @return {string} a sanitized string stripped of invalid XML characters | |
*/ | |
function removeXMLInvalidChars(str, removeDiscouragedChars) { | |
// remove everything forbidden by XML 1.0 specifications, plus the unicode replacement character U+FFFD | |
var regex = /((?:[\0-\x08\x0B\f\x0E-\x1F\uFFFD\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]))/g; |
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
// 1) visit yclist.com | |
// 2) open the browser console | |
// 3) run the following | |
// get all table rows | |
var rows = Array.prototype.slice.call(document.querySelectorAll('#companies tbody tr')); | |
// extract descriptions (use lastChild to skip aquired etc) | |
var descriptions = rows.map(function (row) { return row.cells[5].lastChild.textContent.trim(); }); |
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 (window) { | |
'use strict'; | |
var oldSetTimeout = window.setTimeout; | |
/** | |
* Behaves the same as setTimeout but uses requestAnimationFrame() for better performance | |
* @param {function} fn The callback function | |
* @param {int} delay The delay in milliseconds |
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
/** | |
* Removes empty values, trims whitespace and removes duplicate from a comma separated string in JavaScript | |
* @example | |
* cleanCsvString('one, ,, , two,two,two, three'); // returns 'one,two,three' | |
* cleanCsvString('one, ,, , two,two,two, three', false); // returns 'one,two,two,two,three' | |
* @param {string} str - string to modify | |
* @param {boolean} removeDuplicates - should remove duplicate items? (default = true) | |
* @returns {string} cleaned CSV string | |
*/ | |
function cleanCsvString(str, removeDuplicates) { |
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
/** | |
* Get all CSS style blocks matching a CSS selector from stylesheets | |
* @param {string} className - class name to match | |
* @param {boolean} startingWith - if true matches all items starting with selector, default = false (exact match only) | |
* @example getStylesBySelector('pure-form .pure-form-html ') | |
* @returns {object} key/value object containing matching styles otherwise null | |
*/ | |
function getStylesBySelector(className, startingWith) { |
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
/** | |
* GET contents of a URL | |
* @access private | |
* @param {string} url - url to get | |
* @param {function} error - function to call if there is an error | |
* @param {function} callback - function to call if success | |
* @returns {void} | |
*/ | |
function httpGet(url, error, callback) { |
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
# Disable DPMS. | |
xset s off # don't activate screensaver | |
xset -dpms # disable DPMS (Energy Star) features. | |
xset s noblank # don't blank the video device | |
# Create a RAM disk to use as a FIFO for streaming. | |
if [ ! -d /iwk ]; then | |
mkdir /tmp/rdisk | |
fi | |
mount -t tmpfs -o size=25M tmsfs /tmp/rdisk |