Skip to content

Instantly share code, notes, and snippets.

[
{
"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"
},
{
"accounts": [
"123456@facebook",
"654321@twitter"
],
"123456@facebook": {
"sessionid": "12334fddt3t3t"
},
"654321@twitter": {
"oauthkey": "2433gfwg325t",
@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){
/*
* 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){
<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');
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):
@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 {
@joerussbowman
joerussbowman / gist:739514
Created December 13, 2010 20:02
YQL console output
--- local.search results
<?xml version="1.0" encoding="UTF-8"?>
<query xmlns:yahoo="http://www.yahooapis.com/v1/base.rng"
yahoo:count="0" yahoo:created="2010-12-13T20:02:06Z" yahoo:lang="en-US">
<diagnostics>
<publiclyCallable>true</publiclyCallable>
<url execution-time="40" http-status-code="503" http-status-message="Service Unavailable"><![CDATA[http://local.yahooapis.com/LocalSearchService/V3/localSearch?zip=94085&query=pizza&start=1&results=10]]></url>
<user-time>62</user-time>
<service-time>40</service-time>
@joerussbowman
joerussbowman / gist:781383
Created January 15, 2011 23:54
Example yui3 autocomplete using yql
<input type="text" name="q" id="q" />
<script type="text/javascript">
YUI().use("autocomplete", "autocomplete-highlighters", "datasource-get", function (Y) {
var acDS = new Y.DataSource.Get({
source: "http://sugg.search.yahoo.com/gossip-us-fp/?nresults=10&queryfirst=2&output=json&version=&command=",
});
Y.one('#q').plug(Y.Plugin.AutoComplete, {
maxResults: 10,
resultHighlighter: 'phraseMatch',