Saturday, 17 August 2013

Harley and Callum - Foster Cats 14 and 15

Here are a few shots of our latest foster cats Harley (a male sleek black cat) and Callum (a male ginger cutie).
These two are completely inseparable.
They play and cuddle constantly.
They are also 'lickers'.
I've been cat-foliated several times now and my ears are squeeky clean if a bit sore.
Harley loves to groom and spends ages tugged and licking my hair.





Monday, 8 July 2013

CouchDB Sinatra REST bare-metal call test application

Some months ago I was involved in configuring an API to use with CouchDB. In the process of this, I created a test application using Sinatra to utilize the various CouchDB REST calls. This is that application.

Later I created a MUCH more sophisticated set of sub-apps in Padrino to utilize the lessons learned. For some time now I have been asked to release it into the wild to aid other developers, but have been too busy. Now I have time. Hence this post.

It is not great. It is not well written. It is not documented. It has no tests. But it works.

It was written in one day to get the process of using rest-client to operate against a test CouchDB database. That is all.

I make no apologies for the code.

It works. That is all.

To use it:

1) Install CouchDB someplace.

I have it on an external server as exampled in the config/couchdb.yml file.

2) Clone the repo from https://github.com/ZenGirl/CouchDBSinatraRestAPI

Goes without saying...

3) Change the config/couchdb.yml file

Change to suit.

4) Fire it up

bundle install
rackup -s thin -o 0.0.0.0 -p 9292 -E development config.ru

Then open a browser to http://0.0.0.0:9292/index.html and start playing.

Honestly!

I would love to here from cloners who would like enhancements as I'm always ready to learn. If you see a problem, or want to have me change something, tell me.

Sunday, 7 July 2013

Well, it's official. I've been unemployed for 6 months and broke.

I left Guvera officially mid last year due to fairly dramatic family needs. Then Guvera asked me back on contract which I could do while handling those family issues. I finished up that contract just before christmas to work on some other exciting projects.

I have tons of work on several major startups since then. Mainly Rails, Padrino and Java with some PHP and Systems Admin work. While those startups may still create income, none of them have produced dollar 1 so far.

So I have no option but to hit the job market and try to find work to pay the bills. So if you're looking for a highly experienced technologist, toolmaker, solution architect, problem solver, trouble shooter, firefighter and innovator, then go no further. Have a look at my LinkedIn profile to see if you could use my skill sets. In particular see my colleagues recommendations.

Here's a quick run down of who I am and what I can do:

I have over thirty years experience in computing and have worked for large multi-nationals such as Sun Microsystems, Microsoft, Western Mining Corporation and many, many startups. I have written Unix Systems Administration manuals and have taught systems administration and programming to both groups and individuals.

I love technology!
Since the late 70’s I have been involved in the open source community and contributed heavily to many early projects. My code exists in many implementations of linux and I have even been cited on a man page (albeit for a game). Ben and I own far too much tech... We even have a first gen MakerBot and have used it to fix quite a few things around the house!

TDD is a part of everything I write and has been for many years. Unfortunately I have found that many companies consider TDD to be a waste of programming resource, which I consider short sighted.

Release early, release often. I have always advocated this and used (and built) many deployment tools such as Capistrano et al to get code live quickly.

I have used MySQL, MongoDB and recently CouchDB to handle large amounts of data. A recent project involved 100’s of millions of documents handling companies historical data.

I am no stranger to working from home and can be incredibly productive. For the last 6 months of last year I contracted to a major music distribution company and worked from home with occasional in-house and Skype meetings.

So if I fit your needs, get in touch!

Sunday, 30 June 2013

"Scratches to Scratches" a version of David Bowie lyrics for cat people!

"Scratches to Scratches"

Try listening to Ashes to Ashes after reading these lyrics Ben and I came up with:

Do you remember a cat that's been
In such an early lol
I've heard a rumour from Animal Welfare
Oh no, don't say it's true

They got a message
from the Ceiling Cat
"I'm hungry, hope you're hungry too
I've eaten all I've needed to eat
Nomming details following"

The eating of nothing is boring
Just pictures of grumpy cats in synthesis and I
Ain't got no money and I ain't got no food
But I'm hoping to scratch but the sofa it's unallowed

Scratches to scratches, punk to punky
We know Ginger Tom's a punkie
Strung out in catnip's high
Hitting an all-time low

Time and again I tell myself
I'll not eat tonight
But the little can openers call to me
Oh no, not again
I'm playing with a valuable friend
"I'm hungry, hope you're hungry too"
One flash of led light but no catching it

I never done good things
I never done bad things
I never did anything out of the house
Want an claw to break the skin
Wanna eat right now

My mother said to get things done

You'd better not mess with Ginger Tom

The dreaded 'attack prevented by Rack::Protection::AuthenticityToken' problem

I have a Padrino app with multiple sub-apps.
Each of those sub-apps is not really an app, but rather a set of APIs.
To illustrate here is the super-basic layout:

