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
// too basic atm to be worth setting up a proper repo for, but I think it has potential, assuming it isn't totally wrong | |
// ... I know I could have used actual xml, but this was more amusing | |
var hasOwn = Object.prototype.hasOwnProperty, | |
toString = Object.prototype.toString; | |
// helpers from Fortinbras library | |
function ucfirst (str) { |
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 | |
error_reporting(E_ALL); | |
require realpath(dirname(__FILE__)) . '/Classes/PHPExcel.php'; | |
$objPHPExcel = new PHPExcel(); | |
// DEMO ONLY (potentially unsafe) | |
$data = json_decode($_POST['json']); | |
$key = $_POST['key']; |
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
// from node-paperboy | |
{ | |
"aiff": "audio/x-aiff", | |
"arj": "application/x-arj-compressed", | |
"asf": "video/x-ms-asf", | |
"asx": "video/x-ms-asx", | |
"au": "audio/ulaw", | |
"avi": "video/x-msvideo", | |
"bcpio": "application/x-bcpio", | |
"ccad": "application/clariscad", |
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
// a bit messy and not optimized, but handy for basic formatting of short blocks of text | |
function splitToLines (string, leftMarginWidth, maxLineWidth) { | |
var lines = [], | |
line = [], | |
padding = Array(leftMarginWidth).join(' '), | |
i = 0, // cursor | |
p = 0, // left anchor | |
m = 0, // counter for searching 5 char wrap zone | |
s, // tmpvar |
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
// http://stackoverflow.com/q/5827612/ | |
function walk(dir, done) { | |
var results = []; | |
fs.readdir(dir, function (err, list) { | |
if (err) { | |
return done(err); | |
} | |
var i = 0; | |
(function next() { | |
var file = list[i++]; |
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
// extracted from an earlier gist that had a more comprehensive DOM-like implementation | |
// in this case, I didn't care about namespaces and I didn't require any operation but | |
// append. This is too basic to be useful for most things, but good enough for what I've | |
// used it for. Note that the use of ES5 accessors makes this incompatible with IE < 9. | |
function Tag (name) { | |
this.name = name; | |
this.attrs = Object.create(null); | |
this.children = []; | |
return this; |
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
// as a nodejs module | |
module.exports = makeDictionary(); | |
function makeDictionary (dict) { | |
return function Dictionary () { | |
!dict && (dict = Object.create(null)); | |
var Dictionary = { | |
__proto__: null, | |
get: function (name) { |
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
<!doctype html> | |
<html lang="en"> | |
<head> | |
<!-- warning: template assumes modern browser features --> | |
<title>UNTITLED</title> | |
<meta charset="utf-8"> | |
<meta name="author" content="AUTHOR NAME"> | |
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
// AMD, Node flavored CommonJS, and old fashion global | |
(function (global, factory) { | |
if (typeof define === 'function' && define.amd) { | |
// AMD. Register as an anonymous module. | |
define([], factory); | |
} else if (typeof exports === 'object') { | |
// Node. Does not work with strict CommonJS, but | |
// only CommonJS-like environments that support module.exports, | |
// like Node. | |
module.exports = factory(); |
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
// this is just the starting point. you can run it in the console. | |
// there are numerous problems to solve, like working out whether | |
// the text it finds is visible or not -- i.e. if a node has display: none, | |
// or is absolutely positioned offscreen or behind another element, or | |
// has visiblity: hidden, or has height: 0 and overflow: hidden, and so on. | |
function find (str, caseSensitive) { | |
var head = (document.head || document.getElementsByTagName('head')[0]), | |
body = (document.body || document.getElementsByTagName('body')[0]), | |
re = RegExp(str, 'g' + (caseSensitive ? '' : 'i')), |