Skip to content

Instantly share code, notes, and snippets.

@jsocol
jsocol / bugzilla.mozilla.org.js
Created January 11, 2012 00:39 — forked from potch/README.rst
BugColorZilla!
function textColor(bg) {
var r = parseInt(bg.substr(0,2),16),
g = parseInt(bg.substr(2,2),16),
b = parseInt(bg.substr(4,2),16);
var yiq = (r * 299 + g * 587 + b * 114) / 1000;
return yiq >= 128 ? "black" : "white";
}
function bgColor(el, i) {
return ("000000" + $.trim($("a", el).eq(i).text())).substr(-6);
@jsocol
jsocol / gist:2422571
Created April 19, 2012 17:48
Mozillians Git-Fu
# Mozillians Git-Fu.
# Useful steps for moving around git branches and servers related to
# the Mozillians release process. Any dev should be able to do these
# in a pinch, there are no special privileges.
# Always assuming 'origin' refers to github.com/mozilla/mozillians.git
# Current branch is in () in my pseudo-prompt.
# HowTo: Cut a new 'next' branch.
# After tagging, we wipe out the current next branch and fork from
@jsocol
jsocol / gist:2574884
Created May 2, 2012 07:53
Mongolian + Deferred = Tolerable Mongo in Node
/**
* Imagine, if you will, a simple task. You have a blog written in Node, with
* its content stored in Mongo, and you want to display a single post (for
* simplicity, let's pretend the URL contains the ObjectID) and its comments.
*
* Normally, you'd have to fall into callback/scope hell, and do something
* along the lines of this, already in an onRequest handler:
*/
function displayPost(request, response) {
// We'll look up the post and its comments.
@jsocol
jsocol / EventArray.js
Created May 3, 2012 19:49
EventArray.js - Arrays you can watch.
/**
* EventArray.js - Arrays you can watch.
* Copyright 2012, James Socol <me@jamessocol.com>
*
* Released under the MIT X11 and BSD 2-clause Licenses.
*
* EventArray.js is a simple wrapper around JS arrays that makes it
* easier to use them for data-driven UIs by providing a way to watch
* them for mutations. Think of the lovechild of an Array and an
* EventEmitter.

Hi!

I'm not currently looking for a job as I'm pretty happy at my current job.

However Mozilla is looking for a recruiting manager in Mountain View. Mozilla also has deep ties in the open source communities and it sounds like it might be an interesting fit for you. <OPTIONAL-ADDITIONAL-TEXT>

If you're interested in applying, check out our careers link:

@jsocol
jsocol / test.html
Created May 9, 2012 19:15
HTML5 parsing quirk
<!DOCTYPE html>
<title>test</title>
<p><em>some </em unfinished business.</p>
<!-- EXPECTED DOM: -->
<!-- EITHER -->
<p><em>some &lt;/em unfinished business.</em></p>
<!-- OR -->
<p><em>some </em >unfinished business.</p>
@jsocol
jsocol / gist:2696070
Created May 14, 2012 19:43
Bash prompt function
_prompt() {
local _prompt=$1
local _out=$2
local _default=$3
local _val=''
if [ $_default ]; then
_prompt="${_prompt} [${_default}]"
fi
read -p "$_prompt " _val
if [ $_val ]; then
@jsocol
jsocol / bad.js
Created May 16, 2012 02:46
Prongo
var mongodb = require('mongodb');
var express = require('express');
var app = express.createServer();
var db = new mongodb.Db('mysite',
new mongodb.Server('localhost', 27027, {}),
{native_parser: true});
app.get('/', function(req, res) {
// Open the connection.
@jsocol
jsocol / gist:2925392
Created June 13, 2012 17:30
BannedSession
class BannedSession(Exception):
"""For various reasons, mostly in get_response, I don't think you
want to inherit from PermissionDenied."""
pass
class BannedMiddleware(object):
def process_exception(self, request, exception):
if isinstance(exception, BannedException):
return render(request, 'banned.html', {'reason': exception.args[0]})
@jsocol
jsocol / config.php
Created July 25, 2012 18:37
PHP DB Config
<?php
if (!defined('APP')) die();
define('DB_HOST', 'localhost');
define('DB_PORT', '3306');
define('DB_USER', 'myuser');
define('DB_PASS', 'mypass');