├── API
│   └── v1
│       ├── airports
│       │   ├── app.rb
│       │   ├── config
│       │   │   └── boot.rb
│       │   ├── controllers
│       │   │   └── airports.rb
│       │   ├── db
│       │   │   └── seed.rake
│       │   └── models
│       │       └── airport.rb
│       └── sessions
│           ├── app.rb
│           ├── config
│           │   └── boot.rb
│           ├── controllers
│           │   └── sessions.rb
│           ├── db
│           │   └── seed.rake
│           └── models
├── Capfile
├── Gemfile
├── Gemfile.lock
├── README.md
├── Rakefile
├── app
│   ├── app.rb
│   ├── controllers
│   ├── helpers
│   └── views
├── config
│   ├── apps.rb
│   ├── boot.rb
│   ├── database.rb
│   └── deploy.rb
├── config.ru
├── db
├── lib
├── library
├── log
├── models
├── public
│   ├── airports.html
│   ├── favicon.ico
│   ├── home.html
│   ├── images
│   │   └── logo.jpg
│   ├── javascripts
│   │   ├── application.js
│   │   ├── jquery-ujs.js
│   │   └── jquery.js
│   ├── login.html
│   ├── logout.html
│   └── stylesheets
│       ├── application.css
│       ├── bootstrap.css
│       └── reset.css
├── spec
│   ├── spec.rake
│   └── spec_helper.rb
└── tmp

Notice that folder 'API'? That's what holds all the sub-apps.
In this simple case, there are just two.
Each has a minimal set of folders and what not.
The bulk of the work is done in the public html files via jQuery.
So for example, you want a html file to have jQuery make a call to login a user:

The html:

<div id="ProfileLogin">
    <h1>LOGIN</h1>

    <div id="ProfileLoginErrors"></div>
    <form id="ProfileLoginForm" method="post">
        <label for="ProfileLoginUsername">Username:</label>
        <input id="ProfileLoginUsername" name="username" type="text"/>
        <label for="ProfileLoginPassword">Password:</label>
        <input id="ProfileLoginPassword" name="password" type="text"/>
        <input id="ProfileLoginSubmit" type="submit" value="Login"/>
    </form>
</div>

The jQuery:

    <script type="text/javascript">
        $(document).ready(function () {
            $('#ProfileLoginForm').on('submit', function (event) {
                event.preventDefault();
                var postData = $('#ProfileLoginForm').serialize()
                $.ajax({
                    type: 'POST',
                    url: '/api/v1/sessions/login',
                    data: postData,
                    success: function (data, textStatus, jqXHR) {
                        if (data.errors) {
                            $('#ProfileLoginErrors').html(data.errors);
                        } else {
                            window.location.href = '/home.html';
                        }
                    },
                    fail: function (data, textStatus, jqXHR) {
                        $('#ProfileLoginErrors').html(data);
                    }
                })
            });
        });
    </script>

Now when you do a POST, and look at the development log, you see this:

 WARN -  attack prevented by Rack::Protection::AuthenticityToken
DEBUG -      POST (0.0035s) /api/v1/sessions/login - 403 Forbidden

Damn. Rack::Protection::AuthenticityToken is stopping us getting in.
The problem is that Rack::Protection uses a hidden value to ensure you're being called from where it expects.

The code responsible is in /Users/[you]/.rvm/gems/ruby-2.0.0-p0/gems/rack-protection-1.5.0/lib/rack/protection/authenticity_token.rb.
It looks like this:

require 'rack/protection'

module Rack
  module Protection
    ##
    # Prevented attack::   CSRF
    # Supported browsers:: all
    # More infos::         http://en.wikipedia.org/wiki/Cross-site_request_forgery
    #
    # Only accepts unsafe HTTP requests if a given access token matches the token
    # included in the session.
    #
    # Compatible with Rails and rack-csrf.
    class AuthenticityToken < Base
      def accepts?(env)
        return true if safe? env
        session = session env
        token   = session[:csrf] ||= session['_csrf_token'] || random_string
        env['HTTP_X_CSRF_TOKEN'] == token or
          Request.new(env).params['authenticity_token'] == token
      end
    end
  end
end

And the reason is returns false is because 'authenticity_token' hasn't been provided.

Don't bother going into and mucking about with:

set :protection, true
set :protect_from_csrf, true
set :allow_disabled_csrf, true

It won't help. The problem is you're not passing the 'authenticity_token' in the POST request.
The cure:

  // REQUIRES the authenticity token appended!
  var postData = $('#ProfileLoginForm').serialize() + '&authenticity_token=' + CSRF_TOKEN;

Now where did that CSRF_TOKEN come from?
Ah. And here's the trick.
First modify your public/javascripts/applications.js and add this:

var CSRF_TOKEN = '';

