Entries Tagged 'tech' ↓

Capazoo: MLM 2.0

The thread on Montreal Tech Watch’s Capazoo Update got increasingly surreal this week, first with their Director of Communications heralding their strategic partnership with the National Lampoon. To contact him, anyone in the press should just do so through the service he is promoting (!).

Capazoo is a multi-level marketing scheme. Like Amway and countless other MLM schemes, it turns people into money-grubbing zombies that erode our social capital.

Today one Jean-Christophe decided to comment as a satisfied customer, pleading for us to see for ourselves how fantastic and lucrative Capazoo can be. Naturally, he finishes by giving us his profile page. If we sign up after visiting it, he earns zoops. So far, he’s earned 806 zoops - or $8.06.

So I looked at the referral scheme:

For every friend you invite who upgrades to Privileged Membership, you’ll earn 100 Zoops!

For every friend you invite who upgrades to VIP Membership, you’ll earn 130 Zoops!

The Capazoo.com Referral Program lets you earn Zoops when your friends refer friends – up to four generations!

Ick. Capazoo will quickly fill up with amateur spammers looking to make a single dollar of each of their social connections. Maybe one day they’ll have Amway-style rallies and conferences. Unlike other MLM organizations that manage to stick around for years however, this socio-economic virus should peter out once they burn through their cash reserves and exhaust their possible partnerships.

I hope Capazoo goes out with a bang rather than a whimper, that it serve as a reminder to other idiots that would try similar ideas.

Amazon 1, GOOG 0

The day Google announces it is creating a new wikipedia-like social network that pays authors, Amazon launches SimpleDB.

Montreal Tech Entrepreneurs Breakfast - December 2007

This morning I attended the December MTEB.

A couple of venture capitalists were in attendance, who graciously answered my questions about what is going on with the VC industry. I basically think the industry is big, slow, and doesn’t understand new technology. They’re closely watching the efforts of Montreal Startup, but weary several incubators, seed funds and other schemes have foundered before.

The real surprise was talking with Darrell and the engineers at Stanox. We come from different technology backgrounds: micro-chips, ERP and web. Yet we all have similar attitudes: KISS. YAGNI. Think. Simplify. We’re all fans of Saint-Exupery’s quote on perfection:

Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.

When I griped about a horrible API I might have to integrate (the variable names are inconsistent and ugly) one VC said “well, it can be ugly, but it’s ok if you make money”. The dividing line was obvious. For the engineers, if it’s ugly and verbose it’s probably buggy. For the investors, it’s bearable if it’s profitable.

The folks at Stanox look like they will be successful, and mentioned they may become angel investors in the future. I’m hoping they succeed; we need more angels like that.

Sling Blade Runner

After solving Word Numbers, maybe I should solve ITA’s other current puzzle, Sling Blade Runner. I wasn’t sure how to solve it, so I made a pretty picture:

Graph of movies overlapping with one word

ITA provides you a list of over 6,500 movies, and the objective is to make as long a chain as possible of overlapping titles: Sling Blade Runner, License to kill a Mockingbird. Every dot in the graph is a movie, every arrow connecting them indicating their titles overlap. In comments on Reddit, a few people found solutions of around 230 titles.

Puzzles are useful to learn. Since I’m not an engineer, they force me to learn about computer science theory I never learned. Looking up graph problems of the sort, I found out that this class of problem is defined as a ‘hard’, and it is far too computationally intensive to try every possibility (’brute force’). The only way to solve it elegantly is to use shortcuts, and those depend on the type of graph in question - which is why I decided it might be interesting to have an actual picture.

Tools like graphviz are slow for very large graphs, so this picture doesn’t represent the whole graph. Still pretty, no?

Rails performance: development environment is dog slow

I don’t usually worry about performance. Today, when a simple AJAX request sending back an empty body took 2 seconds to complete, I started digging.

Oddly, Firebug indicated over 2000 ms, while my log showed under a half-second. Since it’s on the same machine, there’s no way network issues can account for 1.5 seconds. I tried several avenues, and Marc-André suggested several possibilities before suggesting running it in production mode.

We were both suprised at the difference. Before / after:
Firebug: 1755 ms

