Skip to content

Instantly share code, notes, and snippets.

View ozten's full-sized avatar

Austin King ozten

View GitHub Profile
app.use(i18n.abide({
limited_paths: ['/wsapi/stage_user', '/wsapi/stage_email'],
supported_languages: config.get('supported_languages'),
default_lang: config.get('default_lang'),
locale_directory: config.get('locale_directory')
}));
@ozten
ozten / mustache2ejs.diff
Created January 10, 2012 22:25
Mustache to EJS
diff --git a/lib/browserid/prove_template.ejs b/lib/browserid/prove_template.ejs
index d2a4ccc..489e30f 100644
--- a/lib/browserid/prove_template.ejs
+++ b/lib/browserid/prove_template.ejs
@@ -1,9 +1,10 @@
-Thanks for verifying your email address. This message is being sent to you to complete your sign-in to {{site}}.
+<%= gettext(
+ strargs('Thanks for verifying your email address. This message is being sent to you to complete your sign-in to %
-Finish registration by clicking this link: {{link}}
@ozten
ozten / thing.py
Created December 5, 2011 23:50 — forked from tofumatt/thing.py
from django.contrib.auth import REDIRECT_FIELD_NAME
from django.contrib.auth.decorators import (login_required as
auth_login_required)
def login_required(function=None,
redirect_field_name=REDIRECT_FIELD_NAME,
login_url='/'):
"""BrowserID sepcific login_required decorator.
@ozten
ozten / verifier.c
Created November 7, 2011 16:42
Detecting buffer overflows - first stab
/** Callback function for streaming CURL response */
static size_t write_cb(void *contents, size_t size, size_t nmemb, void *userp)
{
size_t realsize = size * nmemb;
size_t nextsize;
struct json_response *mem = (struct json_response *)userp;
if (mem->size + realsize >= mem->realsize) {
nextsize = mem->size + realsize + JSON_BUFFER;
if (nextsize < mem->realsize) {

Beneath are basic questions which will be asked by a developer wanting to use BrowserID. They are arranged in order of importance. For each question there are two answers which represent the two competing API proposals (nicknamed the garfield and odie proposals).

At a high level, how do I implement BrowserID support on my webpage?

BOTH garfield and odie APIs are the same:

You need to add a button to your site that, once clicked, will make a javascript call to prompt the user for and identity. You need to call a function at the time your site loads to check to see if a user is already (persistently logged in). Finally, these client side functions provide you with an assertions that you must implement a little bit of server logic to verify.

What do I do in my handler to invoke BrowserID when the user clicks sign in?

@ozten
ozten / person_search.py
Created July 27, 2011 16:10
Searching internal phonebook for country and manager
import ldap
from ldap.filter import filter_format
def search():
ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_NEVER)
conn = ldap.initialize("ldaps://addressbook.mozilla.com:636")
try:
try:
o = conn.bind_s("[email protected],o=com,dc=mozilla", PASSWORD)
@ozten
ozten / brutal_ldap_schema_reset.sh
Created June 14, 2011 03:47
LDAP Schema migration... brutual style
RECIPE_HOME=/home/ozten/Projects/ldap-recipie/version1
TMP_HOME=/tmp/ldif_output
echo "Resetting OpenLDAP"
apt-get remove -y --purge slapd ldap-utils
# Nuking directory databases
rm -Rf /var/lib/ldap/
apt-get install --no-download slapd ldap-utils
# _lazy is just like _() except safe for multi-threaded code
# top level variables aren't thread safe and you can end up with
# en-US for part of the execution and fr for the next piece :/
from tower import ugettext as _
from tower import ugettext_lazy as _lazy
questions = {'slug1': _lazy(u'Which kind of Super hero are You?',
'slug2': _lazy(u'Charlie Sheen would say you are:',
...
@ozten
ozten / change_lrc_offset.py
Created October 29, 2010 07:10
change_lrc_offset.py 5 heal_the_world.lrc will update the karaoke lyrics adding a 5 second delay
#!/usr/bin/python
import re
import sys
def offset(line, add_seconds):
m = re.match("^\[(\d\d):(\d\d)(?:\.\d\d)?\](.*)$", line)
if m:
(r_min, r_sec, lyrics) = m.groups()
minutes = int(r_min)
seconds = int(r_sec)
#!/usr/bin/php
<?php
if (count($argv) == 2 && file_exists($argv[0])) {
//God help us... Adv Opt will mangle names (buggy) but is the only reason to use over jsminify
$fields = array('compilation_level' => 'ADVANCED_OPTIMIZATIONS',
'js_code' => file_get_contents($argv[1]),
'output_info' => 'compiled_code',
'output_format' => 'text');
$curl = curl_init('http://closure-compiler.appspot.com/compile');