function configureCSRF() {
    $.ajax({
        type: 'GET', url: '/api/v1/sessions/csrf_token',
        async: false,
        cache: false,
        success: function (data, textStatus, jqXHR) {
            CSRF_TOKEN = data.csrf;
        },
        fail: function (data, textStatus, jqXHR) {
        }
    })
}

Just see that a call is being made to '/api/v1/sessions/csrf_token' and on success, a global CSRF_TOKEN is being set.
So what is the call '/api/v1/sessions/csrf_token' look like?

get :csrf_token, :map => '/csrf_token', :provides => :json do
  logger.debug 'Retrieving csrf_token'
  result = {
      :csrf => session[:csrf]
  }
  JSON.pretty_generate result
end

Ok. So how do you use it?
You change your javascript to:

<script type="text/javascript">
    configureCSRF();
    $(document).ready(function () {
        $('#ProfileLoginForm').on('submit', function (event) {
            event.preventDefault();
            // REQUIRES the authenticity token appended!
            var postData = $('#ProfileLoginForm').serialize() + '&authenticity_token=' + CSRF_TOKEN;
            $.ajax({
                type: 'POST',
                url: '/api/v1/sessions/login',
                data: postData,
                success: function (data, textStatus, jqXHR) {
                    if (data.errors) {
                        $('#ProfileLoginErrors').html(data.errors);
                    } else {
                        window.location.href = '/home.html';
                    }
                },
                fail: function (data, textStatus, jqXHR) {
                    $('#ProfileLoginErrors').html(data);
                }
            })
        });
    });
</script>

You could also add:

headers: {
    'HTTP_X_CSRF_TOKEN': CSRF_TOKEN
},

To the call, but I found it was not necessary.

YMMV.

Friday, 28 June 2013

Nitrous.IO! First impression after public beta release

Ok. I signed on as soon as I heard about this at the end of May 2013 because it was exactly what I was looking for.
I just received the email confirming the public beta, I decided to do some testing for 'real' and see if it really suited my needs in the 'real' world.

First step was to login and confirm my email. No problem.
Got extra N2O because I was part of the first signers and that's very cool.

Oh I forgot to mention; I'm using Chrome Version 27.0.1453.116.

So... I configured a box.
Neat easy and fast.
At the main window, I immediately started digging around.
First let's take a look at the system:

action@kimbo-review-99999:~/workspace$ lsb_release -a
No LSB modules are available.  
Distributor ID: Ubuntu 
Description:  Ubuntu 12.04.2 LTS 
Release:  12.04  
Codename: precise  

(FYI: The boxname is not the real one for obvious reasons...)

Ok. Ubuntu 12.04. There's a later version (which I've upgraded to on one of my home machines due to some gigabit network driver issues) but I wasn't about to try to do a sudo apt-get do-release-upgrade for obvious reasons.

Next networking:

action@kimbo-review-99999:~/workspace$ ifconfig -a  
eth0  Link encap:Ethernet  HWaddr 02:00:c0:a8:fd:f6  
  inet addr:192.168.253.246  Bcast:192.168.253.255  Mask:255.255.255.0 
  inet6 addr: fe80::c0ff:fea8:fdf6/64 Scope:Link 
  ...elided for brevity...

Ok. So know we know that subnets they're using. A quick check on the 'boxes' page (which is very well built I have to say) showed my external hostname. A quick check with nslookup shows it as running off AWS:

bandit:~ kim$ nslookup kimbo-review-99999.apse2.actionbox.io
Server:  192.168.170.1
Address: 192.168.170.1#53

Non-authoritative answer:
kimbo-review-99999.apse2.actionbox.io canonical name = ec2-54-252-89-123.ap-southeast-2.compute.amazonaws.com.
Name: ec2-54-252-89-123.ap-southeast-2.compute.amazonaws.com
Address: 54.252.89.123
Now let's see who I am:

action@kimbo-review-99999:~/workspace$ who  
action pts/1  2013-06-28 02:10 (ip-10-240-57-14.ap-southeast-2.compute.internal)
Interesting. User 'action'. So I had a look at `/etc/passwd` and noticed that `www-data` is included for Apache2 and `puppet` for... well... `puppet`.

Now for giggles I did this:

action@kimbo-review-99999:~$ uptime 
 02:27:42 up 23 days,  9:58,  1 user,  load average: 0.02, 0.06, 0.11  
What? 23 days? Ah. Neat. It appears that boxes are 'pre-provisioned' and assigned a name and extras during the 'provisioning' process.
Clever. Like that. Must remember that.

UPDATE: Whoops. Ben pointed out my mistake. They aren't pre-provisioned. It's likely a clone of a VM that was configured 24 days ago. My bad.

Now let's dig around the home folder:

action@kimbo-review-99999:~$ ls -aF /home/action  
./ .bash_history  .bash_profile  .cache/  .gemrc  .nvm/ .rvm/  .tmux.conf  workspace/  .zshrc  
../  .bash_logout .bashrc  .gem/  .gitconfig  .profile  .ssh/  .VERSION  .zprofile 
Ok. The .gemrc has good stuff in it:

