Skip to content

Instantly share code, notes, and snippets.

View nborwankar's full-sized avatar

Nitin Borwankar nborwankar

View GitHub Profile
So what exactly is in a Sproingg node?
-------------------------------------
Sproingg is a project to bootstrap a richly featured text communication system over CouchDB using
the following apps and CouchDB features collectively referred to as a Sproingg node
a) A CouchDB database as message inbox with a CouchDB database URL as an address for sending messages (Reqd)
b) A CouchApp that is a forum app (Optional)
c) A CouchApp that is a wiki app (Optional)
d) A CouchApp blog (Optional)
testing ....
THE PROBLEM:
Standard practices say no non-root process gets to talk to the Internet on a port less than 1024. How, then, could I get Node talking on port 80 on EC2? (I wanted it to go as fast as possible and use the smallest possible share of my teeny tiny little micro-instance's resources, so proxying through nginx or Apache seemed suboptimal.)
THE TEMPTINGLY EASY BUT TOTALLY WRONG SOLUTION:
Alter the port the script talks to from 8000 to 80:
}).listen(80);
curl -X PUT http://your:credentials@localhost:5984/profiles
curl -X POST -d '{"source":"http://couchcamp.couchone.com/profiles","target":"http://localhost:5984/profiles","continuous":true}' -H "Content-type: application/json" http://localhost:5984/_replicate
curl -X POST -d '{"target":"http://couchcamp.couchone.com/profiles","source":"http://localhost:5984/profiles","continuous":true}' -H "Content-type: application/json" http://localhost:5984/_replicate
@nborwankar
nborwankar / couchdb-ec2-install.sh
Created August 26, 2011 00:21 — forked from msmith/couchdb-ec2-install.sh
Set up CouchDB on EC2
#!/bin/bash
#
# This script installs and configures couchdb on a fresh Amazon Linux AMI instance.
#
# Must be run with root privileges
# Tested with Amazon Linux AMI release 2011.02.1.1 (ami-8c1fece5)
#
export BUILD_DIR="$PWD"
Here's an R session mimicking the steps in the doc for decision trees. At this point not meant to show anything like the final result just a probe of the R<->Pg semantics.
Note that the driver seems to create a result set in a format that the data frame constructor in R understands.
Not only that but the equivalent of "to_string" for df seems to output it in the familiar tabular format by default.
So the happy result to report here is that the native impedance mismatch is small.
We'll need some validation tests to identify R<-->GP issues if any.
Right now I am using an R<-->Postgres driver (MADlib 0.4 on Pg 9.1 on MacOSX Lion., RStudio 0.9.4, R 2.13.2).
@nborwankar
nborwankar / RSessionToMADlibPG.txt
Created July 13, 2012 00:15
RSessionToMADlibPG
===
> rs <- dbSendQuery(con, statement = paste(
+ "SELECT * FROM", +"MADlib.c45_train('infogain','public.golf_data','trained_tree_infogain',null,'temperature,humidity','outlook,temperature,humidity,windy','id','class',100,'explicit', 5,0.001,0.001,0)"));
> df <- fetch(rs, n = -1)
> df
training_set_size tree_nodes tree_depth training_time split_criterion
14 8 3 00:00:00.311362 infogain
# compute error measures for predictive model for activity (act) as dependent variable
# note this is computed for all 6 activities and a total computed which is an aggregate value
errormeasures <- function(orig, pred, act) {
N <- length(orig)
origtrue <-as.vector(NULL)
origfalse <-as.vector(NULL)
predtrue <-as.vector(NULL)
predfalse <-as.vector(NULL)
@nborwankar
nborwankar / gist:5208931
Created March 20, 2013 22:02
two python files needed for %pg magic in IPython pgdb.py and pgmagic.py. This is pgdb.py
# pgdb.py
__author__ = 'nitin'
import psycopg2 as pspg2
import sys
# import pandas as pd, then use pandas.io.sql
db_data = {
'host':'localhost',
'dbname': 'nitin',
@nborwankar
nborwankar / gist:5208953
Created March 20, 2013 22:04
two files needed for %pg magic in IPython - pgdb.py and pgmagic.py, this is pgmagic.py
__author__ = 'nitin'
# -*- coding: utf-8 -*-
"""
===========
pgmagic
===========
Magics for interacting with Postgres database server via psycopg2.