Saturday, March 20, 2010

RoR Currents and Tides

I had a puzzling thing happen the other day. After upgrading to Rails 2.3.5, rails was still creating projects using 2.2.3 gems.

In particular, the vendor directory had slinks to the active* components elsewhere. These were created by rails 2.2.3. I hadn's seen this before. Using 2.3.4, there was typically nothing in the vendor directory, save another empty directory called plugin. Why have a bunch of links to core rails components rather than automatically finding the gems? And so started research on the vendor dir.

I learned that vendor is used to freeze the configuration of a project by storing the dependant libs, rather than depending on systems to have the "right" version. Most articles were dated 2005 through 2007. And comments on the blog articles reflected that there were a number of different techniques/opinions on how to make configurations consistent in a project with many developers.

Then found that 2.2.3 automatically creates these slinks. Or if you use -C, the gems are copied from /usr/share/rails into vendor.

I found that "rails" changed the -d option - in 2.2.3, -D was used to specify what kind of database. In 2.3.5 -d specifies the database type. And 2.3.5 has an equivalent of -C, but is now --freeze.

So its March 2010, and in ~3-5 years option flags and the default usage of the vendor dir have changed.

And btw, what started all this is that after sudo gem install in one ssh window does not change the path to rails in a previously opened rails window...

My first takeaway is that the changes would throw me into confusion without being able to google the issues. Second is that RoR is still in a period of fast evolution and it could spell rework when upgrading even minor versions (2.2 to 2.3). I have a strong feeling that the key to being a good RoR programmer is being able to keep up with the flow and whatever gems or practices come with it. Similar to how the tide brings in fish and other stuff in the large volume of water, the RoR tide will carry an entire environment and being able to navigate it will help determine your worth as a programmer. That's my hypothesis anyway...

3.x is going to be a big one, especially for ActiveRecord changes. Most of the interface is different. The 3.2 changes look like a good design, but developers writing code today for 2.x should be aware of the changes in 3.2 to minimize rework.

Thursday, March 18, 2010

Ruby on Rails

Pretty neat system. Ruby is pretty cool as a language and Rails on top of it is very high level.

Things to learn:

Ruby language features and idioms
Rails objects and conventions
Ruby Gems - there is a lot of functionality out there.
GIT - why not have source code control for myself?
Apache - its about time.
Linux - ditto
MySQL
JavaScript
Firefox extensions
PHP
System architecture

It's all free software. Amazing how far the industry has come in the last 10 years.

Saturday, September 01, 2007

A webmaster in training

I've picked up a new job. Now I'm webmaster for our local elementary school. I have a little experience putting together simple sites, just for my own training and education. But now this is a real responsibility for an organization. Though it's only going to be an hour or two per week, it's a milestone. Of course this is all volunteer work, no pay for this. It's a resume fill-in. Looks better than "webmaster for simple sites used for self training and education".

Other sites which are not yet public that I'm working on:

Cub Scouts for our local pack
Dentist's office
Renewable energy company (wind and solar)
Picture sharing website

It's interesting and kind of simple stuff so far. I havent made enough of a commitment to attempt anything of complexity. A commitment implies more time and responsibility, I'm not ready for that...

Friday, June 15, 2007

Solving Rubik's Cube

I solved Rubik's cube in 2 weeks. My solution is an original solution, that is I figured it out myself without help. I know that there are websites which give you move solutions, as well as cubes are sold with instructions. I purposely stayed away from these so I could unlock the secrets myself.

I got the cube two weeks ago at the google developer day. I had often played with one in the past, in fact ever since they came out back in the 70's. But I had never tried very hard to find a solution because I didnt have the patience to do any work. Over the years I found people here and there who had solved it and wondered what insights they had to crack such a confusing puzzle. I decided that I would figure it out this time, and on my own.

First I solved one side. Everyone ends up being able to do this in some way, often without realizing the rotations needed to get there. Then I tried to solve the second row. This was difficult and I failed. Then I decided that I needed to review the moves needed to solve first side and start learning how the cubes moved. My hypothesis was that there were patterns which could be learned and used later for the second row.

In particular, I studied movement of just one corner piece and how to move it into the correct position. There is a set of moves to construct the row on the side (this moves a couple blocks out of position on the side), then preserve the row, then fix the blocks that were out of place, then rotate the preserved row back into place. I called this "on world" construction.

I was curious if there were other ways to solve the corner movement problem, and found that the row could be built "off world" or built on a different face, then rotated into the correct position. It turned out that inverting this move, then using the "on world" move to put the block back into place, would allow me to preserve the side, but the cubes on the second and third levels would move around. Breakthrough! Playing around with this, I found another degree of freedom, in that rotation of the bottom row between the "off world inversion" "on world" sequence would change the movement of cubes on the third level. Then I noticed that when executing "on world inversion" "off world", the second row also was preserved! This lead to the theory that the third row could be solved by making these "on/off" world moves. I practiced these moves for a while to get comfortable.

