Skip to content

Instantly share code, notes, and snippets.

@nilakanta
nilakanta / install-node-redis.sh
Last active March 7, 2018 14:55
Install Node.js & Redis on ubuntu
# Install git
sudo apt-get install git-core
# Install Node.js
sudo apt-get install -y libssl-dev pkg-config build-essential curl gcc g++ checkinstall
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
@nilakanta
nilakanta / my_app_money.rb
Created September 1, 2011 03:17
Use Money gem with mongoid (works with mongoid 2.1.0 and higher)
module MyApp
class Money
include Mongoid::Fields::Serializable
def cast_on_read?; true; end
def deserialize(object)
return nil if object.blank?
::Money.new(object[:cents] || object["cents"], object[:currency] || object["currency"])
end
@nilakanta
nilakanta / bigcouch on centos
Created March 13, 2011 19:14
Bigcouch on centos
#32 bit - centos 5, bigcouch 0.3
================================
# add new source
su -c 'rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm'
#add dependencies
yum install js-devel libicu libicu-devel
sed -i 's/gpgcheck=1/gpgcheck=0/' /etc/yum.conf
sudo yum install gcc glibc-devel make ncurses-devel openssl-devel
@nilakanta
nilakanta / Error on bigcouch cluster
Created January 18, 2011 10:48
Add/Remove a node and then try accessing a doc
-- Example from http://blog.couchone.com/post/446015664/whats-new-in-apache-couchdb-0-11-part-two-views
>> curl -X GET http://localhost:5984/testdb/Claire
>>
{"error":"timeout","reason":"{[{shard,<<\"shards/80000000-9fffffff/testdb.1295344320\">>,\n 'bigcouch@bigcouch3-ip',<<\"testdb\">>,\n [2147483648,2684354559],\n #Ref<0.0.2.126921>},\n {shard,<<\"shards/80000000-9fffffff/testdb.1295344320\">>,\n 'bigcouch@bigcouch2-ip',<<\"testdb\">>,\n [2147483648,2684354559],\n #Ref<0.0.2.126922>}],\n 2,\n [{{<<\"Claire\">>,\n {1,[<<121,63,75,187,191,227,242,249,21,77,110,83,242,96,192,38>>]}},\n {{ok,{doc,<<\"Claire\">>,\n {1,\n [<<121,63,75,187,191,227,242,249,21,77,110,83,242,96,192,38>>]},\n {[{<<\"title\">>,<<\"VP of Official Attitude\">>}]},\n [],false,[]}},\n 1}}]}"}
@nilakanta
nilakanta / Error on bigcouch cluster
Created January 18, 2011 10:48
Add/Remove a node and then try accessing a doc
{"error":"timeout","reason":"{[{shard,<<\"shards/80000000-9fffffff/testdb.1295344320\">>,\n 'bigcouch@bigcouch3-ip',<<\"testdb\">>,\n [2147483648,2684354559],\n #Ref<0.0.2.126921>},\n {shard,<<\"shards/80000000-9fffffff/testdb.1295344320\">>,\n 'bigcouch@bigcouch2-ip',<<\"testdb\">>,\n [2147483648,2684354559],\n #Ref<0.0.2.126922>}],\n 2,\n [{{<<\"Claire\">>,\n {1,[<<121,63,75,187,191,227,242,249,21,77,110,83,242,96,192,38>>]}},\n {{ok,{doc,<<\"Claire\">>,\n {1,\n [<<121,63,75,187,191,227,242,249,21,77,110,83,242,96,192,38>>]},\n {[{<<\"title\">>,<<\"VP of Official Attitude\">>}]},\n [],false,[]}},\n 1}}]}"}
@nilakanta
nilakanta / Bigcouch
Created January 18, 2011 07:09
couch view with include_docs
Create Documents and view
=========================
curl -X PUT http://localhost:5984/testdb -d {}
curl -X PUT http://localhost:5984/testdb/Claire -d '{"title": "VP of Official Attitude"}'
curl -X PUT http://localhost:5984/testdb/Mikeal -d '{"title": "VP of Pastries and Automating Stuff"}'
curl -X PUT http://localhost:5984/testdb/Jason -d '{"title": "VP of Hosting and Lightning"}'
curl -X PUT http://localhost:5984/testdb/team -d '{"members": ["Claire", "Mikeal", "Jason"]}'
curl -X PUT http://localhost:5984/testdb/_design/myview -d '{"language":"javascript","views":{"test":{"map":"function(doc) {if(doc.members) {doc.members.forEach(function(member) {emit(member, {_id: member});});}}"}}}'
Test the view
painless removal of all the gems `gem list | cut -d" " -f1 | xargs gem uninstall -aIx`
rvm install 1.9.2 on OS X 10.6 `rvm install 1.9.2 -C --with-readline-dir=/opt/local,--build=x86_64-apple-darwin10`