Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
$.couch.urlPrefix = "https://username:[email protected]";
var db = $.couch.db('crud');
var doc = {"_id":"foo", "name": "bar"};
db.saveDoc(doc, {
success: function(response, textStatus, jqXHR){
console.log(response);
},
@chewbranca
chewbranca / index.html
Created August 22, 2012 19:59
Testing Authorization headers in a couchapp
<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
$.when(
$.ajax("/_session"),
$.ajax("/test_couchapp2"),
$.ajax("/_all_dbs"),
$.ajax("/_session")
@chewbranca
chewbranca / README.markdown
Created July 27, 2012 22:11 — forked from gudbergur/README.markdown
Bootstrap's Typeahead plugin extended (allowing for AJAX functionality) among other things

This is a fork of Bootstrap Typeahead that adds minimal but powerful extensions.

For example, process typeahead list asynchronously and return objects

  # This example does an AJAX lookup and is in CoffeeScript
  $('.typeahead').typeahead(
    # source can be a function
    source: (typeahead, query) ->
 # this function receives the typeahead object and the query string
var app = {
renderView: function(baseView, selector, view, options, callback) {
baseView.setView(selector, new view(options)).render().then(callback);
}
};
app.renderView(this, "FAKEITEM", Views.Popover, {model:view.model}, function(popoverEle) {
$(el).find("i.database-info").popover({
title: "displaying info",
content: popoverEle.innerHTML
@chewbranca
chewbranca / compile_error.txt
Created June 16, 2012 03:37
clojure/core.cache compile error
1 compiler notes:
Unknown location:
error: clojure.lang.ArityException: Wrong number of args (3) passed to: cache$lru-cache-factory
core.clj:4:1:
error: clojure.lang.ArityException: Wrong number of args (3) passed to: cache$lru-cache-factory, compiling:(core.clj:4)
Compilation failed.
str = '<?xml version="1.0"?><feed xmlns:media="http://search.yahoo.com/mrss/" xmlns:gr="http://www.google.com/schemas/reader/atom/" xmlns:idx="urn:atom-extension:indexing" xmlns="http://www.w3.org/2005/Atom" idx:index="no" gr:dir="ltr"><gr:continuation>CMKC26-OorAC</gr:continuation></feed>'
str = '<?xml version="1.0"?><feed xmlns:media="http://search.yahoo.com/mrss/" xmlns:gr="http://www.google.com/schemas/reader/atom/" xmlns:idx="urn:atom-extension:indexing" xmlns="http://www.w3.org/2005/Atom" idx:index="no" gr:dir="ltr"><gr:continuation>CMKC26-OorAC</gr:continuation></feed>'
>>> x = BeautifulSoup(str, 'xml')
x = BeautifulSoup(str, 'xml')
>>> x
x
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:gr="http://www.google.com/schemas/reader/atom/" xmlns:idx="urn:atom-extension:indexing" xmlns:media="http://search.yahoo.com/mrss/" {http://www.google.com/schemas/reader/atom/}dir="ltr" {urn:atom-extension:indexing}index="no"><gr:continuation>CMKC26-OorAC</continuation></feed>
>>>
@chewbranca
chewbranca / gist:1102858
Created July 24, 2011 17:32
dbquick.sh
#!/bin/sh
url="$(echo -n $1 | perl -p -e 's/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg')"
host="http://databook.chewbranca.com"
request="/api/v1/quick_post"
api_key="API_KEY"
CURL=`which curl`
$CURL -X GET "${host}$request?a=$api_key&u=$url"
curl -X PUT http://localhost:5984/test
erica create-app app-id=test
cd test
erica push http://localhost:5984/test
cd /tmp
couchapp clone http://localhost:5984/test/_design/test
errors out with:
$ make
==> erica (get-deps)
Pulling couchbeam from {git,"http://github.com/benoitc/couchbeam.git",
"master"}
Initialized empty Git repository in /tmp/erica/deps/couchbeam/.git/
==> couchbeam (get-deps)
Pulling mochiweb from {git,"http://github.com/mochi/mochiweb.git",
{tag,"1.5.2"}}
Initialized empty Git repository in /tmp/erica/deps/mochiweb/.git/
Pulling ejson from {git,"http://github.com/benoitc/ejson.git","master"}