Skip to content

Instantly share code, notes, and snippets.

@scalabl3
scalabl3 / Couchbase.log
Created July 7, 2012 03:21
Failed DP4 Install on Mac OS X (after previously installed 1.8.0), and deleted ~/Library/Application Support/Couchbase
Launching '/Applications/Couchbase Server.app/Contents/Resources/start-server.sh'
DYLD_LIBRARY_PATH is /Applications/Couchbase Server.app/Contents/Resources/couchbase-core:/Applications/Couchbase Server.app/Contents/Resources/couchbase-core/lib
Eshell V5.8.4 (abort with ^G)
=PROGRESS REPORT==== 6-Jul-2012::20:16:28 ===
supervisor: {local,sasl_safe_sup}
started: [{pid,<0.114.0>},
{name,alarm_handler},
{mfargs,{alarm_handler,start_link,[]}},
{restart_type,permanent},
@scalabl3
scalabl3 / gist:3161434
Created July 23, 2012 00:09
Automatic Versioning
#Current key is always the most current version of the document. Everytime it gets modified, we increase the count of versions and save current couchbase version of document #as a version with current_version - 1 appended.
#So:
#create_doc
#mydoc = { "txt" => "my first text" }
#replace_doc
#mydoc::version = 2
#mydoc::version::1 = { "txt" => "my_first_text", "auto_version" => 1, "auto_version_stamp" => "6/28/2012 20:35" }
@scalabl3
scalabl3 / gist:3161435
Created July 23, 2012 00:09
Even better than has_key?, is has_key_and_value?
class Hash
# if key doesn't exist, returns false
# if self[key] == false, returns false
# if self[key] == nil, empty, or blank, returns false
# if self[key] exists and self[key] == true, or evaluates to true, returns true
def has_key_and_value? (key)
return false unless has_key?(key)
return false if self[key].nil?
return false if self[key].respond_to?(:empty?) && self[key].empty?
@scalabl3
scalabl3 / gist:3164629
Created July 23, 2012 16:42
dp5 make.out
/Users/jasdeep/rvm/rubies/ruby-1.9.3-p125/bin/ruby extconf.rb
checking for libcouchbase_getl() in -lcouchbase... yes
checking for mach/mach_time.h... yes
checking for stdint.h... yes
checking for sys/time.h... yes
checking for clock_gettime()... no
checking for gettimeofday()... yes
checking for QueryPerformanceCounter()... no
creating couchbase_config.h
creating Makefile
@scalabl3
scalabl3 / gist:3494901
Created August 28, 2012 04:10
Sample .rvmrc for jruby-torquebox gemset
#!/usr/bin/env bash
# This is an RVM Project .rvmrc file, used to automatically load the ruby
# development environment upon cd'ing into the directory
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
environment_id="jruby-1.7.0.preview2@torquebox"
#
# First we attempt to load the desired environment directly from the environment
{
deployment: null,
management-major-version: 1,
management-minor-version: 2,
name: "jumbojet",
namespaces: [ ],
product-name: null,
product-version: null,
profile-name: null,
release-codename: "Steropes",
@scalabl3
scalabl3 / gist:3803110
Created September 29, 2012 03:58
Gem Install Problems... It seems like the problem is in 1.9.3-p125

#$ gem install couchbase --pre#

...
/Users/jasdeep/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
	from /Users/jasdeep/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:491:in `block in try_compile'
	from /Users/jasdeep/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:443:in `with_werror'
	from /Users/jasdeep/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:491:in `try_compile'
	from extconf.rb:89:in `'
@scalabl3
scalabl3 / gist:3893563
Created October 15, 2012 16:50
Installing on Mac

Installing Couchbase Server and PHP or Ruby SDK's on Mac OSX

Order of Operations

  1. Handle post Mountain Lion upgrade if you had Homebrew
  2. Install/Upgrade Couchbase Server
  3. Install Homebrew (if you don't have it already)
  4. Install latest XCode
  5. Install XCode Command Line Tools
  6. Install libcouchbase C library
@scalabl3
scalabl3 / gist:4274831
Created December 13, 2012 07:46
Example of a Range Query to query on two properties

Document Examples we'll Index (Map/Reduce)

Document #1 (key: mobie::001)

{
  doctype: "mobie",
  year: 2002,
  rating: 3
}
@scalabl3
scalabl3 / gist:5222694
Last active December 15, 2015 07:19
cbgb simple passivation test - ruby

UPDATED Results

So in order to make this work for Ruby, I have to add something in my wrapper around Couchbase Ruby gem (I do have a wrapper I made/use, need to modify it), to handle the Couchbase::Error::Network on pretty much every operation to be able to reconnect, since currently that is not automatic.

#<Couchbase::Bucket:0x007fcb1411d780 "http://localhost:8091/pools/default/buckets/test/" default_format=:document, default_flags=0x0, quiet=false, connected=true, timeout=2500000>
2013-03-22 09:54:59.109 INCR curr = 1, counter = 1; connected = true, sleeping for 1s
2013-03-22 09:55:00.109 wake
2013-03-22 09:55:00.109 INCR curr = 2, counter = 2; connected = true, sleeping for 2s
2013-03-22 09:55:02.110 wake