01.14.08
Posted in Example Code, CSS at 12:05 pm by mike
A few posts ago, I mentioned how I had implemented a different flavor of html tabs in an application I’m working on. Instead of doing a walk through, like I had been planning on, I just decided to get the code out there in the real world, as I’ve been very busy lately. First of all, you can view my demo. These tabs give another way to emphasize the selected tab, by changing the heights of the unselected tabs to be shorter. It also gives the ability to hover over an unselected tab to see more of its contents. This gives the feeling of thumbing through tabs.
So far I’ve tested this in Firefox and IE7 (Safari support coming soon, hopefully).
I’ve made the source and images available for easy download.
A few things to note about the styling of these tabs:
- I’m using transparent PNGs for the shadows, so they aren’t particularly friendly with IE 6 without the PNG patch (not included).
- The height of the image files is important. Because the tabs become partially hidden, the relative position of the bottom shadow is measured from the top of the tab. So when the height of the tab is changed, the height of the shadow image should be changed as well.
- The tabs are actually hidden more than I would do on a normal site. This is simply to demonstrate how well it works, and how hidden the tab can be. For normal use, I suggest only hiding about 4 to 5 pixels, depending on padding.
I hope everyone likes how these work. Comments and feedback are always appreciated.
Permalink
01.01.08
Posted in Uncategorized at 5:14 pm by mike
Happy New Year’s everyone! Since New Year’s Eve is my birthday, the new year always has a special meaning to me. Along with the new year, I get a new age. But this year means the beginning of the next chapter in my life. I finally graduated from college last month, and I begin working full-time at my job tomorrow morning. So after 23 years, it finally feels like my life is beginning. I’m anxious to start my new job, and to move to the cities and my new apartment. It’s a very exciting time for me.
Permalink
12.04.07
Posted in Uncategorized at 9:47 am by mike
Finally I have my blog back online. I transfered my domain to Linode because I finally decided to use a big-boy web host for my Rails applications. I’ve figured out how to get my own website running on an Ubuntu install, but unfortunately I somehow can’t get PHP to work, so I’m still using Dreamhost for this blog.
As far as school goes, I’m a mere two weeks away from being a college graduate. It’s very exciting. I’m not too worried about finding a job as I was hired by Champ Software; and as their lead designer of all things! I’ve been working for them since shortly after I met a few of their developers out in Portland for RailsConf. I now have a full-time position waiting for me after I graduate.
During my time with Champ, I’ve helped them make a few changes to the overall flow and look of their application. One feature that I’m very proud of that I implemented on their site was their tabbed navigation. “Tabbed navigation? But tabbed navigation is everywhere? What’s the big deal about that?” I hear yourself asking. Well the tabs that I developed make it a little easier to spot the active tab. Currently the few ways that active tabs are indicated usually include making the active tab the same color as its content, or graying out the inactive tabs. The method I’ve developed goes farther and partially hides the inactive tabs. I plan on doing a write up on the details of how to do this, as I’ve been given permission to share this work with the rest of the world. Stay tuned…
Permalink
09.11.07
Posted in Rails at 4:20 pm by mike
I had a number of people (2 is a number) asking for help in the last week about nesting includes in their find statements. So I decided I would share my long experience with these often confusing, yet so rewarding, include statements.
2 years ago when I wrote my first Rails app, I knew somewhat about the include option in the find method. But I knew only how to include a table only one jump away. This is documented in the API. But what if you want to include a table two tables away? If you were like me, you couldn’t find the answer, got confused, and went back to using SQL like you’re comfortable with. Here’s how my models were set up:
class InventoryLine
belongs_to :item
belongs_to :swap
end
class Swap
belongs_to :person
has_many :inventory_lines
end
class Item
belongs_to :person
has_many :inventory_lines
end
class Person
has_many :swaps
end
So for me to include everything I had to do this:
@inventory_lines = InventoryLine.find_by_sql("SELECT *
FROM inventory_lines
left join swaps on inventory_lines.swap_id = swaps.id
left join items on inventory_lines.item_id = items.id
left join reps on swaps.rep_id = people.id...)
Later I learned that I could have used :joins => to include all of those joins with a normal Rails finder, but that isn’t the best answer either. You’ve already spent all of the time setting up your models to have relationships with each other using has_many, belongs_to, etc. Why would you turn that beautiful Ruby code InventoryLine belongs_to :swap into ugly SQL left join swaps on inventory_lines.swap_id = swaps.id?
Most people do that because they don’t know what’s available to them. This is in part to a few hints missing from the API. What isn’t in the API is the fact that you can use hashes, in combination with arrays, to join tables through other associations. If an table is connected to your object through another table, create the association by using a hash. e.g. {:first_table => :second_table}. So now that we know that, and we already know how to connect to a table only one association away (just stick it in an array), my last statement becomes:
@inventory_lines = InventoryLine.find(:all, :include => [{:swap => :person}, :item])
Isn’t that much nicer? Here, :swap and :item are directly related to my InventoryLine model, so they belong in the array, or first element of a hash, for the :include.
Now it’s time to make things even more complicated. If you’re like me, some of the subtleties of Rails can be missed thanks to the fact that Rails makes things so transparent. What if I have a model that has two relationships, and both of those relationships point to the same model? This is the problem that occurred when I realized that my Swap model had two People: a Source and a Destination. So my Swap relationship had to change:
class Swap
belongs_to :person
belongs_to :source, :class_name => “Person”, :foreign_key => :source_id
belongs_to :destination, :class_name => “Person”, :foreign_key => :destination_id
end
Now if I want to include everything in a find statement, I have to reference the relationship name.
@inventory_lines = InventoryLine.find(:all, :include => [{:swap => [:source, :destination]}, :item])
<update date=”1/23/08″>
On the other side, I need to update the relationship between the Person model’s relationship with InventoryLines to reflect the change above.
class Person
has_many :swaps
has_many :swaps_as_source, :class_name => “Swap”, :foreign_key => :source_id
has_many :swaps_as_destination, :class_name => “Swap”, :foreign_key => :destination_id
end
This gives me the granulated control that I need when dealing with determining the swaps a person has been involved in. They can be involved in a swap as either the source or the destination, and this more clearly spells out to me which relationship is which, even though both relationships involve the same model.
</update>
This is what finally opened my eyes to what’s going on behind the scenes. When doing an include, I used to think that I was referencing the table name, in much the same way that you set up the has_many and belongs_to relationships for a model. But it turns out that you have to set up the reference in exactly the same way as in the model because you aren’t referencing the table, you’re referencing the relationship. Convention over configuration
is great most of the time. But occasionally you’ll run into exceptions, like the one above.
Permalink
09.10.07
Posted in Uncategorized at 8:11 am by mike
The Rails Rumble is over! What a weekend. I really enjoyed my time with Chris, Ian and Ned this weekend. I think we all had a pretty good time at the Rumble. I’m just a little dissappointed in the final state of the project. We all had things we had to do yesterday, so we had to call it quits around mid-afternoon, which means we didn’t get a lot of the core functionality done. But we have talked about continuing development on our own servers. I think we have a pretty decent idea here, and I would like to see it go somewhere. Check out iCanHazTrofy.com for updates.
Permalink
09.08.07
Posted in Uncategorized at 10:29 pm by mike
Oh, rumble. That’s it. I’m sitting outside in front of a fire at 11:00 on a Saturday night programming for out Rails Rumble project. I’m working with Chris, Ian and Ned. We’re making a website for people to go and register their Christmas wishlists for sharing with their families, or any groups they belong to, in order for others to see what they want. Also, anyone who register’s in a group can choose to use our Secret Santa method, which will set up everyone in the group with a secret santa. We will also allow charities to register wish lists for underprivileged families, similar to Adopt a Family or other programs. It will be available at elflist.us.
Permalink
08.28.07
Posted in Uncategorized at 9:45 am by mike
I’m really excited right now. I just bought a new car this past weekend and I am absolutely in love with it. It’s a 2003 VW Passat. Manual of course (I’m such a control freak). It took about 2 weeks of searching to find this one, but it was very worth it.
In other news, I’m looking through my Word Press account and I’m realizing that I’m writing a lot of blog posts that I’m not posting. For those of you who haven’t heard of him, Ze Frank is a “content creator” who for a year made quick video posts almost every weekday. He was the one who coined the term “Brain Crack,” referring to those ideas you come up with and work on and just let sit without ever letting it actually see the light of day. It could be because you’re afraid to share it with the world, or you just want to keep working on until it’s perfect. Unfortunately nothing is ever perfect, so sometimes you just need put it out there and let others decide. I need to remember that.
Also, this is my last week at Web Dev. It’s bitter sweet. I’ll have more time to work on other projects, but I’ll miss hanging out with the people here. At least I’ll still be able to drop in and bug everyone once in a while
Permalink
08.20.07
Posted in Uncategorized at 9:41 am by mike
I just got back from a trip to Milwaukee after visiting my cousins this weekend. I went with Kaley, and we all had a really good time. Friday night we stayed at Danny’s house and went out for a few drinks at the local bars in Port Washington. I had visited him at his house before, but never actually saw the rest of the town. I was actually impressed at how nice it was. He’s less than a mile away from the lake, yet I never knew this or knew what was around him. It had a very pretty marina and a great view from its parks of the lake. I look forward to visiting again.
The next day we went down to Milwaukee to see my cousin Sam at his apartment. After that, we all went to the Brewer’s game. The game was amazing! I was so impressed by the stadium. It makes me wish I lived in Milwaukee just so that I could go to more games at Miller Park. The stadium was just massive. And I loved being at a place where I was rooting for the same team as everyone else. And it was even better to see a win! I don’t think I’ll ever go back to a game in the Metrodome. The only problem was that it was raining that day, so we had to walk from our car to the stadium in the rain. But at least the stadium has the closable roof. It would have been nice to see an outdoor game, but it was a whole lot better than getting rained on.
The next day my cousins had plans, so Kaley and I just went to Bay Shore mall for lunch before getting on the road to go back home. All in all it was a fun weekend. I’m looking forward to the next time Sam, Danny and I get to hang out again.
Permalink
08.02.07
Posted in Uncategorized at 10:46 pm by mike
So yesterday started out as a very good day. I didn’t go to bed the night (morning) before until 5 am, so I planned on sleeping in to get caught up on sleep. However Kaley had other things in mind as she woke me up when she called me around 10 to tell me that she finally got her job that she applied to months ago. She applied for an HR position at Fort Snelling back in May (I think) and just yesterday did she finally get a letter saying that she could start working Monday. For those of you counting, that’s at least 4 months that she’s been waiting for this job. So I was very excited for her when she called me and told me that she finally got a starting date for her new job. That same day I got a nice raise from the MyDecisionHelper project. Which is great, other than making it harder to choose which project I want to work on. That was my Ying. Then came the Yang.
Later that afternoon I tried to call Kaley just to chat for a few minutes. The problem was I couldn’t get through to her. I knew something had to be happening if the cell phone calls weren’t getting through. I then checked the news on CNN and saw that the bridge in Minneapolis had collapsed. I couldn’t believe what I was seeing. For everything good that seemed to happen yesterday, it did end pretty badly. Thankfully no one that I know was affected, but it’s still a tragedy. I hope that everything will be ok from now on…
Permalink
07.30.07
Posted in Work, Time Management at 8:08 am by mike
If there’s anything that I’ve learned this summer with my 5 separate projects, it’s time management. Any article/book/old timey pamphlet on time management will tell you the importance of using a calendar to keep track of appointments and such, but I have to say that using Google Calendar’s has been huge in helping me to stay sane amongst 60 work weeks. I use my calendar for tracking what time I should be working on what project, as well as what time I actually worked on a project. The latter has been great for helping me fill in my time sheets/bill my hours at the end of the week.
Because I am working on a variety of projects, it is important for me, as well as the people I’m working for, to know exactly when I’m planning to put in time for each project. Plus it tells me when I’m not supposed to be working, specifically weekends, as I set this aside as me time in order to balance work and personal life effectively.
But my most used feature of Google Calendars is having multiple calendars together. So I can see what I have scheduled personally, as well as having another calendar for my schedule, and yet another calendar for the hours that I actually work.
Permalink
« Previous entries ·