How to connect Ruby on Rails and a IOS app

Interesting alpha version of a new book for Ruby developers wanting to use a IOS fronted:

iOS on Rails (Beta)
The reference for writing superb iOS apps with Ruby on Rails backends.
Once it comes out of Beta, this book will sell for $39. Get it now for just $29.

Read a free sample
This book is really two books in one.

The the first book covers building a backend API in Rails. We will demonstrate how to create a robust, clean, flexible JSON API. Along the way, we’ll discuss different approaches that we didn’t choose and discuss their drawbacks.

[From thoughtbot Learn : iOS on Rails (Beta): a book by thoughtbot]

Firehose realtime web application framework

I will have to investigate this one tonight :

Firehose is a minimally invasive way of building realtime web apps without complex protocols or rewriting your app from scratch. Its a dirt simple pub/sub server that keeps client-side Javascript models in synch with the server code via WebSockets or HTTP long polling. It fully embraces RESTful design patterns, which means you’ll end up with a nice API after you build your app

[From Firehose | Build realtime web applications]

Ruby – running a shell command with a timeout

This was a lifesaver – as it took me quite a while to find out how to terminate a subprocess in Ruby properly.

I was trying to run a script from a Ruby program, but occasionally (every few hours) the script would fail and not return, leaving my program locked.


# Runs a specified shell command in a separate thread.
# If it exceeds the given timeout in seconds, kills it.
# Returns any output produced by the command (stdout or stderr) as a String.
# Uses Kernel.select to wait up to the tick length (in seconds) between
# checks on the command’s status
#
# If you’ve got a cleaner way of doing this, I’d be interested to see it.
# If you think you can do it with Ruby’s Timeout module, think again.
def run_with_timeout(command, timeout, tick)

How to simplify development with RubyMotion

This looks interesting – as I have RubyMotion (and as I am on holiday this week) I may just have to give this a try.

UnderOS (or shortly uOS) is a project that aims to build a web-browser like environment on top of RubyMotion so you could build native iOS apps while keeping your web-developer’s habbits.

[From Untitled]

Accessing the i2c bus on a Raspberry Pi using Ruby – part 2

To start using the Pridopia 24*16 LED matrix daughter board for the Raspberry Pi I found this on GitHub and cloned it to my own repository.

I found one bug which meant that all rows were displayed with a offset – fixed this, and started adding code to display on more than on 8*8 module – made slightly more difficult by a couple of small bugs in the original code, but I have uploaded a new (working) library here.

This is not of production quality yet – but the library module works – just need to update the tests. Then I need to make the code a lot more elegant than it is.

Decoding CUL messages using Ruby

I’m getting a little bit of time to look at my CUL decoding – and am now getting :

201302212043.jpg

the last 2 messages are intercepted from my home automation systems – there are 2 wireless relays in the house, with FS20 addresses 56 and 57, one is turned off and one is turned on by these commands.

The first line shows that the actuators for the living room radiators is 3% open – i.e. hot water is just barely reaching them to keep the temperature in the room stable at the moment.

Reading your Air Quality Egg data from COSM in Ruby

And here is the very short program for reading your AQE data as a JSON stream from COSM

require ‘cosm-rb’

require ‘pp’

require ‘json’

COSM_API_KEY = ‘USE YOUR API KEY FROM THE DASHBOARD HERE’

FEED_ID = XXXXX # your feed id

response = Cosm::Client.get(“/v2/feeds/#{FEED_ID}.json”, :headers => {“X-ApiKey” => COSM_API_KEY})

stream_name = response[‘datastreams’][0][“id”]

Easy isn’t it?