install: --no-rdoc --no-ri 
update: --no-rdoc --no-ri  
gem: --no-rdoc --no-ri 
And the .gitconfig also:

[color]  
  ui = auto  
[alias]  
  st = status  
  di = diff  
  ci = commit  
  br = branch  
  llog = log --date=local  
[rerere] 
  enabled = true 
The .profile is normal and basic. The .tmux.conf is fine:

action@kimbo-review-99999:~$ cat .tmux.conf 
# shell  
set-option -g default-shell /bin/bash  
set -g default-terminal "screen-256color"  
There is a .VERSION file which looks interesting. I'm presuming this is part of the puppet process.
I'm also presuming the .ssh folder keys are used for the same purpose (they are for action@apse2.actionbox.io).

Next a dig around /etc...
Noticed there are no cron jobs configured.
The /etc/hosts is interesting as it has that old 'Ubuntu 127.0.1.1' address thing going on.
The /etc/nsswitch.conf is minimal with the hosts set to files dns.
The /etc/resolv.conf is interesting also. Mine is set to this:

action@kimbo-review-99999:~$ cat /etc/resolv.conf 
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8) 
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN  
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8) 
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN  
nameserver 172.16.0.23 
search us-west-1.compute.internal  
Which is curious since I configured an 'Oceania' box since I'm in Australia. Oh well.

The /etc/timezone file shows the zone is set to Etc/UTC. If you want to I guess you could change this to your local time zone for your logs.

Now the /etc/init.d folder. Mostly standard stuff and no Apache1 or NGinx.
Ah. That's a question I wanted to ask! How the frack do you configure a 'production' environment.
I'll come back to that.

Next I checked the svn and git commands:

action@kimbo-review-99999:~$ svn --version  
svn, version 1.6.17 (r1128011) 
 compiled Dec 17 2011, 16:12:52  
 
