Archive for the ‘Computers’ Category

Living on the edge

Thursday, January 12th, 2012

So, since eating one’s own dog food is probably the best way to test the usability of an application, I have published a new version of my bus schedule viewer webapp Bus de Rennes en Ligne. It looks brand new but it really is the same as it was before (I hope). So, why the change ? Because I’m getting ready to (hopefully) even more grand changes in the future. And because it allowed me to rewrite part of it, both interface-wise, but also regarding its guts and use more tools.

So, in the following, I will give my impressions of Sass, CoffeeScript and Hogan.js. (more…)

dear google reader staff (2)

Tuesday, December 20th, 2011

Now that you have fixed this color issue, could you please fix the focus-on-controls misbehavior ? That would be nice, thanks!

Dear google reader staff

Tuesday, November 29th, 2011

Using the color yellow for the title of the current open article is a no-go. ‘kthxbye.

Rails 3.1 assets

Tuesday, November 29th, 2011

I’m generating Javascript from some CoffeeScript that has been “generated” by some ERB, because that’s the only way to get the path to assets. .js.coffee.erb ? What is wrong with you, people ?

Reading excel files in ruby: FAIL.

Monday, May 30th, 2011

So, I was given a set of Excel files that I need to transform in some way or the other. Given the target use, I want to write the script that will handle this in Ruby, but it fails in so many ways:

  • Parseexcel: Not sure if it is still maintained. Reads data sort of ok while looping rows with an iterator but not in random-access mode;
  • Roo: More pain than anything just to get is installed. Didn’t even bothered to try to make it work to access the data;
  • Jruby-poi: Apparently, the formulas that I need are not correctly (if at all) handled by this one.

Ok, thanks everyone, I think I’ll go back to CSV parsing.

Using the Rennes OpenData API

Thursday, April 28th, 2011

A few months ago, I made a small javascript page that allowed people to test the API provided by Rennes Métropole in their OpenData initiative. It only allowed using their API regarding the “Vivre à Rennes” data set and was mostly helpful if you had a firebug/web inspector kind of tool in your browser to maybe check the URLs generated and the raw results.

I rewrote entirely the javascript and display to look (and somehow act) like Google’s API explorer, with the main difference with the previous version being the ability to switch between APIs (for example, the bikes/alerts API) and versions. It also display the raw response (currently only JSON) (and the HTTP result code, but it’s not like it would help much anyway, heh!).

But it is still work in progress: the listed API are not complete, it does not handle parameters of parameters (but only a single level of parameters, which can be confusing at times), it would be nice to have a user-friendly key storage mechanism and the overall display could be better.

Rennes OpenData API explorer

deleting a file on S3 using Fog

Monday, April 11th, 2011

Because I could not find a proper example of such a simple task, I’m writing a small reminder. So, using Amazon web services to store files (S3), you have a file there that you want to delete programmatically in Ruby. A solution is to use fog which is a library to handle various tasks in the cloud with different providers.

First, you need to create a connection to the web services, by passing credentials to the constructor:

storage = Fog::Storage.new( :provider => 'AWS',
                        :aws_access_key_id => your_key_id, 
                        :aws_secret_access_key => your_secret_key,
                        :region => your_region )

The region is not mandatory but may help performances (and keeping warnings away).
Once you’re connected, you need to get the directories stored in your bucket:

directory = storage.directories.get( your_bucket )

If the bucket does not exist of for some other reason the directory might be nil, so obviously you have to check for that. Now, you have to get a reference to the file in the directories and then you will be able to destroy it:

remote_file = directory.files.get( your_path )
remote_file.destroy

Be aware that the path must not include a leading slash (as one could get by splitting a S3 URL and using the path component).

The cat is out of the bag

Wednesday, January 5th, 2011

It has been a bit more than three years, working on it on and off, that I started thinking about having the ability to consult the local bus schedule from a mobile device (at the time, a J2ME mobile). Starting from there, I worked a bit with google maps, scrapping web sites and so on. About a bit more than a year ago, I had a small working webapp allowing to edit and display bus stop positions. But last year, the city of Rennes (where I live) decided to publish all kind of data in an open way. First it was the bike leasing program, but by Fall, it was GIS and associative life data and… bus data.

