Tech, Ramblings, and Intellectual Detritus http://kevinlochner.com Most recent posts at Tech, Ramblings, and Intellectual Detritus posterous.com Fri, 03 Feb 2012 17:28:00 -0800 Joyful Coding http://kevinlochner.com/joyful-coding http://kevinlochner.com/joyful-coding

From the redis manifesto:

"We optimize for joy. We believe writing code is a lot of hard work, and the only way it can be worth is by enjoying it. When there is no longer joy in writing code, the best thing to do is stop. To prevent this, we'll avoid taking paths that will make Redis less of a joy to develop."

Amen.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/44617/IMG_0031.JPG http://posterous.com/users/1gDCOpMDRaF kevin lochner kevin kevin lochner
Mon, 08 Aug 2011 01:52:00 -0700 A developer is only as good as his commits http://kevinlochner.com/a-developer-is-only-as-good-as-his-commits http://kevinlochner.com/a-developer-is-only-as-good-as-his-commits

As a developer I've found new appreciation for the adage "a man* is only as good as his word."  In business and in life, you can't depend on people who don't follow through on promises, especially when stakes are high.

Amongst programmers, our code is our word.   If collaborators can't trust that our code is of high quality, we are effectively a time and energy sink for those around us, forcing on others the task of testing and validating our work.  The analogue in the non-tech world would be someone whose promises require second guessing, backup plans, and a non-trivial dose of anxiety.

A developer that pushes high-quality commits, like someone who follows through on his or her word, is a refreshing person to interact with, because the cost of interaction is negligible, making the net value of all contributions significantly higher.

Push good code.

*note:  excuse the gender bias in the quote - fortunately women are better with promises and code commits

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/44617/IMG_0031.JPG http://posterous.com/users/1gDCOpMDRaF kevin lochner kevin kevin lochner
Fri, 15 Jul 2011 23:22:00 -0700 Physical Technical Problems http://kevinlochner.com/physical-technical-problems http://kevinlochner.com/physical-technical-problems

A case study of the physical world bleeding into the technical . . . and a case study in idiotic StackExchange questions.

 

Screen_shot_2011-07-15_at_11

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/44617/IMG_0031.JPG http://posterous.com/users/1gDCOpMDRaF kevin lochner kevin kevin lochner
Fri, 13 May 2011 18:13:00 -0700 Canned interview problems are fundamentally flawed http://kevinlochner.com/canned-interview-problems-fundamentally-flawe http://kevinlochner.com/canned-interview-problems-fundamentally-flawe

I always hated "programming problems" when I was interviewing for jobs. I now also hate them as someone who is trying to hire programmers.

As a candidate, I felt like these kinds of problems had little relationship to real work. How often do I really need to find the number of ways that one could walk down a set of stairs (a classic recursion interview question) or what floor an egg breaks on? (nice one, google)  And what am I supposed to do if I already know the answer? (which was often)  There are multiple levels of weirdness at play -- not exactly what I call enjoyable.

As an employer, I hate them for an entirely different reason. My objective during an interview is to find out two things:

a) is this person smart
b) can this person work well with our team

Canned interview problems may given you the answer to (a), but they do so at the cost of having any chance of knowing (b).

By giving them a contrived problem that I know the answer to (and they know I know the answer), I've immediately forced an artificial interrogation-style power dynamic between us and likely amplified their anxiety by a couple orders of magnitude. My goal is to get as far away from that dynamic as possible.

To the best of my ability, I want to simulate an hour or two of work and see whether we can collaborate effectively.  Here's the rough approach I've worked out so far, comments are appreciated as I'm pretty new at this myself:

  • Have them share a personal project with you, it doesn't have to be of epic proportion, just something they're working on.
  • Talk through some of their code during the interview if possible. This can give you both an idea of what a code review will look like.
  • Have them explain any problems they are having, and see if you can help. This informs whether you will be able to collaborate on projects they own. 
  • Walk through some of your own code and explain some of the problems you've been having. See if they have any insight and whether you can brainstorm together.

In both cases of reviewing your respective work, you are admitting that you don't know the answer to the problem. In the case of your own problem, you're also admitting that it's something you could use help with.  You have now mitigated the power dynamic somewhat, which means the candidate can feel comfortable in throwing out ideas. You've moved from waiting for the "right" solution to asking for ideas on a real problem.

You come away with a good indication of their ability, as well as a decent indication for how well you would work together. And a possible side benefit may be new insight into the problems that you're struggling with.  It takes a little extra courage to fly without a net, but that's the whole point - leveling the field so you can actually talk.

