I’ve always been under the impression that keeping up with family is important.  Calling them, not necessarily my forte, but I definitely let them know what I’m doing and will go out of my way, at times, to visit family.  I don’t see it as a chore, I genuinely enjoy visiting my family. They’re always fun to be around, whether it be drinking or just chatting.  The only issue is that my immediate family is no where near me.  Most live in another state, some live in another country.  That’s just my immediate family.

When I say keep up with family, I mean all family.  That includes the family I’ve somewhat been adopted into since I’ve been dating the same person for nearly six years. Today, I visited Becky’s cousin’s son’s communion.  Lots of ways that deviates from the family tree, but let me reiterate, Becky’s Mother’s Sister’s Son’s Son’s first communion.  I think the technical term is cousin once removed, I don’t know. I’ve never been very good with how family tree structures work beyond cousin.

It was an all together pleasant occasion. People were friendly and the food was tasty.  I myself drank a bit too much wine and ended up talking shop with some fellow software people that were beyond the scope of any relationship I’m willing to try to work out.  The communion itself was fine. The priest had a long spiel about how breakfast, being the most important meal must be eaten everyday to stay strong. Likewise, since communion is important to maintaining good faith, it must be taken every week to keep up.  It was long, convoluted, involved three trays of food and the priest with low self-esteem, needless to say, it was odd.

All of this effort was in part to keep up with family. Just to see how everyone was doing and let them know where I am. I’ll do the same in about a month when I go to see my Grandparents in Alabama then again in about two months to see other side of the family.  Every single one of them will be a different experience, but that doesn’t mean that they will be any less enjoyable and everyone is just as important as the last.

@tab

I just received an email from a company called element14.  The company is one of maybe two or three official distributors of the Raspberry Pi PC.  It’s a micro computer about the size of a credit card, though considerably thicker.

The purpose of the Raspberry Pi computer is to provide primary school students with an extremely cheap computer to learn how to program on.  It’s also of course just a very cheap computer that can practically fit in your pocket.  Priced at $25 and $35 for the base RP and the RP with ethernet respectively, it’s not hard to see how this is attractive.  Especially because the foundation claims that it is capable of supporting 1080p output out of the box. All ready people have started putting things like XBMC onto the thing.  Not only does it allow for software development of almost any kind, it also has additional headers to allow hardware hackers to have a hand at it.  It seems almost necessary as a toy for someone who just want s to endlessly tinker or even one who wants a low powered (only 3.5 watts to run it) computer or server.

I’m pretty excited and so should everyone else, check it out at their website.  http://www.raspberrypi.org/

For those of you who have always wondered how to free up a Mac’s memory. For those just incredibly aggravated with consistent response from the Mac community, “Mac memory management is much better than PC,” when asked this question. As if you asked, “How does a Mac and a PC compare when it comes to Memory management?” It’s aggravating.

All you have to do is type in Terminal:

 purge 

Though this sort of sounds out of place for a programmer, but I registered for my first domain name today. Well, technically not my first, I technically bought the domain animeday.com when I was in high school when I had this unending fascination with Anime. Today, however, marks my first. I registered my username tabfugnic.com and a bunch of other TLDs. I have no clue what I’m going to do with it, so currently they just reroute to my blog that I do a terrible job keeping up to date. Either way I’m sure I’ll have fun with it, turning it into a project page or just a for funsies kinda web domain. Either way, just thought I’d share.

This isn’t going to be a really long posting on how to create and implement engines in your rails app.  This is specifically regarding the gemspec and the gemfile in a rails engine.  Within a rails engine you have a Gemfile which is used for your engine any time you need to use it as a standalone app. Then you have a gemspec which defines the parameters of your engine and the dependencies therein.  Which means engines are really just treated as big gems that can be run as standalone apps, though I guess this isn’t necessarily true.

Defining the parameters such as name, version and things like that are pretty straightforward, but the dependencies needs to be understood.  Basically anything that is labeled as a dependency is exactly what it sounds like, it is dependent on that gem.  If you are using bundler, then anytime you run a “bundle update” on the application that is using that engine will automatically install all dependencies.  Which means you don’t need to do any other leg work on the main application to get these files.  Which also means that you don’t need to explicitly declare these gems in your Gemfile in your main application, unless of course your main application needs it, that’s just good environment setup.

The only reason I write about this is that there was some level of confusion amongst some of the people working on a project at work.  We had developed three engines to plugin to our main app which more or less just acted as the intermediary between the three.  Each of those engines was developed to be a standalone app.  The thought had always been, whatever is declared in the gemspec must also be declared in the Gemfile in the main app.  This turns out not to be true.  Hope that helps.

One more fun fact.  If you have a gemspec file, you can call that file in your Gemfile and it will maintain your Gemfile from your gemspec and not have to maintain two separate files.

@tab

I ran into an issue at work today.  We have our rails site and it is separated into four distinct areas, all doing different things, but all on the same IP address.  To make sure things don’t collide, we namespace each section and reuse when necessary, a perfectly standard object oriented way to do things.  This creates a problem though. We wanted subdomains to correspond with the namespace instead of the typical rails way where the namespace would be found tacked on to the end of the URL like so, example.com/namespace/controller/action/id.

There were examples all over the internet on how to do this, or at least part of this, but many involved complex situations using a plugins or programming your own middleware to handle all this. Most of what I found required that you write a lot of code and sometimes with random results. There were a few that gave real knowledge I was able to piece together what I learned from some of those sources and found a great solution, let me explain.

Let’s say for example that you have a blog application and you have put your blog stuff in a namespace called blog. Then let’s say you have an admin section on this blog and you namespace that to be admin.  So you have links like example.com/blog/post/2 and to edit that you would go to example.com/admin/post/2 . Your routes.rb may look something like this:

Rails.Application.routes.draw do
  namespace :blog do
    match 'post/:id' => 'post#show'
    match 'post' => 'post#index'
  end
  namespace :admin do
    match 'post/:id' => 'admin#show'
  end
end

Now lets say you’ve created the subdomains admin and blog to deal with these separately.  These subdomains undoubtedly point to the same place. So admin.example.com/blog/post/2 will point to the same place as blog.example.com/blog/post/2 despite having different subdomains. Using contraints we can now restrict the traffic and where it goes.  Contraints allow us to see the subdomain and match it on a regular expression, code would change to look something like this:

Rails.Application.routes.draw do
  constraints(:subdomain => /blog/) do
    namespace :blog do
      match 'post/:id' => 'post#show'
      match 'post' => 'post#index'
    end
  end
  constraints(:subdomain => /admin/) do
    namespace :admin do
      match 'post/:id' =>'admin#show'
    end
  end
end

You’ll notice that I’ve added contraints and within this contraint we have :subdomain which returns the name of the subdomain of our URL and the => /blog/ checks to see if the subdomain contains the word blog.  You can use any manner of regex in here and if it finds the expression then it will move on to the next item.

So this is great, we now have links like admin.example.com/admin/post/2, but blog.example.com/admin/post/2 will not work, which is what we want.  But there is a small problem, admin.example.com/admin/post/2 is redundant. To remove this we can modify our code ever so slightly on the namespace line:

namespace :blog, :path => '/' do
namespace :admin, :path => '/' do

These small little changes will mean that now things like blog.example.com/post/2 will be the same as the old example.com/blog/post/2, or admin.example.com/post/2 the same as the old example.com/admin/post/2

To me, this is as clean as you can get, but there is a drawback.  The changes put in place mean that we can no longer use our previous paths. They are gone, in favor of subdomains.

I hope that helps someone down the line.

@tab

To be fair, we’re over the half way mark by about two days, but that doesn’t mean I can’t recap on what I’ve done.

It’s been an interesting, yet brief trip. The primary reason for our visit, visiting my Dad, just flew by in the four short days that we had.  And it seems like only yesterday that we showed up in Beijing and now we’re leaving tomorrow.  We have even less time in Taiwan, so I’m sure that will feel even more rushed.

Our first stop, Shanghai, was completely different, yet exactly the same as I remember it.  Big, polluted and with to much emphasis on growth to feel like there is much history left. This was due part to the heavy amount of western culture that seems to dominate the city.  The city itself is exploding, much like the rest of China, but all that seems to amount to right now is pollution that makes it hard to breathe and impossible to wear contacts without your eyes burning.  That said, I still enjoyed Shanghai, mostly because I was able to visit my Dad, but also because of the foods and sights, but I really enjoyed how the city genuinely just felt alive and growing.

Shanghai gave us some interesting experiences as well, though it seems like I’m reliving many of the ones that I experienced while I was in China a few winters ago.  Like before, we’ve been to the Chinese Venice, went to Shanghai Museum, and walked around the city feeling very out of place.  One thing that we didn’t try and I feel obligated to warn people about is the Shanghai Zoo.  It reminds of a description I read of the Beijing zoo in years past, where it had a line that read something like, “The Chinese standards for taking care of animals are not on par with there western counterparts. If you have weak stomachs or children with you it is not recommended to go to this zoo.”  That’s a very similar feeling I have with the Shanghai zoo.  The cages are dingy, the animals are taken care of poorly, and this all surmounts to a truly distressing experience.  Most notable is the pets exhibit, where they showcase caged pets such as dogs and cats, and other random ones like a porcupine.  It was here that we saw every breed of dog you could think of, though we didn’t actually attempt verify this.  Each held in a cage not hardly shaded from the sun, concrete floors and smelled like burning dog feces.  It reminded me a lot of the pound, but baking in the sun.  The last straw of this trip was when we came to a corgi cage, I was speechless, and Becky burst into tears.  I quickly grabbed her to make our way out, and we vowed never to return to the Shanghai zoo.

Now we’re in Beijing.  This is my city. I love it here.  It seems like the proper mix of old and new.  You’ll have massive ten lane wide streets and then you’ll go onto a small side road that you’d imagine were hundreds of years old.  Yesterday we took a trip to the great wall, which no matter how great you imagine it being, still manages to surprise you with its immensity. It was a long hike, 7km to be exact, and although that may not seem to bad, that’s going over hill after hill on less than intact steps and climbs in sweltering heat.  There were a few times yesterday that Becky thought she was going to be sick with heat exhaustion.  But we completed our trip, losing ten pounds in sweat and probably destroying our clothing in the process.  Lets just say that the bus ride home had an interesting smell to it.  Later that night we went back to where I studied while in Beijing. I showed a very tired, unenthusiastic Becky around the campus and found a place that sold DanBing! They are these pancakes that have an egg cracked in them with a sort of spicy sauce and some lettuce.  They are about as simple as you can get, but boy are they delicious.  We then found some random place to eat, we weren’t hungry enough to eat the Duck we had planned to eat.  Then we made our way home.

Today we head out for the summer palace and go around town a bit more. It should be fun, so long as I can get mor street food.

@Tab

Follow

Get every new post delivered to your Inbox.