Skip to content
hy edited this page Aug 22, 2013 · 17 revisions

Hy! Welcome! (This is the NoSQL Hackpack!)

Q: WHAT is this?
A: 1000 lines of code to constitute a set of “Lego Building Blocks” that allow you to experiment with NoSQL concepts using your own data from your own communications . . .

(Details: This is a Sinatra-microframework Heroku webserver deploy for MongoDB, Redis-To-Go, Twilio, Google Calendar, Google TaskList, and Sendgrid / Pony for email. FoundationDB, Allegrograph, Riak and others also have expressed interest, so those may also be available in the weeks ahead. . . )

Q: WHY?
A: Because:
If I give you slides, you will have information. (Which is good.) But…
If I give you code, you will have the power to create. (Which is Better!)

Q: WHO is it for?
A: Folks who want to get from “zero” to “experimental” w.r.t. NoSQL ideas with data from text messages, phone calls, voice-to-text translations, calendar events, etc.

Q: HOW do I get started?
A: Here are the notes from a ‘canonical’ install on a Mac with rvm and bundler installed. . .

1) LICENSE is the MIT (X-11) Open Source license
2) Make a new directory and name it for your project
3) Get the ______.rb file [rename this as per your project name]
4) Get the ‘config.ru’ file [but do NOT change the name]
5) Edit the ‘config.ru’ file to match your project name:
require File.dirname(FILE) + “/HyLvlConcepts”
6) Get the ‘Gemfile’

Then, from the shell’s command line prompt (/bin/bash is the default):

7) Put: \[ \[ -s “/Users/sr/.rvm/scripts/rvm” \] \] && source “/Users/sr/.rvm/scripts/rvm”
into your ~/.rubyrc or else your ~/.profile

If you added the line to .profile, start a new shell or source it.
If you added the ~/.rubyrc, Type: source ~/.rubyrc

8) Type: bundle install [requires bundler gem]

[Optional: Go to GitHub and set up your own repository]

9) Type: git init [requires git]

10) Type: git add Gemfile Gemfile.lock HyLvlConcepts.rb config.ru LICENSE

11) Type: git commit -m 'Initial Commit'

12) Type: heroku create --stack cedar [requires Heroku]

See:
Creating gentle-journey-8089… done, stack is cedar
http://gentle-journey-8089.herokuapp.com/ | git@heroku.com:gentle-journey-8089.git

13) Type: heroku logs

See:
2013-08-19T21:33:12.616732+00:00 heroku[api]: Enable _________@gmail.com
2013-08-19T21:33:12.636547+00:00 heroku[api]: Release v2 created by ___________@gmail.com

14) Type: heroku addons:add redistogo


> Adding redistogo to gentle-journey-8089… done, v3 (free)

15) Type: heroku config

See:
REDISTOGO_URL => redis://redistogo:1759c70d281834d6abffd4312c34fa7c@crestfish.redistogo.com:9288/

16) Configure the rest of the environment for Heroku. . .

Type: heroku config:add APP='NoSQL HyLvlConcepts HackPack'
Type: heroku config:add APP_BASE_VERSION='0.1'
Type: heroku config:add TWILIO_ACCOUNT_SID='XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
Type: heroku config:add TWILIO_AUTH_TOKEN='XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
Type: heroku config:add TWILIO_CALLER_ID='+1650XXXXXXX'
Type: heroku config:add APP_EMAIL_ADDY='your-app-name@gmail.com'
Type: heroku config:add APP_EMAIL_AUTH='app-email-passwd'
Type: heroku config:add MONGO_USER_ID='m-account-name' MONGO_PASSWORD='m-passwd'
Type: heroku config:add MONGO_URL='dharma.mongohq.com' MONGO_PORT=10070
Type: heroku config:add MONGO_DB_NAME='latest'
Type: heroku config:add LOG_LEVEL=DEBUG
Type: heroku config:add SITE='http://gentle-journey-8089.herokuapp.com/'
Type: heroku config:add GIT='git@heroku.com:gentle-journey-8089.git'
Type: heroku config:add MONGODB_URI='mongodb://account-name:passwd@dharma.mongohq.com:10070/db-name'
Type: heroku config:add GOOGLE_SECRET='XXXXX'
Type: heroku config:add GOOGLE_ID='XXXX.apps.googleusercontent.com'

