Skip to content

Instantly share code, notes, and snippets.

View yssk22's full-sized avatar

yssk22 yssk22

View GitHub Profile
/**
* node.js/express twitter oauth integration sample
*/
var express = require('express'),
connect = require('connect');
var MemoryStore = require('connect/middleware/session/memory');
var OAuth= require('oauth').OAuth;
var app = express.createServer();
var http = require('http'),
url = require('url');
PROXY_VIA = 'CouchProxy';
function debug(str){
console.log(str);
}
exports.proxy = function(backendUrl){
var backend = url.parse(backendUrl);
#!/usr/bin/env python
import os
import sys
import json
import logging
import getopt
import couchdbkit
import json
import locale
import time
var sys = require('sys'),
url = require('url'),
querystring = require('querystring'),
http = require('http');
var logger = require('ext').logger;
function handleStream(request, callback){
request.connection.on('error', function(err){
logger.critical('[Twitter] Streaming failed.');
logger.critical(err);
function(doc){
if( doc.type != "twitter" || doc.source == undefined ){
return;
}
if( doc.source.text ){
function hyperlink(text){
return text.replace(/(https?:\/\/[^\s]+)/g, '<a class="hyperlink" href="$1" target="_new">$1</a>');
}
function mentionlink(text){
/**
* Twitter Client for node.js
*/
var sys = require('sys'),
url = require('url'),
querystring = require('querystring'),
http = require('http'),
crypto = require('crypto'),
EventEmitter = require('events').EventEmitter;
var OAuth = require('oauth').OAuth;
var sys = require('sys');
var EventEmitter = require('events').EventEmitter;
var MAX = 1000000;
var c = 0;
function doOnce(){
require('assert').equal(c, MAX);
console.log('OK');
}
function copy(fileUrl, docUrl, event, trace){
if( !trace ){
trace = 0;
}
if( !trace ){
event = new EventEmitter();
}
if( trace == MAX_TRACE ){
logger.error('Max trace exceeded. ({fileUrl} -> {docUrl})'.format({fileUrl: fileUrl, docUrl: docUrl}));
return undefined;
@yssk22
yssk22 / redis.js
Created November 14, 2010 08:19
Redis sample program (retwis) ported to node.js
/**
* retwis-js.js
*
* Description:
*
* redis tutorial program impelmented by node.js
*
* Usage:
*
* node redis.js
@yssk22
yssk22 / couchdb_proxy_middleware
Created December 5, 2010 07:23
CouchDB proxy middleware
/*******************************************
* Connect middleware to proxy request to
* the specified path on CouchDB.
*
* Usage:
*
* app.use(express.bodyDecoder());
* app.use(function(req, res, next){
* res.bindings = res.bindings || {};
* });