Skip to content

Instantly share code, notes, and snippets.

View scalabl3's full-sized avatar

Jasdeep Jaitla scalabl3

View GitHub Profile
@scalabl3
scalabl3 / _.md
Created April 10, 2013 02:24
Tributary inlet
@scalabl3
scalabl3 / gist:5223293
Last active December 15, 2015 07:29
test bucket only passivating once?

cbgb output

2013/03/22 09:54:56 cbgb - 0.2.0-6-g4f2787a
2013/03/22 09:54:56   addr=:11211
2013/03/22 09:54:56   data=./tmp
2013/03/22 09:54:56   default-bucket-name=default
2013/03/22 09:54:56   default-persistence=2
2013/03/22 09:54:56   default-quota=100MB
2013/03/22 09:54:56   num-partitions=1
@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
@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: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: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 `'
{
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: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
@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: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?