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
import java.util.NoSuchElementException; | |
/** | |
* My own little implementation of optional. Lacks other Java 8 features such as filter on Predicate, | |
* eating the value up with a consumer, etc. | |
* <p> | |
* One possible benefit: If you try to get() the value, but haven't checked whether it isPresent(), | |
* this will throw an exception. You must always check if the value is present before getting it. | |
* <p> | |
* Otherwise, this API intends to follow the java.util.Optional<T> Java 8 API. It should be relatively |
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
window['defineModule'] = function defMod(name, moduleDefiner) { | |
window[name] = window[name] || (Object.create ? Object.create(null) : {}); | |
var args = Array.prototype.slice.call(arguments, 2); | |
var API = moduleDefiner.apply(window[name], args); | |
for(var b in API) | |
window[name][b] = API[b]; | |
modules[name] = window[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> | |
<head> | |
<script src="test.har"></script> | |
<script type="text/javascript"> | |
// Insert "var test = " at the very beginning of the HAR-file | |
var entries = test.log.entries; |
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($, callback) { | |
if($) { | |
callback(); | |
return; | |
} | |
var script = document.createElement('script'); | |
script.src = '//code.jquery.com/jquery-1.11.1.min.js'; | |
script.onload = callback; | |
document.getElementsByTagName('body')[0].appendChild(script); | |
})(window['jQuery'], function() { |
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
/** | |
* Detects whether the PDF.js Chromium extension is installed in the browser. | |
* Example: isPDFJSExtensionInstalled(function(result) { alert('Is PDF.js installed? ' + result);}); | |
* | |
* @param {function(boolean)} callback - Called when the detection completed. | |
* | |
* Author: Rob Wu <rob@robwu.nl> (https://robwu.nl) | |
* | |
* Made synchronous by a handwaiving Lebbe | |
* |
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
window.setInterval(function() { | |
var levelColors = [], m = Math; | |
function getLevelColor(level) { | |
if(levelColors[level] === undefined) { | |
levelColors[level] = (m.PI * m.random()).toString(16).slice(-2); | |
} | |
return levelColors[level]; | |
} |
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 promiseNode(name, attributes) { | |
/** | |
* | |
*/ | |
return function (content, beforeInsideOrAfter) { | |
var start = '<' + name; | |
var end = '</' + 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
/* Write out for months. */ | |
var dates = []; | |
$('.js-stream-item ._timestamp').each(function() { | |
dates.push(new Date($(this).data('time-ms'))); | |
}); | |
var data = {}; |
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 the most basic setup you need in express 4 for listening on POST and GET. | |
*/ | |
var express = require('express'); | |
var bodyParser = require('body-parser'); | |
var app = express(); |
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
<!-- | |
Something I threw together to test storage abilities in different browsers. | |
This test two forms of session storages: html 5 session storages, and the window.name fallback option. | |
It also tests two forms of persistent storage: html 5 local storage and cookies. | |
Intended usage: | |
Upload the html file to your web-server. |
OlderNewer