Log: Completed in 0.47638 (2 reqs/sec) | Rendering: 0.00010 (0%) | DB: 0.15976 (33%) | 200 OK [http://standoutjobs.dev.com/****]

Firebug: 121 ms

Log: Completed in 0.11076 (9 reqs/sec) | Rendering: 0.00007 (0%) | DB: 0.06037 (54%) | 200 OK [http://standoutjobs.dev.com/****]]

A full order of magnitude! I’m used to logging and other debug overhead to have about a 10% performance hit, so this was very surprising.

If you’re like me, you have some personal web apps running in development mode. My first instinct was always to look at the logs, and see if there are some unnecessary requests being done, or anything that is taking far too much time. There’s also Marc-André’s tips for improving rails app performance. Still, those are a lot of work compared to the simple step of setting that production flag.

Rails migration hackery with ERB

How do you create a rails project if you don’t know the schema in advance?

Jerome had a really unusual set of business requirements for his first rails project: customers that will each have their own dedicated server, and have to be able to specify their client list schema through a web-based interface.

That’s a pretty ambitious task for a first rails project, don’t you think? Here’s my take on the problem. If you have a simpler solution, please propose a refactoring.

ITA word puzzle: optimization and wrap-up

At 1.4 seconds, the ITA puzzle solution I dreamed up while on codeine was already fast enough. Since the pain has subsided and I stopped taking the damned pain-killers, I thought I should go back, optimize and clean up. The code is now shorter, and runs about 10 times faster.

The new version is also on refactormycode, where you can critique and suggest changes.

If you want to see different approaches, there are other solutions and discussions of this puzzle in various places.

The optimizations I made were guided by ruby’s own profiler (invoking ruby with the -r profile flag ). The first time it ran, I felt a tinge of embarrassment, seeing that format_units was called 248,440 times, accounting for over 43% of the computation time.

$ruby -r profile ita.rb

  %   cumulative   self              self     total

 time   seconds   seconds    calls  ms/call  ms/call  name

 43.87    84.78     84.78   248440     0.34     0.50  NumberWriter#format_units

 17.99   119.55     34.77   134583     0.26     1.29  NumberWriter#write

...

Caching the 1,000 potential return values for that function in an array immediately brought the execution time down under a second. Optimization can really be that easy sometimes.

Most optimizations were done iteratively, taking whatever operation was taking the most time and trying to find ways to reduce its footprint. When code started getting messy and verbose, I re-factored and got another speed boost. Overall, the exercise was amazingly easy, taking less than 2 hours of total time without involving any complex code.

What astonishes me is that there is still low-hanging fruit for anyone that would want to make this even faster. Half the time is now spent sorting. A better profiler would definitely help, as the one available out of the box only breaks things down by function. However it’s clear that the profiler’s top 5 results could be mostly avoided if string representations of numbers and ranges didn’t have to be created to sort them alphabetically:

$ time ruby -r profile ita.rb

  %   cumulative   self              self     total

 time   seconds   seconds    calls  ms/call  ms/call  name

 31.13     4.84      4.84    64521     0.08     0.15  ITA::Number#<=>

  8.49     6.16      1.32        3   440.00  3676.67  Array#sort

  8.10     7.42      1.26    68831     0.02     0.03  ITA::Number#to_s

  6.43     8.42      1.00    61704     0.02     0.03  ITA::Range#to_s

  6.30     9.40      0.98     6178     0.16     0.33  ITA::NumberWriter#write

  5.14    10.20      0.80        4   200.00  2850.00  Array#each

  4.63    10.92      0.72    64521     0.01     0.01  String#<=>

I don’t feel the need to push this puzzle any further. If you do, go for it, and please share on refactormycode.

Coding on Codeine (TM)

I spent most of my week-end solving the ITA puzzle, while high on codeine. As I write this, I am literally shaking from withrawal. Those pills just take too long to get in your blood stream.

A root canal Friday forced me to make an exception to my usual drug-free lifestyle; the infection had reached the bone, so I’m also taking anti-biotics. Since I couldn’t dance, puzzle solving was the best thing to keep me distracted. I found a solution I’ll post later; it runs over 1,000 times faster than others I’ve seen or heard about.

There’s no way I can maintain a codeine habit, so I may have to try doping my writing abilities with alcohol.

Edit: Comments disabled because of spam

Psychology: survival, wealth and happiness.

Being familiar with many of the most common cognitive biases is not only useful to lead happier lives; it’s also becoming essential for survival.

Smart People Make Big Money Mistakes. We pursue things that won’t make us happy and perceive the world as more violent than it really is, even as wars have decreased by orders of magnitude. The availability heuristic affects how we (mis-)spend money on security, including in information security.

Jamais Cascio nails it when he says we have trouble envisioning a future that isn’t catastrophic. He appropriately concludes:

Sometimes, being a futurist isn’t about making forecasts or spotting trends.

Sometimes, being a futurist means acting as a civilizational therapist.

All the essays, books and videos linked above can help us do our individual part for this civilizational therapy project. Have fun :)

Hiring puzzles

Like most geeks, I love puzzles. I solved Google’s infamous puzzle that started with {first 10-digit prime found in consecutive digits of e}.com. I also solved one of Facebook’s puzzles, just for fun.

Today, Jonathan sent me a link to ITA Software’s hiring puzzles. It’s sexy stuff, and Standout Jobs would have some hiring puzzles too if I could come up with something particularly demented. Jonathan suggested an intriguing roman numeral puzzle. Sadly, we both realize that many people can’t even write a simple Fizzbuzz.

Ah well, back to the ITA Software puzzle. Looking at the average length of a few numbers, I estimate there’s a good chance the 51 billionth letter either doesn’t exist, or is very close to the end. Gauss would be amused.

Even if I’m wrong, brute force is obviously out of the question. It would however be nice to start from the end and have the algo run in a fraction of the time. So here’s how I start.

units = %w{ one two three four five six seven eight nine }
tens = %w{ ten twenty thirty fourty fifty sixty seventy eighty ninety }
teens = %w{ ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen }

def sum_string_sizes(units)
units.inject(0) {|memo, unit| memo + unit.size }
end

sum_string_sizes(units)
=> 36

sum_string_sizes(teens)
=> 70

([''] + units).inject(0) {|memo,i| memo + "twenty#{i}".size }
=> 96
'twenty'.size * 10 + sum_string_sizes(units)
=> 96
# sanity check doesn't bounce, wOOt!

sum_string_sizes(tens[1..-1]) * 10 + 8 * sum_string_sizes(units)
=> 758

So for numbers 1 to 99, I get strings of total length 864. I’m certain of my solution up to 999, but I’m not awake enough to be sure I have the rest really nailed. Either way, if there’s more than 51 billion letters, there’s still a fair chunk of work to do.

Have you solved this? If so, do you want to work for Standout Jobs? :) If not, how would you go about it?