(Put this into your own configuration script ASAP!)

17) Type: heroku config

(Should now reflect the above)

18) Type: git push -u git@heroku.com:gentle-journey-8089.git master

19) Type: heroku logs

See:
2013-08-19T22:06:59+00:00 heroku[slug-compiler]: Slug compilation finished
2013-08-19T22:07:05.008589+00:00 heroku[web.1]: Starting process with command `bundle exec thin start -R config.ru -e $RACK_ENV -p 39276`
2013-08-19T22:07:10.087385+00:00 app[web.1]: [OK!] Constants Initialized
2013-08-19T22:07:10.087385+00:00 app[web.1]: [OK!] Mongo Connection Configured
2013-08-19T22:07:10.087385+00:00 app[web.1]: ____________CONFIGURING FOR REMOTE SITE: http://gentle-journey-8089.herokuapp.com/____________
2013-08-19T22:07:10.087385+00:00 app[web.1]: [OK!] Redis Configured
2013-08-19T22:07:10.087385+00:00 app[web.1]: [OK!] Twilio Client Configured for: 14073783837
2013-08-19T22:07:10.737659
00:00 app[web.1]: [OK!] Google API Configured with Scope Including:
2013-08-19T22:07:10.737659+00:00 app[web.1]: https://www.googleapis.com/auth/tasks
2013-08-19T22:07:10.737659+00:00 app[web.1]: https://www.googleapis.com/auth/calendar
2013-08-19T22:07:10.748940+00:00 app[web.1]: >> Thin web server (v1.5.1 codename Straight Razor)
2013-08-19T22:07:10.748940+00:00 app[web.1]: >> Maximum connections set to 1024
2013-08-19T22:07:10.748940+00:00 app[web.1]: >> Listening on 0.0.0.0:39276, CTRL+C to stop
2013-08-19T22:07:10.967834+00:00 heroku[web.1]: State changed from starting to up

20) Go to your new website at /test, and if you see this, Declare Victory!!

2013-08-20T00:25:18.111601+00:00 app[web.1]: >> Thin web server (v1.5.1 codename Straight Razor)
2013-08-20T00:25:18.845606+00:00 app[web.1]: BEFORE FILTER
2013-08-20T00:25:18.845606+00:00 app[web.1]: ENTERING ROUTE: /test
2013-08-20T00:25:18.849718+00:00 app[web.1]: AFTER FILTER
2013-08-20T00:25:18.849718+00:00 app[web.1]: REDIS STORED THE TIME AS:
2013-08-20T00:25:18.851303+00:00 app[web.1]: 2013-08-20 00:25:18 +0000

[Optional: Push your code to your own GitHub repository]

And: That’s It!
-———————————————————————

PLACES YOU MAY GET STUCK AND WHAT TO DO THEN:

Problem: The rvm setup is not working

Alternate (Credit to Sarabjeet Chugh):

> Here is how I did it (for the wiki):
>
> Download and install Railsinstaller from: http://railsinstaller.org/en. If
> you encounter issues during installation, e.g. cannot change user for /opt
> or /opt/rvx then simply reboot your Mac OSX machine, and it works after
> that.
> Install Ruby 1.9.2 using rvm by typing: rvm upgrade 1.9.2
> Point to 1.9.2 using rvm by typing: rvm use 1.9.2
> Test ruby version: ruby -v , and you should see using Ruby version 1.9.2

Problem: Heroku asks for a credit card number in order to activate the add-ons. . .

Alternative (Credit to the Chemical Abstracts team):

Subscribe to Redis separately (i.e. not from the Heroku site) and link up the environment by hand.
(This also works for Mongo — subscribe to MongoHQ or ObjectRocket from those sites directly.)

Take Care! (Hope this Helped)

FORMAT NOTE: This page markup is in Textile, to preserve cut-paste carriage returns…

Clone this wiki locally