Finally Improving My jQuery

Taking a break from rails tonight to go through the peepcode video on jQuery. The advice I had from a pal is that jQuery is easy and separate enough from javascript that it can be learned by itself. I’m not certain I agree just right now, but it’s definitely a big eye-opener.

The big take home point for beginners here seems to be learn the following:

$()

is a wrapper function. It serves mainly to take an argument, and make a jquery methods available on that argument. For example:

$("#someId")

will wrap the someId element on a page inside jQuery and make jQuery methods available:

$("#someId").fadeOut

The other thing is that you’re going to be doing a lot of finding elements, so learn your bloody selectors! The jQuery documentation on selectors contains a bunch of jQuery specific stuff. Otherwise, I’ve been mostly learning them via writing selenium automation tests at work. 

I have a ton of documentation to research on test the rails view for a talk I’m leading tomorrow. Wish me luck!

 

 

Finally Improving my Rails

I’ve known bits and bobs about rails for years, but I’ve never sat down and tried to force myself to be a front-to-back rails developer. It seems weird to say that, because I’ve actively loved the ruby language for years and rails has been something I’ve made a living from supporting before, but my jobs have pulled in non-rails directions (windows, perl, learning vmware, networking, linux systems administration, more perl, more vmware, then lots of security and networking). Combine that with a wonderful relationship, lots of independent interests and it’s been hard to get time together to sit down and focus on rails by itself.

I’m newly single, though, and slimming down my interests a little and I’ve got time to be pursuing some stuff I’ve had on the back burner for a long time. The first of these is forcing myself into learning rails more thoroughly, from soup to nuts.

I’ve had a few ideas for a trouble ticket application to help at work, so I decided to start by making a simple rails app that will track tickets. Each ticket is an idea I’ve had for improving the app itself, so it’s useful from day one and immediate utility tends to keep the interest.

My immediate problem stems from having written a simple test:

test "Only high priority items are returned." do
tickets = high_priority_tickets
tickets.each do |ticket|
assert(ticket.priority =~ /^high$/)
end
end

I’m making the assumption here that I can write some method high_priority_tickets which will return all tickets with a priority of high. I don’t know where to put it, though!

I’m making the bet that it goes in the model for two reasons:

  • the model provides data for the controller/view
  • unit tests in rails are designed to test the model, integration tests are designed for the controller (c.f. http://guides.rubyonrails.org/testing.html)

Still, it’s these kinds of small decisions I’ve not had to make before. It’s exciting getting to see my own rough edges.

conway update

I got half way into Conway and haven’t picked it back up yet. 

The first problem conceptually as that I was stuck thinking about coordinates and coordinates and how does a cell know it has a neighbour and coordinates and neighbours?!

The solution came to me while I was on the bus, going down a beautiful canyon. The cell is a class. It cares about how many neighbours it has, so that it knows whether it is alive, dead or unchanged. 

The world tracks the position of the cells. The information the cell needs is how many neighbours it has. Not its own position, not how big the world is.

I need to write  a world for my cells to live in. Then I’d like something to output graphical information to. I think an ncurses UI would be fine first.

I should upload this to github or something.

 

 

Ideas Ideas Ideas.

Well, daily coding failed as a project. I don’t know whether it’s a discipline issue, or an interest issue, but trying to come up with artificial ways to keep progressing skill can be hard.

 

I’m updating my freebsd vm. I like keeping it around as a standard platform for writing ruby and for testing my code on. If it works on mac os, deploy to FreeBSD and verify it still works. If it does, yay! Whilst doing this, I’ve been trying to come up with a program-y project.

I have a couple of ideas that I’m batting around. Log parsing, message passing over a socket, having worker drones which report back to a central reporting facility. Solved problems, sure, but ones I’m interested in solving myself. Thinking about old problems that I want to re-solve, it hit me that I can write Conway’s game of life.

The rule set isn’t hard to implement, but I’d like to have a UI element too. This means either implementing a command line output with ncurses or whatever, or bringing up a window and drawing to it. Both of which seem very cool. I may even try both.

This seems like a good idea somehow.