Skip to content

Instantly share code, notes, and snippets.

View ozten's full-sized avatar

Austin King ozten

View GitHub Profile
CmdUtils.CreateCommand({
feedIcon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAJDSURBVHjajJJNSBRhGMd/887MzrQxRSLbFuYhoUhEKsMo8paHUKFLdBDrUIdunvq4RdClOq8Hb0FBSAVCUhFR1CGD/MrIJYqs1kLUXd382N356plZFOrUO/MMz/vO83+e93n+f+1zF+kQBoOQNLBJg0CTj7z/rvWjGbEOIwKp9O7WkhtQc/wMWrlIkP8Kc1lMS8eyFHpkpo5SgWCCVO7Z5JARhuz1Qg29fh87u6/9VWL1/SPc4Qy6n8c0FehiXin6dcCQaylDMhqGz8ydS2hKkmxNkWxowWnuBLHK6G2C8X6UJkBlxUmNqLYyNbzF74QLDrgFgh9LLE0NsPKxjW1Hz2EdPIubsOFdH2HgbwAlC4S19dT13o+3pS+vcSfvUcq9YnbwA6muW9hNpym/FWBxfh0CZkKGkPBZeJFhcWQAu6EN52QGZ/8prEKW+cdXq0039UiLXhUYzdjebOJQQI30UXp6mZn+Dtam32Afu0iyrgUvN0r+ZQbr8HncSpUVJfwRhBWC0hyGV8CxXBL5SWYf9sYBidYLIG2V87/ifVjTWAX6AlxeK2C0X8e58hOr/Qa2XJ3iLMWxB1h72tHs7bgryzHAN2o2gJorTrLxRHVazd0o4TXiyV2Yjs90uzauGvvppmqcLjwmbZ3V7BO2HOrBnbgrQRqWUgTZ5+Snx4WeKfzCCrmb3axODKNH+vvUyWjqyK4DiKQ0eXSpFsgVvLJQWpH+xSpr4otg/HI0TR/t97cxTUS+QxIMRTLi/9ZYJPI/AgwAoc3W7ZrqR2IAAAAASUVORK5CYII%3D",
name: "discover-feeds-gist",
ico
@ozten
ozten / ubiquity-copy-page-title-gist.js
Created January 27, 2009 20:55
Ever find yourself doing View Source > Find <title> > Copy ? Not any more
CmdUtils.CreateCommand({
name: "copy-page-title-gist",
description: "Replaces View Source &lt; Find &gt;title&lt; &lt; Copy",
icon: "http://www.ozten.com/random/clipboard-16x16.png",
preview: function(pblock, input){
pblock.innerHTML = "Copies '<code>" + this.pageTitle() + "'</code> into your copy/paste Clipboard.";
},
execute: function(){
// http://developer.mozilla.org/en/Using_the_Clipboard
var copytext = this.pageTitle();
#!/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');
@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)
# _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 / 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
@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)

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 / 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) {
@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.