Copyright (C) 2000-2009 CollabNet. 
Subversion is open source software, see http://subversion.apache.org/  
This product includes software developed by CollabNet (http://www.Collab.Net/).  
 
The following repository access (RA) modules are available:  
 
* ra_neon : Module for accessing a repository via WebDAV protocol using Neon.  
  - handles 'http' scheme  
  - handles 'https' scheme 
* ra_svn : Module for accessing a repository using the svn network protocol. 
  - with Cyrus SASL authentication 
  - handles 'svn' scheme 
* ra_local : Module for accessing a repository on local disk.  
  - handles 'file' scheme  
 
action@kimbo-review-99999:~$ git --version  
git version 1.7.9.5  
Ok. The git version is less than 1.7.10 so if you are using capistrano from your own physical box you *may* encounter the old "cap constantly asking for passwords even though they've been defined in the deploy.rb" problem.

Ok. I configured a RoR box, so let's do some digging.
First, of course, is ruby.

action@kimbo-review-99999:~/workspace$ ruby -v  
ruby 2.0.0p195 (2013-05-14 revision 40734) [x86_64-linux]  
Neat. Ruby2 p147 has just been released and hopefully that will be installed on new boxes and be upgradeable on already provisioned ones.
Next, let's see some system stats:

Since I am going to test padrino I did a gem install padrino and it installed very quickly!
The rails gems like activerecord were all 3.2 by the way.
So next I changed directory to the `workspace` and generated a plain app.
Blisteringly quick.
So cd to the workspace app and do a bundle install...
Not so blistering, but fast enough.
It showed that we are using sinatra (1.4.3) and padrino (0.11.2).
So let's play with starting the app:

action@kimbo-review-99999:~/workspace/kimbo$ padrino start  
WARN: Unresolved specs during Gem::Specification.reset:  
  rack (>= 1.0.0, ~> 1.4)  
  activesupport (>= 3.1.0) 
WARN: Clearing out unresolved specs. 
Please report a bug if this causes problems. 
=> Padrino/0.11.2 has taken the stage development at http://127.0.0.1:3000 
[2013-06-28 02:57:14] INFO  WEBrick 1.3.1  
[2013-06-28 02:57:14] INFO  ruby 2.0.0 (2013-05-14) [x86_64-linux] 
[2013-06-28 02:57:14] INFO  WEBrick::HTTPServer#start: pid=969 port=3000 

Ok. I browsed to it from the 'preview' menu (port 3000) as that was what WEBrick starts on.

BLAM!

We couldn't find a server running on this port – are you sure there is a server running?
Make sure to bind your server to host 0.0.0.0 (instead of localhost/127.0.0.1).
Ah. Fracking obvious. So a restart of WEBrick with the host and port set:

action@kimbo-review-99999:~/workspace/kimbo$ padrino start -p 3000 -e development -h 0.0.0.0  
WARN: Unresolved specs during Gem::Specification.reset:  
  rack (>= 1.0.0, ~> 1.4)  
  activesupport (>= 3.1.0) 
WARN: Clearing out unresolved specs. 
Please report a bug if this causes problems. 
=> Padrino/0.11.2 has taken the stage development at http://0.0.0.0:3000 
[2013-06-28 03:02:49] INFO  WEBrick 1.3.1  
[2013-06-28 03:02:49] INFO  ruby 2.0.0 (2013-05-14) [x86_64-linux] 
[2013-06-28 03:02:49] INFO  WEBrick::HTTPServer#start: pid=978 port=3000 
And the 'preview' works. Cool. Don't like the look of those gem messages, but I'll leave that for now.

Let's try thin:

action@kimbo-review-99999:~/workspace/kimbo$ padrino start -p 3000 -e development -h 0.0.0.0 -a thin  
WARN: Unresolved specs during Gem::Specification.reset:  
  rack (>= 1.0.0, ~> 1.4)  
  activesupport (>= 3.1.0) 
WARN: Clearing out unresolved specs. 
Please report a bug if this causes problems. 
=> Padrino/0.11.2 has taken the stage development at http://0.0.0.0:3000 
<= Padrino leaves the gun, takes the cannoli 
/home/action/.rvm/gems/ruby-2.0.0-p195/gems/rack-1.5.2/lib/rack/handler/thin.rb:1:in `require': cannot load such file -- thin (LoadError)  
  from /home/action/.rvm/gems/ruby-2.0.0-p195/gems/rack-1.5.2/lib/rack/handler/thin.rb:1:in `<top (required)>' 
  from /home/action/.rvm/gems/ruby-2.0.0-p195/gems/rack-1.5.2/lib/rack/handler.rb:20:in `const_get'  
...elided for brevity...

BLAM!

Odd. Sure I saw it in the gem list --local... Is it installed?

action@kimbo-review-99999:~/workspace/kimbo$ which thin 
action@kimbo-review-99999:~/workspace/kimbo$ gem list --local | grep thin 
So I was wrong. Not installed.
Install it:

action@kimbo-review-99999:~/workspace/kimbo$ gem install thin 
Fetching: eventmachine-1.0.3.gem (100%)  
Building native extensions.  This could take a while...  
Successfully installed eventmachine-1.0.3  
Fetching: daemons-1.1.9.gem (100%) 
Successfully installed daemons-1.1.9 
Fetching: thin-1.5.1.gem (100%)  
Building native extensions.  This could take a while...  
Successfully installed thin-1.5.1  
3 gems installed 
And try again:

action@kimbo-review-99999:~/workspace/kimbo$ padrino start -p 3000 -e development -h 0.0.0.0 -a thin  
WARN: Unresolved specs during Gem::Specification.reset:  
  rack (>= 1.0.0, ~> 1.4)  
  activesupport (>= 3.1.0) 
WARN: Clearing out unresolved specs. 
Please report a bug if this causes problems. 
=> Padrino/0.11.2 has taken the stage development at http://0.0.0.0:3000 
<= Padrino leaves the gun, takes the cannoli 
/home/action/.rvm/gems/ruby-2.0.0-p195/gems/rack-1.5.2/lib/rack/handler/thin.rb:1:in `require': cannot load such file -- thin (LoadError)  
  from /home/action/.rvm/gems/ruby-2.0.0-p195/gems/rack-1.5.2/lib/rack/handler/thin.rb:1:in `<top (required)>' 
  from /home/action/.rvm/gems/ruby-2.0.0-p195/gems/rack-1.5.2/lib/rack/handler.rb:20:in `const_get'  
...elided for brevity...

BLAM!

Oh my lord I'm a dummy. Look at the Gemfile:

# Server requirements
# gem 'thin' # or mongrel
# gem 'trinidad', :platform => 'jruby'
Ok. (Hmm. JRuby would be interesting to test... :-)
Uncomment thin and bundle install and try again:

action@kimbo-review-99999:~/workspace/kimbo$ padrino start -p 3000 -e development -h 0.0.0.0 -a thin  
WARN: Unresolved specs during Gem::Specification.reset:  
  rack (>= 1.0.0, ~> 1.4)  
  activesupport (>= 3.1.0) 
WARN: Clearing out unresolved specs. 
Please report a bug if this causes problems. 
=> Padrino/0.11.2 has taken the stage development at http://0.0.0.0:3000 
>> Thin web server (v1.5.1 codename Straight Razor)  
>> Maximum connections set to 1024 
>> Listening on 0.0.0.0:3000, CTRL+C to stop 
Check preview again and we see the "Sinatra doesn’t know this ditty." which is fine.

Ok. We have got somewhere.
Just because I'm cantankerous, I always enable development and test logging 'my way'.
If you want to do this, edit your config/boot.rb and add this:

Padrino::Logger::Config[:development] = {
  :log_level => :debug,
  :stream => :stdout,
  :format_datetime => '%Y-%m-%d %H:%M:%S'
}
Padrino::Logger::Config[:test] = {
  :log_level => :debug,
  :stream => :stdout,
  :format_datetime => '%Y-%m-%d %H:%M:%S'
}
I normally adjust the format of the output as well, but I won't bore you.
For the record, I also uncomment the I18n.default_locale = :en line.

One thing I need to mention is the font. Why can't I change it?
I know I'm old and have bad eyes, but I prefer a MUCH smaller font to get a better view.

I found that the in browser editor gets it 'almost' right - curlys don't line up the way I like.
I also noticed that when you click on the language button or soft tabs button you have to re-click the button to get the menu to go away.
Clicking in the editor window doesn't do it.
In fact, ALL buttons have this behaviour which I find personally irritating.
You may feel different and that's fine.
I'm spoiled I guess using IDEs like RubyMine.

No I tried the 'chat' mode with Ben (who is downstairs writing a non-technical review) and up came a 'Collaborators' popup.

"This feature is experimental"

Ah. But heck, I'll try it. So I typed in his email and the first part worked.
To get your collaborator to have editing on a file, you open it in your editor and click the 'Collab Mode' button.
Neat. It's experimental - YMMV.

Ok. One thing I noticed is that there is no config/database stuff.
Now while clicking about on the menus I saw the following options on the 'Connect' menu: 'MongoDB (MongoLab)' and 'PostgreSQL (Heroku)'.
These point to help pages with extensive details on how to get connected to them, so I won't go into it in detail.
You'll have to install the ORMs etc and configure them yourself of course.

One niggle: when on the 'Connect' pages, it's tempting to click the 'Help Center' button at the top.
Unfortunately, this is a href to the page you're on.
Not helpful.
So if you want to go to the actual help center, you'll have to use http://help.nitrous.io
The Help Center is well laid out and easy to navigate but does have some

Conclusion:

Frackin love it. It has quirks but is just a development environment. Ben tried it on the iPad and apart from not listening to attached keyboard commands it worked just fine.

You *could* run up NGinx or Apache2 on your box and have a 'stage/production' environment, but if you are using Heroku or ilk, why bother?
You *could* install MySQL or CouchDB or whatever locally. I didn't try it.
Does it violate some part of the acceptable terms or policy?
Can't see anything on the help center about this.
Need to read a bit more.

Just a point... If you're just using the system as a development environment, why would you need a box with 2Gb memory and 20Tb (Correction 20Gb - been in the big data world too long) of storage just for development? At $89.95 a month this seems over the top. There is an implication (for me) that if you're paying $90 a month you would expect to be able to install extra packages and use the box at least as a staging if not production server.

There are some quirks.

If you use git (you do use it right?) then it's cmdline only.
Maybe they'll add it to the menu to allow issue/branch/merge/commit/push like RubyMine but I'm ok with the cmdline.

Also a website oddness. Once you've gone to the https://www.nitrous.io/app once, you can't seem to get back to the main site at http://nitrous.io - you just keep getting redirected to your app boxes page. Browser issue? In any case it's annoying.
I had to open a new 'incognito' window to get to https://www.nitrous.io/pricing.

There are a few spelling errors and what not, but we're all developers right?

Deployment

Heroku integration
Deplying to Heroku

`Deplying`?

Also I have to say that when I followed the link for connecting to GitHub, I saw the authorize page:
"Authorize Nitrous.IO?
The app Nitrous.IO will be able to:
Read your public information.
Update your user profile.
Update your public and private repositories (Commits, Issues, etc)."
Wait. Update my public information? Make *ANY* change to my public and private repos? How do I authorize that from GitHub to stop someone hacking Nitrous and getting access to my repos? Hmm. Kinda facebookie. Scared to enter my details on that one. Same for LinkedIn. Although I'm obviously trusting GitHub and LinkedIn to not get hacked...

Oh! I forgot: READ THE:

'Acceptible use policy' (http://help.nitrous.io/admin-aup/) especially the 'Quota & Limits' part.

'Terms of use' (http://help.nitrous.io/admin-terms/) especially '8. License from You'

But I love it.
I'll use it.
It won't replace RubyMine, but it's not supposed to.
It's to allow project development anywhere not just on your local desktop.
ChromeBook on the train home anyone?

I give it 5 pings.

FYI: You can get me extra N2O by following this link: https://www.nitrous.io/join/CL9mwvyYmwY

UPDATE: I was discussing my post with Ben and something occurred to me. How would this work with teams? I could easily see that a sole developer (or a duo) would find the system fantastic to work with. But with teams? Here's a simple example:

Ben and Kim are developers. Let's say Ben creates a box to work on. He creates an app. Kim wants in. How does that work? She has access to the box as per http://help.nitrous.io/collab/ but does she start a new instance of the app so she can work on it? How does it fit together when you may have dozens of people working on a project? They each have a Nitrous account, and the IDE open, but do they all have a WEBrick (or Thin - whatever) running? And since it's in development mode, won't changes Ben makes to the code get reloaded by Kims instance of WEBrick? They may be silly or just plain invalid questions, but I need to play with that to answer the question fully. Another post.

Tuesday, 18 June 2013

Moose the foster cat likes to Chill-Ax...

Moose the foster cat has some quirks.
One is his habit of sitting in what seems to me to be uncomfortable positions.
Here's one:


Odd no?

FYI while I was typing this, he jumped up next to the keyboard and tried to chew my glasses.
While I was wearing them.
I also now have fur up my nose.

OS X Crayon Color Hex Table

I've been doing dozens of wireframes recently using OmniGraffle.
Which, I might add, is very useful for this.
To help me along, I've been using some stencils:

  • jQmobile
  • iPhone 5 UI
  • Mobile - iPhone
  • Best Practice UX Forms Stencil v2.0
  • Ultimate iPhone

All pretty cool.

But when I came to actually creating some of the layouts to HTML and specifically CSS, I found getting the colors from the Color Picker crayons to hex values was irritating. I did try ColorPicker from RubiCode.com, but in the end I just built a table.

For my reference and for anyone else who needs a visual representation of those crayons I put this together:


Cayenne
#800000

Clover
#008000

Midnight
#000080

Tin
#7F7F7F

Asparagus
#808000

Teal
#008080

Plum
#800080

Nickel
#808080

Mocha
#804000

Moss
#008040

Eggplant
#400080

Steel
#666666

Fern
#408000

Ocean
#004080

Maroon
#800040

Aluminum
#999999

Marascino
#FF0000

Spring
#00FF00

Blueberry
#0000FF

Iron
#4C4C4C

Lemon
#FFFF00

Turquoise
#00FFFF

Magenta
#FF00FF

Magnesium
#B3B3B3

Tangerine
#FF8000

Sea Foam
#00FF80

Grape
#8000FF

Tungsten
#333333

Lime
#80FF00

Aqua
#0080FF

Strawberry
#FF0080

Silver
#CCCCCC

Salmon
#FF6666

Flora
#66FF66

Orchid
#6666FF

Lead
#191919

Banana
#FFFF66

Ice
#66FFFF

Bubblegum
#FF66FF

Mercury
#E6E6E6

Cantaloupe
#FFCC66

Spindrift
#66FFCC

Lavender
#CC66FF

Licorice
#000000

Honeydew
#CCFF66

Sky
#66CCFF

Carnation
#FF6FCF

Snow
#FFFFFF


For reference, here is the CSS used for the above table for your cut-n-paste convenience:

.Cayenne { background-color: #800000; }
.Asparagus { background-color: #808000; }
.Clover  { background-color: #008000; }
.Teal  { background-color: #008080; }
.Midnight { background-color: #000080; }
.Plum  { background-color: #800080; }
.Tin  { background-color: #7F7F7F; }
.Nickel  { background-color: #808080; }
.Mocha  { background-color: #804000; }
.Fern  { background-color: #408000; }
.Moss  { background-color: #008040; }
.Ocean  { background-color: #004080; }
.Eggplant { background-color: #400080; }
.Maroon  { background-color: #800040; }
.Steel  { background-color: #666666; }
.Aluminum { background-color: #999999; }
.Marascino { background-color: #FF0000; }
.Lemon  { background-color: #FFFF00; }
.Spring  { background-color: #00FF00; }
.Turquoise { background-color: #00FFFF; }
.Blueberry { background-color: #0000FF; }
.Magenta { background-color: #FF00FF; }
.Iron  { background-color: #4C4C4C; }
.Magnesium { background-color: #B3B3B3; }
.Tangerine { background-color: #FF8000; }
.Lime  { background-color: #80FF00; }
.SeaFoam { background-color: #00FF80; }
.Aqua  { background-color: #0080FF; }
.Grape  { background-color: #8000FF; }
.Strawberry { background-color: #FF0080; }
.Tungsten { background-color: #333333; }
.Silver  { background-color: #CCCCCC; }
.Salmon  { background-color: #FF6666; }
.Banana  { background-color: #FFFF66; }
.Flora  { background-color: #66FF66; }
.Ice  { background-color: #66FFFF; }
.Orchid  { background-color: #6666FF; }
.Bubblegum { background-color: #FF66FF; }
.Lead  { background-color: #191919; }
.Mercury { background-color: #E6E6E6; }
.Cantaloupe { background-color: #FFCC66; }
.Honeydew { background-color: #CCFF66; }
.Spindrift { background-color: #66FFCC; }
.Sky  { background-color: #66CCFF; }
.Lavender { background-color: #CC66FF; }
.Carnation { background-color: #FF6FCF; }
.Licorice { background-color: #000000; }
.Snow  { background-color: #FFFFFF; }

Thursday, 13 June 2013

The latest foster cat "Moose" has arrived

Moose (3yrs old) needs some quiet time to recover form ear mites. And what a surprise! Either by accident or breeding he has half a tail! The curious thing is that I don't have those subtle indicators of mood based on tail language. It's only been two days though so some learning has to be done.

And he SOOOO wants to get outside. I guess he was a outdoor cat in his previous life.

Totally affectionate, chatty and incredibly strong. Just a ball of muscle. When you get head butted, you REALLY feel it.

And he 'understands' sliding doors. My office upstairs has a closet with two sliding doors. I closed them. Later I went looking for him and one door was open. Thinking I had not closed it properly I closed it. "MEEEOOOOWW" Oh. He was in there. So I got him out and closed the doors. Later I went upstairs to check my previous FB status in. And one of the sliding doors was open! And guess who was peeking out? I actually caught him opening a sliding door yesterday, but couldn't video it as I was in the bathroom and didn't have my phone. I'll try to get some video of him opening a door when I can.

Some photos:

 

 

Wednesday, 12 June 2013

MySQL: "Truncated incorrect DOUBLE value" issue

Man oh man this had me going for quite a while.
Guess I must be getting old.
Anyway, I have a rails site that uses ActiveRecord to a MySQL db.
One table has two columns that are integers, but have to be unsigned as they hold values > 2147483647.
(See http://dev.mysql.com/doc/refman/5.5/en/integer-types.html for more detail)
Anyway, the insertions went just fine.
An example output of the table structure and last few rows is as follows:

mysql> show columns from ranges;
+-----------+------------------+------+-----+---------+----------------+
| Field     | Type             | Null | Key | Default | Extra          |
+-----------+------------------+------+-----+---------+----------------+
| id        | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
| starts_at | int(10) unsigned | NO   | PRI | NULL    |                |
| ends_at   | int(10) unsigned | NO   | PRI | NULL    |                |
| iso3_code | varchar(50)      | YES  |     | NULL    |                |
+-----------+------------------+------+-----+---------+----------------+
4 rows in set (0.00 sec)

mysql> select * from ranges order by id desc limit 5;
+--------+------------+------------+-----------+
| id     | starts_at  | ends_at    | iso3_code |
+--------+------------+------------+-----------+
| 126602 | 4278190080 | 4294967295 | ZZZ       |
| 126601 | 4261412864 | 4278190079 | ZZZ       |
| 126600 | 4244635648 | 4261412863 | ZZZ       |
| 126599 | 4227858432 | 4244635647 | ZZZ       |
| 126598 | 4211081216 | 4227858431 | ZZZ       |
+--------+------------+------------+-----------+
5 rows in set (0.00 sec)

My code gets a value and does a search for the row that includes that number.
So if for instance I want the iso3_code for value 4261412864:

mysql> select * from ranges where starts_at >= 4261412864 
order by starts_at limit 1;
+--------+------------+------------+-----------+
| id     | starts_at  | ends_at    | iso3_code |
+--------+------------+------------+-----------+
| 126601 | 4261412864 | 4278190079 | ZZZ       |
+--------+------------+------------+-----------+
1 row in set (0.00 sec)

The problem was the generated SQL from ActiveRecord shown below:

SELECT `ranges`.* FROM `ranges` WHERE ("starts_at" >= 4261412864) 
ORDER BY `id` LIMIT 1

In the code I got a nil row set.
My first thought was: WTF?
So I cut and pasted it into the mysql command line and saw this:

mysql> SELECT `ranges`.* FROM `ranges` WHERE ("starts_at" >= 4261412864) 
ORDER BY `id` LIMIT 1;
Empty set, 1 warning (0.00 sec)

Wait. Warnings?

mysql> show warnings;
+---------+------+-----------------------------------------------+
| Level   | Code | Message                                       |
+---------+------+-----------------------------------------------+
| Warning | 1292 | Truncated incorrect DOUBLE value: 'starts_at' |
+---------+------+-----------------------------------------------+
1 row in set (0.00 sec)

What? DOUBLE? But the column starts_at is an integer...
So I started changing column types, and generally wasting my time for a couple of hours.

To cut a long story short it's programmer blindness.
It's obvious in retrospect.
The select statement is incorrect and I was interpreting the warning incorrectly.
I assumed the message referred to the column starts_at.
Nope.
What the select where clause is actually saying:
"Oh. You want rows from ranges where the string 'starts_at' has a value that is greater or equal to 4261412864. Er. Ok. I'll try to cast the STRING 'starts_at' to a DOUBLE and then do a comparison. Er... Ok. That didn't produce any rows and by the way I tried to cast that STRING to a double and failed."
Dammit.
So I looked at my code (simplified of course):

range = Range.where('"starts_at" >= ?', val).order(:starts_at).first

Oh how could I have been so dumb?
Quick change to test:

range = Range.where('`starts_at` >= ?', val).order(:starts_at).first

And all is fine.