In early december, I decide to scrap my existing webapp to use those official data. I had soon a new working web app that I was able to share with others as Carte et horaires des bus de Rennes. It did a few enhancements and features that look and feel nice, but I was still not reaching my three year old goal. So, instead of J2ME I settled on ObjC and I targeted my iPod Touch as device of choice, with the additional difficulty that not being a mobile phone, I could not rely on an Internet access.

By mid-december, I had a small application reading a SQLite database and displaying the name of lines, that I wrote while traveling by train. On the 28th, I had a semi-working application that I could hint in a youtube video, and one day later, I stole the grid display from another bus schedule application OpenMBTA and I was submitting my application on Apple’s appstore (“Release early, release often…”) and it was published Yesterday as Bus de Rennes en poche. Look, Ma’, I’m an iPhone developer! Sure, it is just a really basic version, but I’ll soon release an enhanced version, and so on.

Of course, both the web and iPhone application are Open Source.

Git at Breizhjug

Monday, November 22nd, 2010

Earlier tonight, I went to a conference about Git given at the local JUG and I have to say that I do not fully agree with this presentation. One of the point was that the Build Manager role is over and that people having this kind of job should start to look for something different and all power to the developers. Maybe I have a different understanding of what a Build Manager is entitled to. To me, it is the management of branches, releases, build process and the overall good wealth of a software repository. And in my opinion, unlike what was said, I think Git is a great push and revival of the Build Manager and Integration role. Notwithstanding the fact that the usage pattern he described, a central repository with almost no branching, is, I think, very un-git-y.

Think about it. What is the main example of Git usage? The Linux kernel. What is the role of Linus Torvalds? Build Manager. He doesn’t code a line (almost) but just get patches from others to integrate them in the official tree. What is the other main usage of Git? Github: You can create (or fork) a project, have people develop features and create pull requests that you integrate if you wish to, picking whatever suits you.

Git (and other DCVS probably) is the best Build/Integration Manager tool: Developers can work however they want on their own repository and be empowered by fast versioning tools while a central role can coordinate and pick whatever features are available, in order to have the best resulting software (and eliminating the risk of a developer committing and pushing everything (for backup reasons) to the master server on a friday night, including unfinished and/or broken features).

Having a central repository where everybody pushes features without any control is just a bastardized (un) distributed revision control.

Compared to my real life usage of SVN in an enterprisey usage, the main selling point of Git (and probably other DCVS) is the ability to have local branches at a nearly zero cost (for either creation or switching), not only for a feature-branching workflow but simply to have at hand the various points of the life of a software (development version, latest/current release, maintenance releases…). (more…)

Testing views with RSpec 2 and Rails 3

Sunday, November 14th, 2010

I have been using RSpec 2 with Ruby on Rails 3 recently and I had a bit of a hard time understanding how to test views with it since it changed a bit between versions (as opposed to model/controller testing) and the older ways are still the one most documented, so I thought I would write down a small self reminder.

First, care has to be taken of what code generators may produce. It is especially important if using controllers in modules. To test views with RSpec 2, the top most describe must use the path of the file. Unfortunately, some generators with modules will generate a rspec path of module_controller/view.html.erb instead of the correct module/controller/view.html.erb.

Before rendering a view, one can set the values it uses by using assign as either a function call or a hash. The rendering itself is done by simply calling render and the tests of the view can be applied, not on a response object as it is the case for the controller (or as it was the case I think with RSpec 1?) but on rendered. There, the main matcher to use is have_selector which takes a xpath expression and can use a block to do further testing on an inner DOM node.

it "should have some tag" do
  render
  rendered.should have_selector( "a[class='foobar']" ) do |node|
    node.first.text.should == "quux"
  end
end

But XPath is not really the most friendly syntax and using blocks can become tiresome. There are shortcuts for testing the text content and one can in fact use CSS expressions as a selector:

it "should have some tag" do
  render
  rendered.should have_selector( "a.foobar", :content => "quux" )
end

And one can obviously use more complex CSS expression (div.foobar #quux a).

About

My name is Sebastien Tanguy. This is my weblog. I am currently a software developer, but every now and then I also talk about music, books or photography.

 

May 2012
M T W T F S S
« Jan    
 123456
78910111213
14151617181920
21222324252627
28293031  

Archives