Rockstar Memcaching

Posted by tobi — 05:37 AM Jul 21

I’m back from Rubyfringe which was hands down the best conference i’ve been to.

Pete Forde asked me to present on memcached (mem-cache-dee) after my popular blog article Secret to memcached. The talk covers different use cases such as simple html snippet stores to advanced expiry systems such as generational cache keys.

Every talk at rubyfringe was taped so I’ll update this space with the video once its online. In the meantime enjoy the slides which probably make zero sense on their own.

Download the PDF or watch it on slideshare:

P.S: 30 minute is the ideal length for talks at a Tech Conference.

12 comments

Shopify Sys Admin

Posted by tobi — 03:41 PM Jul 07

If you love servers you should consider applying for our system administrator position . Flexible work hours and you get to work with all the coolest and latest technologies and a fantastic team.

0 comments (closed)

One million integers?!

Posted by tobi — 11:09 PM Jul 06

This is a great general purpose interview tip:

If you don’t know how to answer a question because it’s way outside of your expertise simply give it your best guess and negate the question.

via youtube:

This can sometimes have pretty impressive results.

1 comment (closed)

Gecko/Webkit Screenshots

Posted by tobi — 12:07 PM May 17

For our Shopify Product Search we needed a good way to Screenshot web pages. There are some services on the web for this but we ended up building it but none of them fit our needs. They were either way to expensive, they didn’t produce nearly the quality we needed or they didn’t offer an API at all.

Our solution was to install a headless X server in our server farm which runs firefox 2.0. We used a python GTK automation script which navigates the Firefox instance to the page and then dumps the framebuffer into a png file when done. This works well enough but i’d like something more robust for a different project.

Ideally I’d like someone to build a screenshot tool based on Gecko or Webkit which can simply take an url and spit out an png. A dependency on an running X server is acceptable but I’d rather not have it running all the time because it complicates deployment a lot. It has to run on Linux and must not depend on a shared global resource, i.e. you should be able to take two screenshots at the same time.

If you know of a tool like the one I describe or if you think you could build something like this for me please contact me. This may be paid open source work.

15 comments (closed)

Twitter

Posted by tobi — 09:13 PM May 08

I need more followers on twitter :-)

5 comments (closed)

Canadian Citizenship

Posted by tobi — 01:04 PM May 05

Today I got my Canadian citizenship.

Both Germany and Canada allow multiple citizenships so I’m allowed to carry both. Geographical redundancy accomplished. Next step is to apply for my Canadian passport so that I can instant failover :-)

Update: Take the citizenship test yourself and post your score in the comments.

21 comments (closed)

Database situps

Posted by tobi — 08:45 AM Apr 22

Todd Hoff in his love letter to Amazon’s SimpleDB

SimpleDB shifts work out of the database and onto programmers which is why the SimpleDB programming model sucks: it requires a lot more programming to do simple things. I’ll argue however that this is the kind of suckiness programmers like. Programmers like problems they can solve with more programming. We don’t even care how twisted and inelegant the code is because we can make it work. And as long as we can make it work we are happy.

I can’t think of what drove him to write this. This argument is directly contradicted by the success of Rails.

5 comments (closed)

Active Shipping

Posted by tobi — 01:36 PM Apr 21

James released his development version of Active Shipping to github

Active Shipping does what Active Merchant did for payment gateways: Provide one unified API to talk to all the Parcel Services on the web. Given a weight, a to and a from address you can calculate the Shipping costs of every supported Shipping Service. All the complexity of the task is handled by the library.

Active Shipping has been in production use with Shopify since the beginning of the year.

API:

require 'active_shipping'
include ActiveMerchant::Shipping

# Package up a poster and a Wii for your nephew.
packages = [
  Package.new(  100,                        # 100 grams
                [93,10],                    # 93 cm long, 10 cm diameter
                :cylinder => true),         # cylinders have different volume calculations

  Package.new(  (7.5 * 16),                 # 7.5 lbs, times 16 oz/lb.
                [15, 10, 4.5],              # 15x10x4.5 inches
                :units => :imperial)        # not grams, not centimetres
]

# You live in Beverly Hills, he lives in Ottawa
origin = Location.new(      :country => 'US',
                            :state => 'CA',
                            :city => 'Beverly Hills',
                            :zip => '90210')

destination = Location.new( :country => 'CA',
                            :province => 'ON',
                            :city => 'Ottawa',
                            :postal_code => 'K1P 1J1')

# Find out how much it'll be.
ups = UPS.new(:login => 'auntjudy', :password => 'secret', :key => 'xml-access-key')
response = ups.find_rates(origin, destination, packages)

ups_rates = response.rates.sort_by(&:price).collect {|rate| [rate.service_name, rate.price]}
# => [["UPS Standard", 3936],
#     ["UPS Worldwide Expedited", 8682],
#     ["UPS Saver", 9348],
#     ["UPS Express", 9702],
#     ["UPS Worldwide Express Plus", 14502]]