If this sounds sane to you and you're looking for dev work in San Francisco, please get in touch.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/44617/IMG_0031.JPG http://posterous.com/users/1gDCOpMDRaF kevin lochner kevin kevin lochner
Mon, 13 Dec 2010 14:52:00 -0800 Safe Access for Temporary ActiveRecord Fields in Rails http://kevinlochner.com/safe-access-for-temporary-activerecord-fields http://kevinlochner.com/safe-access-for-temporary-activerecord-fields

I run into a fairly common problem in rails views when I'm pulling data from multiple tables.  To optmize on db access, I use :select to pre-load the data from the joined tables.  For example, let's say I want to list all users with their respective cities:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#models/user.rb
class User < ActiveRecord::Base
  has_one :address
  named_scope :with_city_info,
              :joins=>:address,
              :select="users.*, addresses.city as user_city"
end

#models/address.rb
class Address < ActiveRecord::Base
  belongs_to :user
end

#users controller
def locations
  @users = User.with_city_info
end

Then I don't have to load the Address model to display a user's city:

1
2
3
4
5
#locations.html.erb
<%= render :partial=>"user", :collection=>@users %>

#_user.html.erb
<%=h user.name %> lives in <%=h user.user_city %>

The problem is that my user partial is now coupled with my named scope:  if I render the partial without using the scope, I'll throw an exception.  To avoid the problem, I add an accessor method to the User model that will pull the pre-loaded data if available, and revert to using the Address model:

1
2
3
4
#models/user.rb
def user_city
  read_attribute(:user_city) || address && address.city || ""
end

The partial will be inefficient, but I'd prefer to find the error when profiling view times rather than through exceptions.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/44617/IMG_0031.JPG http://posterous.com/users/1gDCOpMDRaF kevin lochner kevin kevin lochner
Thu, 04 Nov 2010 10:35:04 -0700 How Twitter handles disabled Javascript http://kevinlochner.com/how-twitter-handles-disabled-javascript http://kevinlochner.com/how-twitter-handles-disabled-javascript The home page works, but once you log in . . .

Picture_2

. . . so much for Javascript fallback.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/44617/IMG_0031.JPG http://posterous.com/users/1gDCOpMDRaF kevin lochner kevin kevin lochner
Fri, 01 Oct 2010 12:23:00 -0700 Bash-style history for irb http://kevinlochner.com/bash-style-history-command-for-irb http://kevinlochner.com/bash-style-history-command-for-irb

This functionality is included in some ruby gems (Utility Belt seems to be the most popular), but I'm more of a "roll-your-own" kinda guy.  Not to mention that the gem is a little overkill for printing out command history. 

Here's what I came up with:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
def history(num=100)
  h = Readline::HISTORY.to_a
  start = [0,h.size-num-1].max
  h.zip((0..h.size).to_a)[start...h.size].each do |e,i|
    puts " #{(i).to_s.rjust(4)} #{e}"
  end;nil
end

>> history(7)
  483 def history(num=100)
  484 h = Readline::HISTORY.to_a
  485 start = [0,h.size-num-1].max
  486 h.zip((0..h.size).to_a)[start...h.size].each do |e,i|
  487 puts " #{(i).to_s.rjust(4)} #{e}"
  488 end;nil
  489 end
  490 history(7)


Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/44617/IMG_0031.JPG http://posterous.com/users/1gDCOpMDRaF kevin lochner kevin kevin lochner
Thu, 23 Sep 2010 16:02:00 -0700 Prompting for Facebook Permissions http://kevinlochner.com/prompting-for-facebook-permissions http://kevinlochner.com/prompting-for-facebook-permissions

When authenticating users via facebook, you have a laundry list of possible permissions to ask for.  If you ask for no permissions, the user gets the following login window:

Picture_3

Any requested permissions get displayed in the login window, but some of them get grouped into the same permission category. For example, many of the user_foo privileges get grouped into "Access my profile information", and similarly, friends_foo permissions get grouped into "Access my friends' information".

Below is a screenshot of what it looks like when asking for the full suite of permissions (I used the helpful Rell application to test). From this you can get an idea of what it looks like to the user based on which permissions you're asking for.

Picture_2

Asking for all permissions at once would be a little intimidating for users . . .

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/44617/IMG_0031.JPG http://posterous.com/users/1gDCOpMDRaF kevin lochner kevin kevin lochner
Thu, 23 Sep 2010 09:06:00 -0700 Orkut update - officially a "new product" http://kevinlochner.com/orkut-update-officially-a-new-product http://kevinlochner.com/orkut-update-officially-a-new-product

