This file contains hidden or 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
#! /usr/bin/python3 | |
def tupleise(*values): | |
""" | |
Return a tuple based on the arguments - if there are none then return an | |
empty tuple or if there are more than one create and return a new tuple from | |
the arguments. If there is one arg, if it is iterable but not a string then | |
create a tuple from its items, otherwise return tuple with a single-element | |
equal to that argument. |
This file contains hidden or 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> | |
<head> | |
<title>String format() function demo</title> | |
</head> | |
<body> | |
<h1>String format() function demo</h1> | |
<div> | |
<p>Module format not loaded</p> |
This file contains hidden or 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
/*jshint asi:true */ | |
;(function(global) { | |
'use strict' | |
const parser = /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, | |
queryKeyParser = /(?:^|&)([^&=]*)=?([^&]*)/g, | |
keys = "href protocol authority userInfo user password host port relative path directory file query anchor".split(" "); | |
/** |
This file contains hidden or 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($) { | |
$.fn.batch = function(method, args) { | |
var func = $.fn[method], results = []; | |
this.each(function() { | |
results.push(func.apply(this, args)); | |
}); | |
return results; | |
}; | |
var funcs = "attr css=styles prop html text val offset width height".split(" "); |
This file contains hidden or 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 Q = require("q"); | |
var FS = require("fs"); | |
function process_file(fn) { | |
var deferred = Q.defer(); | |
FS.readFile(fn, "utf-8", function(error, content) { | |
if (error) { | |
deferred.reject(new Error(error)); | |
} |
This file contains hidden or 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
/* | |
* Prompts for the URL of a script, then creates a bookmarklet to load and run the script. | |
* | |
* javascript:(function(u) {u=prompt('Script URL');u&&prompt('Bookmarklet', 'javascript:(function(d,s){s=d.createElement("script");s.src="'+u.replace(/^https?:/,'')+'?cb="+Math.random();d.body.appendChild(s)})(document)') })() | |
*/ | |
(function(u) { | |
u = prompt('Script URL'); | |
u && prompt('Bookmarklet', | |
'javascript:(function(d,s){s=d.createElement("script");s.src="' + | |
u.replace(/^https?:/,'') + |
This file contains hidden or 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
/** | |
* classof(obj) | |
* | |
* Returns the object's internal [[Class]] property, see | |
* the other file for example output. | |
* | |
* @param {Object?} object | |
* @return {String} | |
*/ | |
const classof = v => Object.prototype.toString.call(v).replace(/^\[object\s(.*)\]$/, '$1').toLowerCase(); |
This file contains hidden or 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
/** | |
* Allows you to specify named groups in regular expressions like in Perl/Python/.NET/etc. You have to | |
* use a string to specify the regex, and the function returns an object that has `exec` and `replace` | |
* functions like a normal RegExp object, but matches they generate have keys for the values of the named | |
* groups. | |
* | |
* n = NamedRegExp("(?<protocol>http|ftp)://(?<host>[\\w-]+\\.com)(?<path>/.+\\.html)?$"); | |
* res = n.exec("http://foobar.com"); -> res.protocol = http, res.host = foobar.com res.path = undefined | |
* res = n.exec("http://foobar.com/"); -> res.protocol = http, res.host = foobar.com res.path = / |
This file contains hidden or 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
@script:jscript | |
/** | |
* Return an array of the results of running func on each item in coll e.g. | |
* map(DOpus.vars, function(v, i) { | |
* return v + '=' + v.value; | |
* } | |
*/ | |
function map(coll, func) { | |
var res = []; |
OlderNewer