# Check out USPS for comparison...
usps = USPS.new(:login => 'developer-key')
response = usps.find_rates(origin, destination, packages)

usps_rates = response.rates.sort_by(&:price).collect {|rate| [rate.service_name, rate.price]}
# => [["USPS Priority Mail International", 4110],
#     ["USPS Express Mail International (EMS)", 5750],
#     ["USPS Global Express Guaranteed Non-Document Non-Rectangular", 9400],
#     ["USPS GXG Envelopes", 9400],
#     ["USPS Global Express Guaranteed Non-Document Rectangular", 9400],
#     ["USPS Global Express Guaranteed", 9400]]

6 comments (closed)

Git and Capistrano

Posted by tobi — 05:45 PM Apr 15

Git support in the latest capistrano works very well but there are two gotcha’s I ran into, i’ll document them here so that Google can pick it up.

The first problem was the bizarre error message I got when I forgot to push my changes to the deployment repository:


 ** [err] Needed a single revision
 ** [err] Needed a single revision
 [...]

Needed a single revision, well then. Git seems to use the rare other meaning of “single” which means “existing” or “valid”.

The other problem was harder to track down. Capistrano would simply hang forever after the update_code task. It would also leave the cached_copy directories in a totally invalid state on some servers which required manual rm -rf. Thanks go to Scott Raymond on Twitter for pointing me in the right direction. It seems that we have too many App servers for a stock sshd_config and It triggers some kind of throttling logic which git cannot deal with.

If you are deploying to medium to large server farms better head over to your git box and increase the MaxStartups now.


MaxStartups 10000:1:10000

This solves the problem.

0 comments (closed)

Work on Shopify

Posted by tobi — 09:44 PM Apr 10

Are you in Ottawa, Canada or willing to relocate? Want to work in the coolest office in town? Would you like to work on a high profile rails application with millions of users? Do you want to work with some of the best rails programmers out there?

Please email me at tobi@jadedpixel.com. Please include a piece of code you are especially proud of or point me to some of your open source work. If you include a CV please attach it as PDF.

2 comments (closed)

Wtf?

Posted by tobi — 09:17 PM Apr 10


if false
  var = nil
end

p var.nil? #=> true ??? 

12 comments (closed)

On Return

Posted by tobi — 11:49 AM Apr 03

ActiveSupport has this really nice returning tool. It allows you to rewrite the common pattern of initialization and returning a object from am method like this:

returning something = Thing.new do
  something.this
  something.that
end

We were wondering if there may be a performance issue with the tool so a quick benchmark showed the following:

                                          user     system      total        real
def n; i = 0; return i; end           0.510000   0.000000   0.510000 (  0.520417)
def n; i = 0; i ; end                 0.340000   0.000000   0.340000 (  0.344569)
def n; returning i = 0 do; end; end   0.730000   0.000000   0.730000 (  0.726853)

Those numbers are after 1m runs on a core 2 duo laptop. As you can see the difference is very minor. Code vanity can safely prevail. Full Benchmark

9 comments (closed)

Shopify stores are gorgeous

Posted by tobi — 08:00 AM Mar 25

The quality of Shopify stores being launched every day really boggles my mind. Just look at those 3 most recent examples:

ClothMoth

ZipRC

Destinative

If you like pretty stores, i recommend subscribing to the Shop of the moment feature or head over to our http://www.shopify.info/screenshots/ page.

Speaking of which, our screenshot page is actually powered from the RSS feed of the Shop of the moment category on our blog. Shopify.info is powered by radiant and we use the RSS Reader extension with some minor modifications and some clever CSS. This is a great example of how we can reduce content production work by re-using various RSS feeds. Another example of this is our feature page where we list all the Payment gateways Shopify currently supports. This comes straight from a RSS feed generated by the Shopify application and so it’s automatically always up-to-date.

0 comments (closed)

Money as debt

Posted by tobi — 10:41 AM Mar 24

Paul Grignon’s 47-minute animated presentation of “Money as Debt” tells in very simple and effective graphic terms what money is and how it is being created.

via google video :

8 comments (closed)

many many DJs

Posted by tobi — 10:16 AM Mar 23

I just checked in a new version of the delayed_job plugin which handles background processing of long running tasks in Shopify.

DJ is now fully parallelizable and does not require any global locking anymore. This means that you can run as many worker processes as you want across your server farm if you need to speed up the queue processing.

This became necessary when we kicked off a full search server reindex recently and realized that a single worker process would require 48 hours to complete the task. Such is the burden of success.

This feature is DB independent and doesn’t rely on row level locking. I found that row level locking lead to a lot of unnecessary lock timeout waits. If you are updating from the previous version of the plugin please be advised that there are two new columns you have to add.

Grab the latest version form http://github.com/tobi/delayed_job/tree/master

4 comments (closed)