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.

"Random Acts" is a blog about things of interest, software, technology, religion (or the lack of it), politics and philosophy
bundle install rackup -s thin -o 0.0.0.0 -p 9292 -E development config.ru
http://0.0.0.0:9292/index.html
and start playing.├── 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
<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>
<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>
WARN - attack prevented by Rack::Protection::AuthenticityToken
DEBUG - POST (0.0035s) /api/v1/sessions/login - 403 Forbidden
Rack::Protection::AuthenticityToken
is stopping us getting in./Users/[you]/.rvm/gems/ruby-2.0.0-p0/gems/rack-protection-1.5.0/lib/rack/protection/authenticity_token.rb
.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
set :protection, true set :protect_from_csrf, true set :allow_disabled_csrf, true
// REQUIRES the authenticity token appended! var postData = $('#ProfileLoginForm').serialize() + '&authenticity_token=' + CSRF_TOKEN;
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) { } }) }
get :csrf_token, :map => '/csrf_token', :provides => :json do logger.debug 'Retrieving csrf_token' result = { :csrf => session[:csrf] } JSON.pretty_generate result end
<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>
headers: { 'HTTP_X_CSRF_TOKEN': CSRF_TOKEN },
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
sudo apt-get do-release-upgrade
for obvious reasons.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...
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.123Now 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`.
action@kimbo-review-99999:~$ uptime 02:27:42 up 23 days, 9:58, 1 user, load average: 0.02, 0.06, 0.11What? 23 days? Ah. Neat. It appears that boxes are 'pre-provisioned' and assigned a name and extras during the 'provisioning' process.
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 .zprofileOk. The
.gemrc
has good stuff in it:install: --no-rdoc --no-ri update: --no-rdoc --no-ri gem: --no-rdoc --no-riAnd the
.gitconfig
also:[color] ui = auto [alias] st = status di = diff ci = commit br = branch llog = log --date=local [rerere] enabled = trueThe
.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..ssh
folder keys are used for the same purpose (they are for action@apse2.actionbox.io
)./etc
.../etc/hosts
is interesting as it has that old 'Ubuntu 127.0.1.1' address thing going on./etc/nsswitch.conf
is minimal with the hosts
set to files dns
./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.internalWhich is curious since I configured an 'Oceania' box since I'm in Australia. Oh well.
/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./etc/init.d
folder. Mostly standard stuff and no Apache1 or NGinx.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.5Ok. 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.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.
padrino
I did a gem install padrino
and it installed very quickly!rails
gems like activerecord
were all 3.2 by the way.cd
to the workspace app and do a bundle install...sinatra (1.4.3)
and padrino (0.11.2)
.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
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=3000And the 'preview' works. Cool. Don't like the look of those gem messages, but I'll leave that for now.
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...
gem list --local
... Is it installed?action@kimbo-review-99999:~/workspace/kimbo$ which thin action@kimbo-review-99999:~/workspace/kimbo$ gem list --local | grep thinSo I was wrong. Not installed.
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 installedAnd 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...
Gemfile
:# Server requirements # gem 'thin' # or mongrel # gem 'trinidad', :platform => 'jruby'Ok. (Hmm. JRuby would be interesting to test... :-)
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 stopCheck preview again and we see the "Sinatra doesn’t know this ditty." which is fine.
development
and test
logging 'my way'.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.
I18n.default_locale = :en
line.config/database
stuff.http://help.nitrous.io
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.https://www.nitrous.io/pricing
.Deployment Heroku integration Deplying to Heroku
"Authorize Nitrous.IO?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...
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)."
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 |
.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; }
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)
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)
SELECT `ranges`.* FROM `ranges` WHERE ("starts_at" >= 4261412864)
ORDER BY `id` LIMIT 1
mysql> SELECT `ranges`.* FROM `ranges` WHERE ("starts_at" >= 4261412864)
ORDER BY `id` LIMIT 1; Empty set, 1 warning (0.00 sec)
mysql> show warnings; +---------+------+-----------------------------------------------+ | Level | Code | Message | +---------+------+-----------------------------------------------+ | Warning | 1292 | Truncated incorrect DOUBLE value: 'starts_at' | +---------+------+-----------------------------------------------+ 1 row in set (0.00 sec)
"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.
range = Range.where('"starts_at" >= ?', val).order(:starts_at).first
range = Range.where('`starts_at` >= ?', val).order(:starts_at).first