Confirming the email alert I recently received, Google appears to be strategerizing in social with a renewed push for Orkut: it's listed on page 1 of their new products page (despite launching in 2004).

Picture_18
Picture_17
Picture_16

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/44617/IMG_0031.JPG http://posterous.com/users/1gDCOpMDRaF kevin lochner kevin kevin lochner
Wed, 22 Sep 2010 19:21:00 -0700 This is what heaven looks like http://kevinlochner.com/this-is-what-heaven-looks-like http://kevinlochner.com/this-is-what-heaven-looks-like

My browsing speed was noticeably & absurdly fast, so I ran a quick check:

Picture_2

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/44617/IMG_0031.JPG http://posterous.com/users/1gDCOpMDRaF kevin lochner kevin kevin lochner
Sat, 18 Sep 2010 19:32:00 -0700 Sign of a well played scrabble game http://kevinlochner.com/28432734 http://kevinlochner.com/28432734
Photo

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/44617/IMG_0031.JPG http://posterous.com/users/1gDCOpMDRaF kevin lochner kevin kevin lochner
Mon, 16 Aug 2010 08:33:00 -0700 Is Google Bringing Orkut Back? http://kevinlochner.com/is-google-bringing-orkut-back http://kevinlochner.com/is-google-bringing-orkut-back

My old friend Orkut sent me an email yesterday, the first in a long time . . .

Picture_1

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/44617/IMG_0031.JPG http://posterous.com/users/1gDCOpMDRaF kevin lochner kevin kevin lochner
Fri, 06 Aug 2010 16:01:00 -0700 Use rails date_select without an activerecord model http://kevinlochner.com/use-rails-dateselect-without-an-activerecord http://kevinlochner.com/use-rails-dateselect-without-an-activerecord

I actually googled this and found a workable but ugly solution:

## view code <%= date_select('range', 'start_date', :order => [:month, :day, :year])%> ## controller code @start_date = Date.civil(params[:range][:"start_date(1i)"].to_i,params[:range][:"start_date(2i)"].to_i,params[:range][:"start_date(3i)"].to_i)

I needed to include the hour and minute as well, and didn't want to cram more arguments into the Date.civil call (actually Time.zone.local), so I cleaned up the code a bit.

Hoping to leave the internet a little better for the next guy, I thought I'd post the code.

## view code <%= datetime_select('range_start', 'date', :order => [:month, :day, :year, :hour,:minute]) %> # controller code @start_date = Time.zone.local(*params[:range_start].sort.map(&:last).map(&:to_i))

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/44617/IMG_0031.JPG http://posterous.com/users/1gDCOpMDRaF kevin lochner kevin kevin lochner
Thu, 01 Jul 2010 18:32:30 -0700 Feynman on Knowing vs. Knowing the Name http://kevinlochner.com/feynman-on-knowing-vs-knowing-the-name http://kevinlochner.com/feynman-on-knowing-vs-knowing-the-name

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/44617/IMG_0031.JPG http://posterous.com/users/1gDCOpMDRaF kevin lochner kevin kevin lochner
Sun, 30 May 2010 09:44:00 -0700 How I Roll http://kevinlochner.com/click-here-to-set-a-title-876 http://kevinlochner.com/click-here-to-set-a-title-876

Howiroll

credit:  http://bigeyedeer.wordpress.com/2008/07/15/this-cartoon-wrote-a-sweary-word-o...

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/44617/IMG_0031.JPG http://posterous.com/users/1gDCOpMDRaF kevin lochner kevin kevin lochner
Sun, 02 May 2010 14:53:00 -0700 Crappy TV Rant: Happy Town http://kevinlochner.com/trying-some-new-shows-happy-town-and-lie-to-m http://kevinlochner.com/trying-some-new-shows-happy-town-and-lie-to-m

I thought Happy Town had a decent chance of being entertaining

Happy-town-tv-01_sm

  "Executive producer Josh Appelbaum and others on the show are huge fans of the Twin Peaks"

  "Executive producer Scott Rosenberg says he's more a Stephen King fan."

  "So if you think it's too much like Twin Peaks, blame them. If you think it's not enough like Twin Peaks, blame me."

