The Solution to Unique Passwords

This is not the bookmarklet. This is where you will find the bookmarklet. WordPress doesn’t allow the hosting of bookmarklets. Click here.

  1. Drag this bookmarklet to your bookmarks (put it somewhere you can click it easily, and consider renaming it to something shorter)
  2. Whenever you need a password, click the bookmarklet
  3. You must always enter the same Passphrase and you should keep it secret
  4. You’ll always get the same generated password for the same Passphrase and Domain
  5. If you need a password for a service that spans hostnames (e.g. mail.google.com, docs.google.com) you’ll need to enter the same thing in the Domain popup for each (e.g. google) so you get the same password
  6. If you click on the password field before the bookmarklet, the password will be automatically typed in for you

Sha256 Implementation by Chris Veness under the LGPL 2.1. I guess that makes this LGPL too.

  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  */
  /*  SHA-256 implementation in JavaScript | (c) Chris Veness 2002-2010 | www.movable-type.co.uk    */
  /*   - see http://csrc.nist.gov/groups/ST/toolkit/secure_hashing.html                             */
  /*         http://csrc.nist.gov/groups/ST/toolkit/examples.html                                   */
  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  */
  

array_flatten() in PHP

$arrays ? call_user_func_array(‘array_merge’, $arrays) : array()

How to sort a PHP array-of-arrays

array_multisort(
array_pluck($records, 'field_to_sort_on'), SORT_ASC,
//array_pluck($records, 'another_field_to_sort_on'), SORT_ASC,
//array_pluck($records, 'another_field_to_sort_on'), SORT_DESC,
$records
);

/*

NOTE: this requires array_pluck():

function array_pluck($recordList, $targetField) {
$result = array();
foreach ($recordList as $recordKey => $record) {
if (!array_key_exists($targetField, $record)) { continue; }
$result[ $recordKey ] = $record[$targetField];
}
return $result;
}

*/

Can I use an exciting new web feature?

http://caniuse.com/indexeddb
http://caniuse.com/#search=nth

Social Skills

Sense Motive can be rolled before the DM tells a lie. Depending on the result, he may roleplay the lie straight-faced or stumble awkwardly through it, contradicting himself.

Diplomacy is used to impart a character’s understanding of what the other party has to be gained and lost. It can be used to make it very clear why someone is better off going with your plan.

Tabs could be so much better.

Elastic Tabstops

How to eval a multiple line “function” in Python

Python has two basic methods of evaluating Python code: eval and exec. eval will only accept a single statement, while exec doesn’t allow return statements — that is, unless you wrap your code in a function definition…

Crux in red:

import re
import sys

def eval_as_function(code, local_vars = None, global_vars = None):
    if local_vars is None:
        local_vars = {}
    if global_vars is None:
        global_vars = globals()
    retval = None
    try:
        context = {}
        code = re.sub(r"(?m)^", "    ", code)
        code = "def anon(" + ','.join(local_vars.keys()) + "):\n" + code
        exec code in global_vars, context
        retval = context['anon'](*(local_vars.values()))
    except:
        print "an error occurred in eval_a_function:"
        print str(sys.exc_info()) + "\n\n"
        print "in this code:\n\n" + code + "\n\n"
    return retval

code = """
if foo == 'bar':
    return True
"""[1:-1] # strip blank lines

print eval_as_function(code, { 'foo': 'bar' })

The usual caution about evaluating untrusted strings applies, but also note that the keys of local_vars are evaluated as the anonymous function argument names.

Improvements welcome! :)