Skip to content

Instantly share code, notes, and snippets.

@sbisbee
sbisbee / gist:1174685
Created August 26, 2011 23:27
Another script for Sag v0.5.1 connection pooling debugging purposes.
#!/usr/bin/php
<?php
require('Sag.php');
$sag = new Sag();
$sag->setDatabase('bwah', true);
// Send a temp view
var_dump($sag->post(array( 'map' => 'function(doc) { emit(null, null); }'), '/_temp_view'));
// Send a doc
@sbisbee
sbisbee / fibo.erl
Created October 14, 2011 03:17
Learning me some erlang by calculating Fibonacci.
-module(fibo).
-export([calc/1, run/1]).
% Entry method to calculate fibo
calc(N) when N > 0 ->
calc(N, 1, 1, []);
calc(_) ->
'Can only calculate F(N) where N > 0'.
@sbisbee
sbisbee / twitpic_flickr.php
Created October 18, 2011 14:42 — forked from cowboy/twitpic_flickr.php
Twitpic-Flickr bridge. Now I can upload photos to Flickr via my iPhone Twitter app, yay!
<?php
# Twitpic-Flickr bridge - v0.1pre - 10/18/2011
# http://benalman.com/
#
# Copyright (c) 2011 "Cowboy" Ben Alman
# Dual licensed under the MIT and GPL licenses.
# http://benalman.com/about/license/
# There's no way I'm writing all the Flickr stuff myself.
Document Structure
------------------
{
_id: "whatever",
type: "some category style grouping",
date: Unix time stamp
}
Map Function
@sbisbee
sbisbee / gist:1320996
Created October 27, 2011 21:55
init file for bigcouch on centos
#!/bin/bash
#
# chkconfig: 23 90 10
# Description: Quickly hacked together bigcouch init script for CentOS systems.
. /etc/init.d/functions
PID_FILE=/var/run/bigcouch.pid
BIGCOUCH_BIN=/opt/bigcouch/bin/bigcouch
SUBSYS_LOCK_FILE=/var/lock/subsys/bigcouch
@sbisbee
sbisbee / gist:1352319
Created November 9, 2011 18:13
Sag contribution guide

Contributing to Sag

First off - you rock! Community contributions are so awesome and have resulted in some awesome features landing in Sag.

This guide is meant to make it as easy as possible to contribute your code to Sag.

Sending the Contribution

<html>
<head>
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/1.4.0/bootstrap.min.css">
</head>
<body>
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="http://autobahn.tablesorter.com/jquery.tablesorter.min.js"></script>
<script>
function makeTable(parentSelector, colHeaders, data) {
@sbisbee
sbisbee / bulk.js
Last active November 1, 2015 20:55
Sag-JS Docu Examples 1
var docs = [
{ _id: 'doc1', foo: 'bar' },
{ _id: 'doc2', hi: 'there' }
];
couch.bulk({
docs: docs,
callback: function(resp, succ) {
//...do stuff
}
@sbisbee
sbisbee / compact.js
Created December 23, 2011 21:45
Sag-JS Docu Examples 2
//Compact the db
couch.compact({
callback: function(resp, succ) {
//do stuff
}
});
//Compact the view
couch.compact({
viewName: 'app',
sag.setDatabase('bwah');
sag.login({
user: 'user',
pass: 'pass'
); //using basic auth
sag.get({
url: '/someDoc',
callback: function(resp, worked) {