Lynch
I love David Lynch films - Blue Velvet, Lost Highway, Mulholland Drive, and of course, Twin Peaks, are all surrealist classics.  He is a true artist in the film world, where you come away from his movies not with a literal understanding of the story, but with a visceral sense of being disturbed and intrigued.  His short films are not to be missed if you're a fan.
King
I also enjoy Stephen King stories.   I say stories because it's typically not the production that wins me over - the novels are uniformly better than the movies - The Shining, Misery, Christine, Kujo, - all great books and very decent movies.  His knack for writing terrifying stories that get at our deepest fears elevate him above other writers of the genre.

Csi-sm
So with my expectations possibly set too high, Happy Town was fully disappointing - formulaic writing, overly produced, and all-around cheesy.  I want to know who to blame if it's too much like CSI.  It's unlikely I'll be back for a second episode, 20 minutes was more than enough.

 

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/44617/IMG_0031.JPG http://posterous.com/users/1gDCOpMDRaF kevin lochner kevin kevin lochner
Wed, 21 Apr 2010 15:40:57 -0700 Facebook Connect Fail http://kevinlochner.com/facebook-connect-fail http://kevinlochner.com/facebook-connect-fail Flash? Really? Funny given that Pandora was featured in the f8 keynote.

Picture_17

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/44617/IMG_0031.JPG http://posterous.com/users/1gDCOpMDRaF kevin lochner kevin kevin lochner
Wed, 03 Mar 2010 12:03:45 -0800 (not) Powered by Scala http://kevinlochner.com/not-powered-by-scala http://kevinlochner.com/not-powered-by-scala
Picture_9

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/44617/IMG_0031.JPG http://posterous.com/users/1gDCOpMDRaF kevin lochner kevin kevin lochner
Wed, 03 Mar 2010 10:35:00 -0800 The New Dashboard for Facebook Platform http://kevinlochner.com/the-new-dashboard-for-facebook-platform http://kevinlochner.com/the-new-dashboard-for-facebook-platform

Facebook has decided to do away with notifications - the little messages notifying you of things friends did on platform applications, or giving you updates on applications you have installed:

Picture_7
While some of these messages are more nuisance than value, users have the ability to block notifications from specific applications, and many applications depend on these notifications to enable continuity of user experience (chess is a good example - knowing when to play).

The Dashboard

Facebook decided that these notifications were too intrusive, or something like that, so they decided to replace them with something called the "Dashboard":   
Picture_8
The dashboard functions as a place to see notifications, grouped by application and limited to the most recent three displayed in the summary.  
This is fine.  Hell, it could even be considered an improvement.  

Getting Alpha and Beta Confused

But the problem is that Facebook nuked notifications while the Dashboard feature was still in alpha.  On launch day for the new feature, the Dashboard wasn't operational for many applications.  It was irresponsible of Facebook to annihilate notifications with the replacement feature in alpha, especially given that many applications critically depend on light-touch messaging in providing a decent user experience.

XML isn't Supposed to be Pretty, but WTF?

I'll sign off with a little sample of what's coming out of Facebook these days, an XML response to a Dashboard API call.  

Finding the data in the response is like playing "where's waldo?" with XML  (hint:   "Message Content", "http://url.net", "Text Content", "TimeStamp", "MessageID"). 

I also like how Facebook devs use "elt" repetitions to indicate nesting depth, I can just hear the conversation now:
    "did you mean the  response_elt or the response_elt_elt?"
     . . . "dammit, I said the response_elt_elt_elt"
<Dashboard_getNews_response list="true">
    <Dashboard_getNews_response_elt key="312266072840" list="true">
        <Dashboard_getNews_response_elt_elt key="image" />
        <Dashboard_getNews_response_elt_elt key="news" list="true">
            <Dashboard_getNews_response_elt_elt_elt list="true">
                <Dashboard_getNews_response_elt_elt_elt_elt key="message">
                      Message Content
                </Dashboard_getNews_response_elt_elt_elt_elt>
                <Dashboard_getNews_response_elt_elt_elt_elt key="action_link" list="true">
                    <Dashboard_getNews_response_elt_elt_elt_elt_elt key="href">
                        http://url.net
                    </Dashboard_getNews_response_elt_elt_elt_elt_elt>
                    <Dashboard_getNews_response_elt_elt_elt_elt_elt key="text">
                         Text Content goes here
                    </Dashboard_getNews_response_elt_elt_elt_elt_elt>
                </Dashboard_getNews_response_elt_elt_elt_elt>
            </Dashboard_getNews_response_elt_elt_elt>
        </Dashboard_getNews_response_elt_elt>
        <Dashboard_getNews_response_elt_elt key="time">
              TimeStamp
        </Dashboard_getNews_response_elt_elt>
        <Dashboard_getNews_response_elt_elt key="fbid">
              MessageID
        </Dashboard_getNews_response_elt_elt>
    </Dashboard_getNews_response_elt>
