Skip to content

Instantly share code, notes, and snippets.

@joerussbowman
joerussbowman / gist:636908
Created October 20, 2010 17:39
trying to figure out global events with yui3
YUI().use('cookie', 'io-base','json-parse', 'event-custom', function(Y) {
var cookieDate = new Date();
cookieDate.setMinutes(cookieDate.getMinutes() + 30);
function locationComplete(id, o) {
var data = Y.JSON.parse(o.responseText);
if (data.error == 0) {
Y.Cookie.set("fwixid", data.result.id, { expires: cookieDate });
Y.Cookie.set("fwixpretty", data.result.pretty, { expires: cookieDate });
} else {
class MongoCache(object):
def __init__(self, db, collection="cache", size=100000):
self.db = db
self.collection = collection
collections = self.db.collection_names()
if not self.collection in collections:
self.db.create_collection(self.collection, capped=True, size=size)
def set(self, k, v, ttl):
<script type="text/javascript">
YUI().use('anim', 'node', function(Y){
Y.one("#footer-newsticker").removeClass("hidden");
var tickernode = Y.one('#footer-newsticker')
/* This gets the max value of scrollLeft quickly, making for smooth
* animation with no delay before the fade and rest.
*/
tickernode.set('opacity', 0);
tickernode.set('scrollLeft', tickernode.get('offsetWidth'));
var maxScroll = tickernode.get('scrollLeft');
/*
* mongodb based sessions with rotating tokens
*/
require("./Math.uuid");
var sys = require("sys");
var cookies = require("./cookies");
var mongo = require('./mongodb');
Session = function(req, res, callback){
/*
* mongodb based sessions with rotating tokens
*/
require("./Math.uuid");
var sys = require("sys");
var cookies = require("./cookies");
var mongo = require('./mongodb');
Session = function(req, res, callback){
@joerussbowman
joerussbowman / node.js header as array hack
Created March 31, 2010 13:58
Patches to node.js for working with headers as an array
/*
* BEGIN Custom patches
*/
// This is the content type I will return on most of my requests,
// so I'm adding it as the default. I can overwrite the headers
// to change it if necessary on the individual handlers.
http.ServerResponse.prototype.headers = ["Content-Type: text/html"];
http.ServerResponse.prototype.writeHeadArray = function(statusCode){
{
"accounts": [
"123456@facebook",
"654321@twitter"
],
"123456@facebook": {
"sessionid": "12334fddt3t3t"
},
"654321@twitter": {
"oauthkey": "2433gfwg325t",
[
{
"uri": "/mydb/mycollection/",
"method": "POST",
"headers": {
"Content-Type": "application/x-www-form-urlencoded",
"Content-Length": "123"
},
"body": "v=SOME JSON ENCODED STRING WITH VALUE _id = 1"
},