Life as Code

refactoring my life

Archive for the ‘Working smart’ Category

accessing ruby I18n locale messages from the web client

leave a comment »

I like to keep my client-side code completely decoupled from the server-side but I still want to keep one message source for localization.

The ruby stack I use includes Sinatra, Sinatra::I18n and the I18n gem for localization and this is the simplest and most effective way (that I’ve found) of accomplishing this:

The Sinatra route:
get '/locales/:locale_name/messages.js' do |locale_name|
    locale = locale_name.to_sym
     
    if I18n.available_locales.include? locale then
        messages = I18n.backend.send(:translations)
        "var m = " + messages[locale].to_json 
                    + "; t = function(k){ return eval('m.' + k); }";
    else
        not_found
    end
end 

This way the yml locale file is loaded and served and wrapped for quick use.

In the client just request the messages script and then when you need a message call t(‘message key’) just like you’d do it in ruby :)


var message = t('message.key');

Written by Bogdan

August 30, 2014 at 9:29 PM

new endeavours – things to avoid

with 2 comments

When you want to start something new,  be it a business or a new product you always start up with an idea or, if you don’t have one you come up with one (by who care what process… brainstorming, calling a friend, stealing).

There’s no better idea than yours. I mean, it’s a pot of gold. What am I saying… it’s the motherload, the ultimate cash cow.

Well, before the money starts rolling in, you may want to analyse it a little further, especially regarding the intersection between your new idea, the boundary of your knowledge and the actual demand for a product such as the one you’re envisioning.

Here’s a diagram describing where you don’t want to be.

2014-01-26 Venn - Intersection - 1

Written by Bogdan

January 26, 2014 at 9:25 PM

Posted in Working smart

cause and effect – more testing doesn’t necessarily improve software quality

with 2 comments

A short story about cause and effect I had in my backlog.

Jim works for a software company or, why not, he may even own it.

Jim realizes that the quality of the software that gets built in his company decreases year-by-year, all over the board. He’s been seeing it for some time now but it seemed like the guys have it under control. You know, the guys know what they’re doing.

After awhile things seem to slip even further….

Read the rest of this entry »

Written by Bogdan

October 17, 2013 at 11:49 PM

competing for your time

leave a comment »

If there’s any single thing that you’ll never get back, it’s time.

Time is the most valuable resource that you posses. It’s your currency.

Things and people are in a never-ending race, competing for your time, but ultimately, if you respect your time, you should decide who receives it.

Lao Tzu said “Time is a created thing. To say ‘I don’t have time,’ is like saying, ‘I don’t want to.” and that’s… well, deep and true.

Only give your time to the people who respect it and to the things that given time, will give it back to you.

Because the people who respect your time will use it wisely while the rest will just waste it.

Saying that you don’t have time for something is lying to yourself and others. Give it some time tomorrow, or if you think that it really doesn’t deserve your time… don’t do it.

Written by Bogdan

October 11, 2013 at 9:51 PM

Posted in Working smart

semantics

leave a comment »

Back when I was green and naive I thought that real physical things are valuable.

I thought that people work together based on common interest, as opposed to working together based on the intersection of personal interests. I know, it seems like a semantic difference… it’s not.

Once you realize that this is a fact, not just some philosophical gibberish your whole collaboration mindset will change.

Nobody actually wants to work toward a distant goal that will benefit us all, without searching for a personal benefit. You’ll find people who swear their allegiance, ready to do anything to prove their pure intentions. That’s just their subconscious pulling tricks on them. They’re internal subconscious radar is scanning for gain 24/7.

“Help me help you” wins every time, it’s a better, more sincere strategy.

 

Written by Bogdan

September 17, 2013 at 7:03 PM

Posted in Working smart

building the new

leave a comment »

“The secret of change is to focus all of your energy, not on fighting the old, but on building the new” a wise man once said, and even though that was a long long time ago, it still stands strong. Read the rest of this entry »

Written by Bogdan

August 25, 2013 at 8:08 PM

Posted in Working smart

a little product management

leave a comment »

Even if you’re just a developer, a little product management will open your eyes.

I know, you think it’s all about marketing, and it is, sort of, but from time to time an article series like Practical Rules for Product Management makes it fun, even for non marketers. So, enjoy:

Written by Bogdan

February 13, 2013 at 10:48 PM

Follow

Get every new post delivered to your Inbox.

Join 263 other followers