Skip to content

Instantly share code, notes, and snippets.

# creating 2 documents and deleting one of them
$ curl -X PUT 'http://127.0.0.1:5984/crap/thing-A' -d '{}'
{"ok":true,"id":"thing-A","rev":"1-967a00dff5e02add41819138abb3284d"}
$ curl -X PUT 'http://127.0.0.1:5984/crap/thing-B' -d '{}'
{"ok":true,"id":"thing-B","rev":"1-967a00dff5e02add41819138abb3284d"}
$ curl -X DELETE 'http://127.0.0.1:5984/crap/thing-B?rev=1-967a00dff5e02add41819138abb3284d'
{"ok":true,"id":"thing-B","rev":"2-eec205a9d413992850a6e32678485900"}
# checking for existence
$ curl -X GET 'http://127.0.0.1:5984/crap/thing-A'
<?php
header("Content-Type: text/plain");
$dataIn = (object)array(
"string" => "value 1",
"array" => array(1,2,3),
"assoc" => array("cow"=>"moo","dog"=>"woof"),
"object" => (object)array("cat"=>"miao","pig"=>"oink"),
);
{ topic: function () {
fs.stat('~/FILE', this.callback);
},
'after a successful `fs.stat`': {
topic: function (stat) {
fs.open('~/FILE', "r", stat.mode, this.callback);
},
'after a successful `fs.open`': {
topic: function (fd, stat) {
fs.read(fd, stat.size, 0, "utf8", this.callback);
#!/bin/bash
tee -a ~/couchjs-view.in \
| /usr/local/couchdb/bin/couchjs \
/usr/local/couchdb/share/couchdb/server/main.js \
| tee -a ~/couchjs-view.out
<?php
// WTF!
file_get_contents("http://127.0.0.1:31337/v1/posts/adjacent/65f1685dd814524417705a9bcd03e9e7?limit=5", false,
stream_context_create(array('http'=>array(
'method' => "GET",
'header' => array("Host: api.domain.com"),
'timeout' => 2,
))));
function postElem(post) {
var itemEl = $('<div class="item"><div class="image"><a><span class="img"><img></span></a><span class="txt"/></div></div>');
itemEl.attr('id', 'post-'+post.id);
itemEl.find('.image a').attr('href',S3_URL+"/"+post.id+"-m800le.jpg");
itemEl.find('.image img').attr('src',S3_URL+"/"+post.id+"-75se.jpg");
itemEl.find('.image .txt').text(post.caption || '');
return itemEl;
}
<?php
$data = (object)array(
"html" => "<foo bar=\"baz\"/> &amp;",
"arabic" => "العربية al-ʿarabiyyah, IPA: [æl ʕɑrɑˈbijjɐ], or عربي ʿarabī",
"hebrew" => "עִבְרִית, Ivrit",
"chinese" => "汉语/漢語 Hanyu; 华语/華語 Huáyǔ; 中文 Zhōngwén",
"korean" => "한국어/조선말",
"japanese" => "日本語 Nihongo",
"umlauts" => "äüöãáàß",
@muhqu
muhqu / gist:898103
Created April 1, 2011 12:55
version.sh
#!/bin/bash
usage() {
echo "Usage: $0 [options] [action] [branch]"
echo "Actions: "
FORMAT=" %-30s %s\n"
printf "$FORMAT" "curr" \
"prints the current version"
printf "$FORMAT" "incr major|minor|patch" \
"prints the version with incremented major, minor or patch"
#!/bin/bash
#
# The MIT License
#
# Copyright (c) 2011 Mathias Leppich <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell