John Patrick Given http://iamjpg.posterous.com Ruby, Rails, Javascript, Basketball, & Randomness posterous.com Sat, 03 Mar 2012 12:35:07 -0800 Best breakfast sandwich ever. Love Portland. http://iamjpg.posterous.com/best-breakfast-sandwich-ever-love-portland http://iamjpg.posterous.com/best-breakfast-sandwich-ever-love-portland

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/929236/26099_365504018447_658023447_5038464_1091622_n.jpg http://posterous.com/users/5BccaLVsHbsB JP Given iamjpg JP Given
Wed, 21 Dec 2011 16:26:00 -0800 Love and Regret http://iamjpg.posterous.com/love-and-regret http://iamjpg.posterous.com/love-and-regret

I got a letter in the mail yesterday. It was small and sort of hid itself along with my bills and junk mail. When I noticed it, I grabbed it and instantly knew it was from my aunt and uncle that live in London. I was excited as I don't hear from them very often due to distance, schedules, life, etc.

Once I opened the letter it was a small Christmas card, but inside was a pamphlet; I unfolded the pamphlet and it was a funeral announcement with my Uncle Ron's name at the top. My heart sank and instantly I was filled with sadness.

When I read what my aunt wrote inside the card it actually made me feel worse. Allow me to paraphrase:

Uncle Ron passed away on October 28th. I didn't have a phone number for you or your mother. I was able to get your address from Maureen.

While I was sad on many levels, the thing that might have made me the saddest is that I learned about the passing of my uncle almost two months after the fact.

  • This is the man that took me to my first cricket match as a child.
  • This is the man that randomly bought me a boomerang after my 7th grade year when I spent the summer with them. We took that boomerang to the park and threw it until we figured it out and nearly killed ourselves in the process.
  • This is the man that converted a card table into a snooker table with colored tin foil balls because a young kid from America loved watching snooker on TV.
  • This is the man that took me to my first professional football match to see Chelsea play...before they were good.
  • This is the man that walked me around the Parthenon, lovingly telling me all about it, as Greek history was his passion.
  • This was the man who had the most pleasant Welsh accent, a calming disposition, and a beautiful laugh.
  • This was a beautiful man whom I am going to miss immensely.

Yesterday, I was troubled nobody had told me. Maureen (mentioned in my aunts letter) and her husband Ed knew how to get a hold of me but decided not to. Worse yet, I had talked to Ed on the phone a week earlier, literally, and he didn't mention anything. I don't know why, and frankly it upset me.

All of this brings me to my point; yesterday I was upset with everyone but myself. Today, I am only upset with myself. For the last 5 years I had been so caught up in my own life I had neglected to keep in touch regularly with people I love very much. In this case family. Sure, I could justify it by blaming it on the time difference, or everyones busy schedules, but the attempt would be hollow.

I'm thinking that perhaps people took my non-communication as indifference and that is a hard pill to swallow.

I will regret not being able to say goodbye to my Uncle Ron for the rest of my life. It's cliche but true; don't wait to tell the people you love that you love them. One day, in a blink, they might be gone, and the regret and emptiness that's left behind is painful.

I don't want to experience this regret again.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/929236/26099_365504018447_658023447_5038464_1091622_n.jpg http://posterous.com/users/5BccaLVsHbsB JP Given iamjpg JP Given
Tue, 13 Dec 2011 16:52:00 -0800 Google Knows I'm a Terrible Speller http://iamjpg.posterous.com/google-knows-im-a-terrible-speller http://iamjpg.posterous.com/google-knows-im-a-terrible-speller

I'm a programmer. I spend all day, everyday, writing code. As any programmer will tell you, Google is an invaluable resource for our industry. In a typical day I may ask Google as many as 10 questions about nuances pertaining to a programming language, a framework, a design pattern, or whatever.

While using Google today, something dawned on me:

Google knows I'm a terrible speller.

I can't give a percentage of how many times I see "Did you mean?" or "Showing results for..." when I type a Google query, but I imagine it's higher than I'd like to admit.

After my revelation I couldn't help but wonder if that kind of information is advantageous to Google when conducting interviews. Seems reasonable to me, only I had never thought about it before.

Now, I have absolutely no plans to apply to Google, I'm very happy thank you, but after todays revelation, I may never want to :)

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/929236/26099_365504018447_658023447_5038464_1091622_n.jpg http://posterous.com/users/5BccaLVsHbsB JP Given iamjpg JP Given
Wed, 02 Nov 2011 10:32:00 -0700 Appcelerator Logging in 1.6.2 http://iamjpg.posterous.com/appcelerator-logging-in-162 http://iamjpg.posterous.com/appcelerator-logging-in-162

So, console logging doesn't seem to work in Titanium Appcelerator 1.6.2.  Trying to fix this problem I have come across a bunch of articles telling me to create a "logger.py" in the neather regions of my computer.  Well, I did that, and guess what?  Logging still didn't work.

Finally came across this article which fixes the issue simply.  I love simple.

This is what you do:

cd ~/Library/Application\ Support/iPhone\ Simulator/

mv 4.3.2 4.3.2.BAK

ln -s 4.3.2 4.3

Now your logging will work again!  Here's what's happening.  Basically after cding to your iPhone Simulator directory you back a back up of your 4.3.2 folder and then create a symlink from 4.3.2 to your 4.3 directory.  Like magic, console logging works again!

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/929236/26099_365504018447_658023447_5038464_1091622_n.jpg http://posterous.com/users/5BccaLVsHbsB JP Given iamjpg JP Given
Thu, 20 Oct 2011 13:32:00 -0700 Javascript Riddle http://iamjpg.posterous.com/javascript-riddle http://iamjpg.posterous.com/javascript-riddle

So I haven't posted on my blog in quite a while which is unfortunate because I feel that writing about programming helps one become a better programmer.  Plus, with practice, perhaps someday I'll actually be able to explain what I do to my mother.

So I thought it would be fun to write a quick post about a JS riddle I thought about yesterday.

It's quick and it's kind of fun.  Here's the riddle:

Without using global variables, write a script that prints the numbers 0 though 100 to the browser, printing each number one second apart.  Remember, no global variables...

Simple, right?

Try it first, but If you want the answer to the riddle you can see it on this Gist over at Github.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/929236/26099_365504018447_658023447_5038464_1091622_n.jpg http://posterous.com/users/5BccaLVsHbsB JP Given iamjpg JP Given
Wed, 09 Feb 2011 11:15:00 -0800 Rails 3, MongoDB, Mongoid, & Embedded Documents http://iamjpg.posterous.com/rails-3-mongodb-embedded-documents http://iamjpg.posterous.com/rails-3-mongodb-embedded-documents

So, I've been diving head first into MongoDB lately. It's awesome and quickly becoming my go-to database set up.

One of the nice things about a document database like MongoDB, is the notion of embedded documents. Yesterday I wanted to achieve modeling embedded documents within my rails application and found the documentation a little sparse. After succeeding I figured I should write a little post.

If you're unclear about what exactly embedded documents are, keep reading, it *should* be come clear as long as I don't write like a 4 year old.

For this example I will be assuming a that you have a working knowledge of Ruby on Rails. It's also important to note that I am using Mongoid as my MongoDB connector.

Let's begin and for this tutorial pretend we are making a site about dogs. One thing we *should* all be able to agree on is that a dog can have many breeds (think mutt). This means that a dog can have or has many breeds.

Let's start with the models

# Dog Model - dog.rb class Dog   include Mongoid::Document   field :name, :type => String   field :weight, :type => String   field :height, :type => String     embeds_many :breeds   accepts_nested_attributes_for :breeds end

Notice the embeds_many :breeds. That tells the dog model that it will accept an array of hashes that will represent breeds.

# Breed Model - breed.rb class Breed   include Mongoid::Document   field :breed_name, :type => String   field :breed_origin, :type => String   field :breed_personality, :type => String     embedded_in :dog, :inverse_of => :needs end

The big thing to note in the breed.rb file is the embedded_in :dog macro.  It's required for the relationship to work properly.

# Dog Controller - dog_controller.rb def new   @dog = Dog.new   @dog.breeds.build   respond_to do |format|     format.html # new.html.erb     format.xml  { render :xml => @dog }   end end

It's subtle, it's easy, but it's also easy to miss. Notice the @dog.breeds.build statement? That simple line prepares the controller for the association.

<%= form_for(@dog) do |f| %> <% if @dog.errors.any? %> <div id="error_explanation">     <h2><%= pluralize(@dog.errors.count, "error") %> prohibited this dog from being saved:</h2>     <ul>         <% @dog.errors.full_messages.each do |msg| %>         <li><%= msg %></li>         <% end %>     </ul> </div> <% end %> <div class="field">     <%= f.label :name %><br />     <%= f.text_field :name %> </div> <div class="field">     <%= f.label :weight %><br />     <%= f.text_field :weight %> </div> <div class="field">     <%= f.label :height %><br />     <%= f.text_field :height %> </div> <%=     # Don't miss the subtleties here.     # This builds the part of the form that embeds breeds.     f.fields_for :breeds do |b| %>     <div class="field">         <%= b.label :name  %><br />         <%= b.text_field :name %>     </div>     <div class="field">         <%= b.label :weight  %><br />         <%= b.text_field :weight %>     </div>     <div class="field">         <%= b.label :breed_personality  %><br />         <%= b.text_field :breed_personality %>     </div> <% end %> <div class="actions">     <%= f.submit %> </div> <% end %>

Above is a standard rails form used in creating and updating objects. The important part of this file is f.fields_for : breeds loop. That builds out the relevant form elements for embedding a breed (or two) inside the dog object.

After submitting the form above (with various data) you could see MongoDB return the following:

{ "_id" : ObjectId("4d5302e28b21a75180000009"), "name" : "Bailey", "weight" : "180lbs", "height" : "36\"", "_type" : "Dog", "breeds" : [     {         "name" : "German Shepherd",         "breed_origin" : "Germany",         "breed_personality" : "Loyal, Protective, Intelligent",         "_id" : ObjectId("4d5302e28b21a75180000007"),         "_type" : "Breed"     },     {         "name" : "Labrador",         "breed_origin" : "Unknown",         "breed_personality" : "Loving",         "_id" : ObjectId("4d5302e28b21a75180000008"),         "_type" : "Breed"     } ] }

And there you have it - two breeds embedded inside of the dog object. I hope this helps someone out there. Once you implement embeds_many using macros like embeds_one is simple.

The Mongoid web site has good documentation on associations, however they are by no means complete. I should mention though, without them, I wouldn't have been able to figure this out as quickly as I did.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/929236/26099_365504018447_658023447_5038464_1091622_n.jpg http://posterous.com/users/5BccaLVsHbsB JP Given iamjpg JP Given
Tue, 01 Feb 2011 15:15:00 -0800 The Original King http://iamjpg.posterous.com/the-original-king http://iamjpg.posterous.com/the-original-king

Wp_000045

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/929236/26099_365504018447_658023447_5038464_1091622_n.jpg http://posterous.com/users/5BccaLVsHbsB JP Given iamjpg JP Given
Tue, 28 Dec 2010 11:21:00 -0800 Pretty Major Windows Phone 7 UX Fail http://iamjpg.posterous.com/pretty-major-windows-phone-7-ux-fail-0 http://iamjpg.posterous.com/pretty-major-windows-phone-7-ux-fail-0

Winphonefail

Recently I bought a Windows Phone 7 and I love everything about it except one tiny little issue within the photo options.  See, "Upload to Facebook" doesn't have a confirm dialogue and it's positioned directly below the delete button.

You see the problem here, right?

Basically you're one misplaced tap away from sharing something you intend to delete with your Facebook friends.

I know this from personal experience.  The first photo I took with my new shiny phone accidentally got shipped it off to Facebook when I intended to delete it.  Luckily the picture was just of my kitchen table.

Until this gets fixed I get the feeling this could lead to some pretty embarrassing situations for people.

On the bright side, the unintentional comedy potential here is endless.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/929236/26099_365504018447_658023447_5038464_1091622_n.jpg http://posterous.com/users/5BccaLVsHbsB JP Given iamjpg JP Given
Mon, 06 Dec 2010 10:38:00 -0800 Replacing Prototype/Scriptalicious with jQuery in Rails 3? http://iamjpg.posterous.com/replacing-prototypescriptalicious-with-jquery http://iamjpg.posterous.com/replacing-prototypescriptalicious-with-jquery

I'm not sure why there isn't more information on the interwebs about this but if you want to use jQuery as your default javascript library in Rails 3 it's as simple as replacing your rails.js file with the one here:

https://github.com/rails/jquery-ujs

After that just delete controls.js, dragdrop.js, effects.js, and prototype.js and add jQuery in their place.  I prefer adding jQuery via the Google CDN but go ahead and do whatever makes you happy.

Happy coding.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/929236/26099_365504018447_658023447_5038464_1091622_n.jpg http://posterous.com/users/5BccaLVsHbsB JP Given iamjpg JP Given
Sun, 17 Oct 2010 11:28:00 -0700 Android Layout to Pin Buttons at Bottom of Device http://iamjpg.posterous.com/android-layout-to-pin-buttons-at-bottom-of-de http://iamjpg.posterous.com/android-layout-to-pin-buttons-at-bottom-of-de

Recently I have jumped into developing an app for the Android mobile platform.  While I do enjoy developing for Android it isn't nearly as nice to work with as the iPhone SDK.

This has nothing to do with the languages (Java vs Objective-C) but has everything to do with Android not providing a tool like Interface Designer.

The other day I had to figure out how to pin buttons to the bottom an Android device screen with scrollable content under it.  This is something you would think would be simple to do and reasonably well documented.  Well, it isn't.  In iOS (iPhone) you just drag your widget onto your stage and place it at the bottom.  In Android world you tinker with XML file layouts trying something, then building, trying again, building again, until you get your desired result.

Anyway, I finally figured it out and thought I would share it.

I created a Gist over at GitHub showing the code.  You can look at it here.

<?xml version="1.0" encoding="utf-8"?> <LinearLayout android:orientation="vertical" android:layout_height="fill_parent" android:layout_width="fill_parent" > <ScrollView android:layout_width="fill_parent" android:layout_height="0px" android:layout_weight="1" > <!-- ScrollView only accepts one child. --> <LinearLayout android:orientation="vertical" android:layout_height="fill_parent" android:layout_width="fill_parent" > <!-- START contents of scroll go here --> <!-- END contents of scroll go here --> </LinearLayout> </ScrollView> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <!-- START Menu Buttons --> <!-- END Menu Buttons --> </LinearLayout> </LinearLayout>

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/929236/26099_365504018447_658023447_5038464_1091622_n.jpg http://posterous.com/users/5BccaLVsHbsB JP Given iamjpg JP Given
Fri, 17 Sep 2010 14:58:00 -0700 Re_Invigorate Isn't a Service Worth Paying for Yet http://iamjpg.posterous.com/reinvigorate-isnt-a-service-worth-paying-for http://iamjpg.posterous.com/reinvigorate-isnt-a-service-worth-paying-for

I've been a re_Invigorate analytics user since its creator, Sean, started it with the intent of buying a scooter.  That was a really long time ago.  If I remember correctly that was around 2002/2003 or so and at the time there was NOTHING like it.  It was incredible.  Frankly, It still is!  And It's gotten better!  To me, Google Analytics can't touch it.  Mint can't touch it.  No other analytics service can touch it.

I freaking love re_Invigorate.

Seriously, if Mint can sell for 30 dollars then certainly re_Invigorate should charge, right?

Wrong.

At least not until it fixes one two core problems.

First, if you're going to charge for analytics, it's important to asure as few things as possible can corrupt the data.  Personally I would start with locking down statistics on a domain by domain basis.

What do I mean?  Maybe an example will help.

Say you write jQuery plug-ins (I do).  And let's say people actually use those plug-ins (they do).  And let's say you want to track the traffic going to the plug-in demo pages (I do).  And let's say people view source (they do) maybe copy that source (they do) and for arguments sake say they even copy the re_invigorate code assuming it's a requirement for the plug-in (they sure do).

What's the problem you ask?

Here is the problem.  When other people copy my re_invigorate code and include it in their source code then launch it live on their domains - their web traffic stats corrupt my web traffic stats.  Everything from referrers, to actual traffic, to geospatial data...everything.

Which leads me to the second reason why re_Invigorate is not ready to be a paid service:  It's been two weeks and I can't get an answer from them about this problem on their GetSatisfaction support page.  If it's a paid service I will expect a certain level of customer support.  And I can't pay for an analytics service that doesn't give me accurate data (duh).

Here is the GetSatisfaction ticket with no answer.

I can't say enough how much I love re_Invigorate.  Frankly I would pay more than what they're asking.  I realize I am in the minority of users that would actually have their source code copied but that shouldn't matter.  The data is what makes the service valuable.  If the data isn't right it's worthless.  Which is why I am now using Mint and missing re_Invigorate terribly.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/929236/26099_365504018447_658023447_5038464_1091622_n.jpg http://posterous.com/users/5BccaLVsHbsB JP Given iamjpg JP Given
Sun, 05 Sep 2010 19:35:00 -0700 Back to Basics for my Fantasy Football Draft http://iamjpg.posterous.com/going-analog-for-my-fantasy-football-draft http://iamjpg.posterous.com/going-analog-for-my-fantasy-football-draft

Imag0019

 

Something needed to change this year...

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/929236/26099_365504018447_658023447_5038464_1091622_n.jpg http://posterous.com/users/5BccaLVsHbsB JP Given iamjpg JP Given
Sat, 04 Sep 2010 13:19:00 -0700 Maven, Ninja, Rock Star - It's Got To Stop http://iamjpg.posterous.com/27336943 http://iamjpg.posterous.com/27336943

If anyone actually thinks of themselves as a "Social Media Maven", "Ninja Developer" or a "Rock Star Designer" trust me, they're not.

Please stop using these types of labels.  This especially applies when referring to yourself but also applies to job postings, conversations with friends and co-workers, or any other social situation imaginable.

If you use a term like this on your Twitter page to describe yourself you're an idiot.

</rant>

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/929236/26099_365504018447_658023447_5038464_1091622_n.jpg http://posterous.com/users/5BccaLVsHbsB JP Given iamjpg JP Given
Fri, 03 Sep 2010 15:46:00 -0700 There Aren't Enough Twitter Buttons on the Internet - TwtBnr http://iamjpg.posterous.com/twtbnrcom http://iamjpg.posterous.com/twtbnrcom

I like building jQuery plugins.  To me, building a jQuery plugin is right up there with a day at the mountains snowboarding or drinking beers and golfing.  Yes, it's that fun for me.

Whenever I build a new plugin I always find myself searching for some kind of Twitter follow button/ribbon/icon so a Twitter user can follow me for updates.  Well, updates and super rad tweets like "I forgot how much I like pickles!".

I recently noticed the "Fork me on GitHub" ribbon floating around and decided I wanted one just like it, only for Twitter.  So I built a site to do just that: http://twtbnr.com - A super easy way to generate code for a "Follow me on Twitter" ribbon placed on the left or right side of your web site.

Click here to visit TwtBnr!

Screen_shot_2011-10-20_at_1

 

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/929236/26099_365504018447_658023447_5038464_1091622_n.jpg http://posterous.com/users/5BccaLVsHbsB JP Given iamjpg JP Given
Tue, 31 Aug 2010 16:36:00 -0700 Why I Chose Posterous Over Tumblr http://iamjpg.posterous.com/why-i-switched-from-tumblr-to-posterous http://iamjpg.posterous.com/why-i-switched-from-tumblr-to-posterous

I used to love Tumblr.  I thought they could do no wrong.  As a matter of fact, I thought they were the easiest, dead simplest way to blog.  If my mother wanted to start blogging I would have recommended Tumblr without thinking about it.

When I initially tried Posterous I didn't like it.  After logging into the admin I thought it was overly wordy and complicated.  Nothing in the interface made me want to click around and I remember thinking the fonts were annoyingly small.  I'm a snob that way I guess.

Recently, when I decided I wanted to take the time to write more, I had a decision to make regarding which blogging platform I was going to use.  It basically came down to Tumblr, Wordpress, and Posterous as the choices.

Over the years I have spent a lot of time working with Wordpress and I really like it.  Unfortunately Wordpress carried too much overhead for what I wanted to do.  Plus I didn't want to deal with managing my install, managing plugins, and dealing with comment and ping-back spam.

So I moved on to Tumblr but immediately noticed something:  Tumblr was slow.  I mean sloooooooooow.  I love the interface, but nearly 10 second latency between requests in their admin was crazy to me.

Now I had to do something I hadn't done before: Give Posterous an honest look.  I'm glad I did because hot damn Posterous is nice.  The first thing I loved was how easy posting is.  You think Tumblr is simple?  Forgetabout it.  Posterous is amazing.  All I have to do is send an email to post@posterous.com from the email I signed up for and it will blog it?

Yup.

What if I attach an image?

No problem.

What if I link a video?

Taken care of.

Posterous is dead simple.  It seriously makes Tumblr seem like 10 more clicks to accomplish less.  The next thing that blew my mind was how east building a custom theme was.  Could making a theme be any easier?  When building Posterous themes you only have to worry about posts.  Not whether the post is an image, or the post is an audio file, or the post is a video, or that the post is a quote...

A post is a post on Posterous regardless of type.  As a programmer, that kind of abstraction made me smile.

Now I realize my custom theme isn't the most complicated thing in the world, but considering I whipped it out in 20 minutes I think it's pretty good.

Posterous is the platform.  It's awesome.  So awesome in fact that I extended my jQuery So So Social plug-in to account for it now.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/929236/26099_365504018447_658023447_5038464_1091622_n.jpg http://posterous.com/users/5BccaLVsHbsB JP Given iamjpg JP Given
Mon, 30 Aug 2010 17:41:35 -0700 Whistler! I Wish I Could Live There... http://iamjpg.posterous.com/whistler-i-wish-i-could-live-there http://iamjpg.posterous.com/whistler-i-wish-i-could-live-there
Shot_1283025926215

...well, at least 3 months out of the year ;)

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/929236/26099_365504018447_658023447_5038464_1091622_n.jpg http://posterous.com/users/5BccaLVsHbsB JP Given iamjpg JP Given
Mon, 30 Aug 2010 16:12:00 -0700 First Obligatory Post http://iamjpg.posterous.com/first-obligatory-post http://iamjpg.posterous.com/first-obligatory-post

So I have decided to write.  I'm not sure why really, I just get this feeling like I need to.  I guess on a lot of levels it's a good idea for me to take my writing a little more seriously.  First off, writing is skill and I have always been envious of those who can write well, be consise, and clearly explaine their point.  In the end the only way to get better at something is to work at it, right?

Since I am a programmer I am pretty sure my personal blog will be mostly about programming, design, usability, languages, frameworks, and general nerdom with some personal randomness thrown in from time to time.

Well, I guess this is a start.  We'll see where it goes from here.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/929236/26099_365504018447_658023447_5038464_1091622_n.jpg http://posterous.com/users/5BccaLVsHbsB JP Given iamjpg JP Given