I then set out to solve the second row. This took a couple hours, but found a sequence by accident which preserved the first side, and allowed me to rotate the 4 second level cubes into place. Just lucky, but a breakthrough. I practiced this while trying to figure out how to attack the third row.

There are 8 cubes on the third row and they all moved positions and rotated when doing the on/off world sets of moves. I finally broke down and started writing down how the cubes moved after a specific set of moves. Once I came up with the notation for two basic "on/off world" moves (A and B), I did a lot of work on paper to study their combinations, including different ordering and rotation between moves. Some patterns started to emerge, such as swapping the locations of opposite side cubes, movement of 3 corner cubes. I played with two level moves with rotations, then some 4 level moves with rotations. Unfortunately the notation I was using was confusing when trying to combine moves, so many mistakes had to be corrected. I checked my paper work by manipulating the cube. I also practiced moving the cubes and tried recognizing the cube configuration to determine what pattern I should employ.

The movements of the cubes typically involved cycling 3 corners through 3 positions, then cycling 3 sides through 3 positions. Each side/corner cube would rotate. This was getting to be a lot to track. How could I quickly recognize what pattern could be used? I realized that the kids on youtube who solve Rubiks cube in < 3 minutes must be recognizing simpler patterns to solve things more quickly. Using my method, trying to recognize a pattern and trying a couple of A/B moves could take 20 minutes. I decided that I needed to do more paperwork and find simpler moves. If there were a set of moves which would change only one or two cubes at a time then the cube could be solved systematically.

At this point I started to use the computer to record my work. My notation had become too error prone, diagrams of 9 cubes and arrows showing movement. I decided to number the corners 1-4, and the sides 1-4, then laid them out on a spreadsheet. The position transformations were easy to show in excel, and combinations amounted to copying at row. I decided that I would not record rotations of the individual cubes yet. But I did figure out that rotations of the entire cube between transformations could be easily done by shifting the starting column of the transformation. The last breakthrough happened here.

I found that an A+A(counterclockwise) move would preserve the positions of all the cubes in the third row, but would apply a ccw rotation to 3 corners and flip 2 side cubes. I thought that if I moved the cubes into position, perhaps I could use this move to turn them around and around and solve the puzzle. This turned out to work!

Since yesterday, I've solved the cube 4 or 5 times. It takes about 30 min at this point, but I'm getting faster. I've decided that I need to finish the notation in excel, and perhaps I can find other moves which will simplify the number of moves needed. I'd also like to code up the solution and post it, perhaps as a google gadget. In any case, I can finally say that I've found a solution on my own!

Labels:

Thursday, August 31, 2006

Busy

It's been 1 and a half months since I've been officially out of work. It seems like I've been off for a lot longer though, and I'm enjoying every second. I'm very busy.

Researching business ideas, playing classical guitar, running up to 10 miles a week, studying foreign languages, spending time with the family and travelling. And studying automotive repair.

At first I was feeling quite guilty about being laid off. Why me, why wasnt there another assignment? Did I do something wrong? Then I realized that the job I was in was a lot of stress, not much potential for success. Lots of smart guys at work are being exploited. And there are less stressful ways to make a living. I've talked to several people in the last 2 months who make equal or more than I did and have to work less with less stress.

In the end I have to admit that the old job was good to me for the benefits it provided. But it had several drawbacks such as long hours, lots of politics, lack of direction/leadership and in the end we never had the success that we deserved for the fine work which we put in. Conclusion: its time to explore new opportunities and move on.

Friday, May 19, 2006

Laid off at 45 years old

It's been 2 weeks now since I've been given the word that I'll be laid off. Officially my position is being eliminated by effectively closing out the division. So I'll experience perhaps one of the most character defining events in any mid life crisis, the search for a new job. At these career crossroads, the assessment of useful skills, begging contacts who I've known over the years for interviews, rejections, financial pressures and anxieties are all now laid before me to deal with.

Wednesday, August 17, 2005

It's a man's world

Currently in Seoul Korea. Had a massage today, all male sauna "club" at the top of the Prima hotel, Sauna 24. The masseuse was about 24 yrs old, Ms Cho. She spoke slowly and respectfully, while keeping an air of familiarity and intimacy. Really made me feel like I was getting special attention. The treatment was excellent, very strong and firm. Imagine a medium size young woman sitting on your back, working on your shoulders neck and back. Then going at the lower back with her hands knees and feet. Her feet were great, all over my triceps, shoulder/armpit joint, neck/shoulder area. Sorry, no touchy allowed. Very high class place. The person I went with introduced me to the owner of the YKK zipper company (yes, that's right. Check how many YKK zippers you have) and to another person who owns about 20 hotels in Korea. Each worth well over $100M. BMW's and Mercedes all over the place when we asked for valet parking of our very nice but compartively low class Hyundai Sonata. Tomorrow - bullet train to Pusan.