</Dashboard_getNews_response>

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/44617/IMG_0031.JPG http://posterous.com/users/1gDCOpMDRaF kevin lochner kevin kevin lochner
Sun, 21 Feb 2010 12:16:00 -0800 My Brief Stint as a Groupon User http://kevinlochner.com/my-brief-stint-as-a-groupon-user-learning-aga http://kevinlochner.com/my-brief-stint-as-a-groupon-user-learning-aga

learning again that you get what you pay for

Groupon

For those that are unfamiliar, Groupon is a collective buying site, similar to Woot and BuyWithMe.  Borrowing from the Wikipedia entry:

The Groupon works as an assurance contract using ThePoint's platform: if a certain number of people sign up for the offer, then the deal becomes available to all;  if the predetermined minimum is not met, no one gets the deal that day. This reduces risk for retailers, who can treat the coupons as quantity discounts as well as sales tools. Groupon makes money by getting a cut of the deal from the retailers

Sounds great, right?  Retailers build sales by offering a one-time discount, contingent on quanitty, and consumers get a good deal on some product or service, with Groupon taking a little cut.

Well, as with anything with even trivial complexity, the devil is in the details. 

My Experience

I was overdue for a dental exam, and my insurance doesn't exactly have stellar dental coverage, and i happened to be checking out Groupon when the deal of the day was for $60 exam/cleaning/xrays at a San Francisco dental office.   

Great! Right?

I bought into the deal, and actually waited about a month before booking my appointment.  Well, before trying to book my appointment.  When I called the office, I was greated not by the receptionist, but by this pre-recorded message:

The following information applies only to our Groupon.com patients that have not yet scheduled with us but who have already called or emailed our office.  We are currently repsonding to Groupon.com user calls and emails in the order in which they were received.  If you have already called or emailed to schedule your Groupon.com appointment, we ask that you be patient and please not call or email us again.

That's when I decided to run the numbers, something I probably should have done beforehand:

  • 585 Groupons issued 
  • 10 new patients/week (estimate)
  • 58 weeks before I get an appointment

Now I feel like an idiot, and simultaneously realize the brilliance of the Groupon model - they can make interest on the float of non-cashed groupons, which is huge for services that can't be consumed instantaneously. [edit - I'm told that Groupon pays out vendors immediately on the deal, which in theory should mean the vendors can sit on the cash until redeemed]

I have to mention that a simple email to groupon and my money was quickly refunded, so I have no beef with Groupon.  The experience made me wonder though: how many vendors would be prepared for the massive Groupon demand spike?

A Quick Look at Some Recent Deals

Here are some of the recent vendors/deals and quantities issued for Groupon:

  • Indian Restaurant Discount - 2549
  • Admission to a Party - 1650
  • Food Festival Entrance - 216
  • Spa Session - 1734
  • Asian Restaurant Discount - 2111
  • Salon Haircut - 833
  • Massage - 998

Here are some of the discussions centered around the deals:

I’ve been trying to book an appointment online and it just says “No available times were found” for every date in January and February… Is that just because they are overwhelmed by the number of Groupons purchased?

They made me feel like it was my fault that they had too many people buy this (1700 people) so they just can’t handle the capacity, so they haven’t been able to get back to everyone.

I just called and found their phone number was disconnected, too.

Not all the comments were negative -- for goods/services that are typically provided in high volume, people seemed extremely happy with their Groupon experience.  For the time-intensive services, the user response was a bit more spotty. 

Concluding Notes

Again, my experience wasn't great, but getting a refund was no problem whatsoever.  It may take a little time for consumers and vendors to flesh out the best way to manage their respective Groupon experiences, but there seems to be a real benefit from getting consumers excited about buying together on the day's deal.  So I expect Groupon to be around for a while, continuing to incite mania-induced group purchasing of local goods and services. 

As a side note, am I the only person who wonders why a "Collective Action Engine" is necessary to drive the Groupon site?  It sounds a lot like business-speak for one line of code saying "don't issue deal until N customers have bought.  Maybe I'm missing something.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/44617/IMG_0031.JPG http://posterous.com/users/1gDCOpMDRaF kevin lochner kevin kevin lochner