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
/** | |
* Create a compare function for Javascript's Array.sort() | |
* Inspired by Triptych's http://stackoverflow.com/a/979325/37020 | |
* | |
* my_array.sort( sorter({key: 'size', reverse: true}) ); | |
* my_array.sort( sorter({key: function(x) { return parseInt(x.tag); }) ); | |
*/ | |
var sorter = function(spec) { | |
if (spec.key === undefined) | |
spec.key = function(x) { return x; }; // identity |
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
# one-liner for generating a 14-char password | |
# On Windows this is a secure password, based on CryptGenRandom | |
# On *nix this is based on /dev/urandom which is intended to be a cryptographically-secure PRNG but | |
# usually isn't. It should still be good enough for passwords. | |
python -c "import random, string; r = random.SystemRandom(); print ''.join(r.choice(string.letters + string.digits) for i in xrange(14))" |
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
// jQuery plugins to focus a fragment | |
// | |
// Uses a StackOverflow-like "flashing" effect. | |
// Degrades gracefully: assumes anchors have a fragment, so | |
// the scrolling will work without JS. | |
// | |
// Written by Ori Peleg | |
// Copyright (c) 2010 CloudShare, http://www.cloudshare.com/ | |
// Distributed under the MIT license |
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
// jQuery.validate.requiredIfVisible.js | |
// Copyright (c) 2010 Ori Peleg, http://orip.org, distributed under the MIT license | |
(function($) { | |
$.validator.addMethod( | |
"requiredIfVisible", | |
function(value, element, params) { | |
function isVisible(e) { | |
// the element and all of its parents must be :visible | |
// inspiration: http://remysharp.com/2008/10/17/jquery-really-visible/ | |
return e.is(":visible") && e.parents(":not(:visible)").length == 0; |
NewerOlder