Skip to content

Instantly share code, notes, and snippets.

var crappy_xml = "<tag>some forget to encode & others &lt;do not&gt;</tag>";
// negative lookahead
crappy_xml.replace(/&(?!(\S+;))/g, '&amp;')
// From: http://tomasz.janczuk.org/2013/05/multi-line-strings-in-javascript-and.html
function multiline(fn) {
return fn.toString().match(/[^]*\/\*([^]*)\*\/\}$/)[1].trim();
}
// NOTE: exported objects are Strings, not functions
exports.getTour = multiline(function() {/*
SELECT
*
FROM
@sspencer
sspencer / wordwheel.js
Created February 18, 2009 02:15
JavaScript wordwheel, similar to iTunes search.
function wordwheel(e, searchField, tableId)
{
var i, r, corpus, displayStyle,
kc = YE.getCharCode(e),
table = YD.get(tableId),
terms = YD.get(searchField).value.toLowerCase().split(" "),
table_len, terms_len;
if (kc === 27) {
terms = "";
@sspencer
sspencer / debug_to_file.php
Created February 18, 2009 02:28
Log to your own error file in PHP.
function dbg($str) {
error_log("$str\n", 3, "/tmp/dbg.txt");
}
# Ruby Range Check with Default Value
# if args['level'] is from (-1..9) return args['level], otherwise return -1
level = (-1..9).include?(args['level']) ? args['level'] : -1
I'm Lloyd Hilaiel from BrowserPlus.
[show the yahoo cow, moo]
This screencast explores the question, *how do we make uploading from the Browser, better?*
[textual question showing on screen]
What does better mean?
I'm Lloyd Hilaiel from BrowserPlus. `[show the yahoo cow, moo]`
This screencast explores the question, *how do we make uploading from the Browser, better?* `[textual question
showing on screen]`
What does better mean?
* Better means *easier* for the user to select the content they wish to upload `[easier floats in lower left
portion of screen]`
* Better also means the selected content should transfer *faster*. `[faster floats in lower
@sspencer
sspencer / gist:399025
Created May 12, 2010 19:22
NodeJS BrowserPlus Service Sketch
// A rough sketch of how a NodeJS service might look
// Take 2 - keep services flat.
service = require('browserplus').service;
log = require('browserplus').log;
service.name = "HelloWorld";
service.version = "1.0.1";
service.doc = "A hello world service for BrowserPlus";
// MarzulloAlgorithm in JavaScript
//
// Not quite what I need which is a list of ranges that contain a specified number.
//
'use strict';
function Point(name, point, type) {
this.name = name;
this.point = point;
this.type = type;