Code On Fire Passionate About Cool Code

23Feb/120

Django Template Translations Tips and Tricks

A few scenarios I’ve come across, use-cases that are sometimes difficult to implement or find information about:

Double Quote Escape

template: {% trans “This is a \“quoted\” string.” %}

msgid:
“This is a \“quoted\” string.”
msgstr: “This is a \“quoted\” string.”

template: {% blocktrans %}This is a “quoted” string.{% endblocktrans %}

msgid:
“This is a \“quoted\” string.”
msgstr: “This is a \“quoted\” string.”

Variable Inclusion

template: {% blocktrans %}This is a {{DJANGO_VARIABLE}} value.{% endblocktrans %}

#, python-format
msgid:
“This is a %(DJANGO_VARIABLE)s value.”
msgstr: “This is a %(DJANGO_VARIABLE)s value.”

Variable Inclusion with Quotes

template: {% blocktrans %}This is a quoted “{{DJANGO_VARIABLE}}” value.{% endblocktrans %}

#, python-format
msgid:
“This is a quoted \“%(DJANGO_VARIABLE)s\” value.”
msgstr: “This is a quoted \“%(DJANGO_VARIABLE)s\” value.”

13Sep/111

.netrc for googlecode on Windows

For automated git-authentication magic googlecode gives you a line to add to the .netrc file. This will seamlessly authenticate you with a username and password on googlecode for smooth git interaction.

What they fail to mention is how to implement this on Windows.

Here it is in three easy steps:
  1. Open the command prompt.
  2. Type set HOME=%HOMEPATH% and press enter to create a new environment variable telling git where to find your netrc file.
  3. Type echo machine code.google.com login yourEmail@gmail.com password > %HOME%\_netrc swapping out yourEmail and password with the ones supplied by google. On windows the file is not .netrc but _netrc.

You can now clone any googlecode repo you have access to without any authentication problems.

7Sep/11Off

How To Link to a Google Plus User

It might seem obvious to many, but it took me a good bit of time to figure out how to link to another google plus user in my stream. Turns out, it is very easy and intuitive:

Just type “+” and then start typing the person’s name you want to link to. Google Plus will do the rest.

Happy Surfing!

26Aug/11Off

Smooth Gestures Spyware

Smooth Gestures, the Chrome plugin that allows you to use mouse gestures for navigation, are stabbing all of their users in the back. This segment of code was found in the code they inject into every single page you visit:

 1: function pl_track(){
 2: if (window.location.protocol == "https:") return;
 3: if (window === window.top)
 4: {
 5:     if (!document.getElementById('hummingtrack'))
 6:     {
 7:         trackerimg=document.createElement('img');
 8:         trackerimg.id="hummingtrack";
 9:         trackerimg.src="http://www.smoothgesturesapp.com/tracking/ tracking_ss.gif?events="+

window.location.href

                               .split(/\/+/g)[1]+"&r="+Math.random();
 10:         trackerimg.height="1";
 11:         trackerimg.width="1";
 12:         document.body.appendChild(trackerimg);
 13:     }
 14: }
 15: }
 16: setTimeout(pl_track(),1500);
This behavior only came to my attention when their site is slow to respond causing the browser to hang, waiting for the call to www.smoothgesturesapp.com to complete.
This is beyond deplorable. It is blatant abuse of your trusty clients that number over four hundred thousand. That is half a million people’s private web browsing history you are storing and probably selling.
Since url’s often include email adresses, this extension not only knows where you browse, it can take a good stab at guessing your email address(es) and sell your browsing habits to the highest bidder.

Google isn’t  is Helping

Update: Google has since removed the application from their store. Let this be a lesson to other extension-makers.

Smooth Gestures have been reported numerous times and there is no action on Google’s part yet. To make matters even worse, the Google extension repository shows comments on extensions in Chronological order with no way to view the last page of comments.

This means that every new sucker that considers installing Smooth Gestures, have no way of knowing about recent issues unless they click through 43 pages of comments to find the most recent ones.

This is a severe security oversight and should be dealt with promptly. Please Google, take notice!

Quick Workaround

If you still like the functionality of Smooth Gestures, but don’t want the spying bit to catch you, you can enter the following line in your hosts file:

127.0.0.1 www.smoothgesturesapp.com

17Jun/11Off

Comment Flood

Since I've removed the Captcha box for comments, I have been receiving a flood of spam comments. For those who requested it, unfortunately I am re-instating the captcha on comments. There is just too much junk coming in otherwise.

For those who have posted legitimate comments and are expecting to see them show up on the site, please be patient as I am methodically going through all the pending comments to get rid of all the spam.

I will post updates when the process is complete and if your comment hasn't shown up by then, please let me know.

Till later..

Tagged as: Comments Off
23Mar/111

Firebug-like JavaScript Object Inspector

thumbnailI’ve been looking around for a object inspector debugging tool similar to firebug’s console and have not found anything that suited my needs.

So I created this little jQuery extension to perform this function for me. I thought it might be useful to somebody else too, so I’m posting the plugin here.

Features

Using object references, this plugin will only render the parts of the object you are currently looking at.
When expanding an item, it gets rendered at that point. When closing an item, it gets removed from the DOM for memory efficiency.

It also offers (similar to Firebug console) a summary line next to the item if it contains hash values or array items.

You are also able to provide an additional parameter that will act as the title so that more than one of them can be available on the page without causing confusion.

Known Issues

It currently has problems displaying in IE. When that is sorted, I’ll update this post with the new version.

The styling is not quite up to scratch, with certain elements slightly misaligned. This will also hopefully be fixed soon. It does however provide useful information on the fly when firebug is not an option.

Download

You can download v0.1 from Box.net: Download
Size: 33Kb
Version: 0.1
Author: Mark Holtzhausen
Tested Browsers: Firefox 3.6, Firefox 4.0 , Chrome 10.0.648.151
Download Link: Box.net

Documentation


$(‘selector’).inspect(obj,’title’);

At this point there is really no more to it than that.

14Feb/11Off

Magento Translations

Magento’s inline translation mechanism, like most other components in Magento, are scoped to a module. You can implement one or more translation CSV file for each module in it’s config.xml file:

<config> <modules> <Namespace_Module> <version>0.0.1</version> </Namespace_Module> </modules> . . . <frontend> <translate> <modules> <Namespace_Module> <files> <default>TranslationFile.csv</default> </files> </Namespace_Module> </modules> </translate> </frontend> </config>

 

The actual content of the TranslationFile.csv is a simple two-column CSV with the first column containing the translation tokens and the second column containing the corresponding translation to be used.

The translation files are located in:  app/locale/[en_GB]/TranslationFile.csv

You will notice I bracketed [en_GB]. This is the portion of the path that relates to which language_country the translations will be for.

28Jan/111

Code-Cowboys and Chuck-Norris Ego’s

So I’ve always seen developers grouped into two categories. Those who use vi on linux and those who don’t.

And frankly, I don’t particularly like the vi-coders. They are mostly arrogant, obnoxious and a general pain in the ass. They spend more time being derisive toward anybody that uses anything other than that gnostic fossil of an editor than they spend actually doing anything useful.

They are high-speed coders.. you can watch their fingers fly across the keyboard and the lcd screen flickering with impressive-looking junk. Watch carefully enough though, and you’ll notice they hit the backspace button about twice as much as any other key on the keyboard. Just because you type like a hollywood-hacker does not mean you can code.

They are all boastful because they can beat you at any task any time anywhere. Got a problem to be solved.. they can do it in 10 seconds flat. What they don’t tell you is that nobody will be able to pick up their shit code later and fix anything in it.. Generally speaking, if you have to fix code produced by these cowboys (and you can bet your ass you’ll have to), you’ll end up rewriting the entire section. The cowboys are so busy typing, they don’t take the time to think about what they’re typing. And inevitably somebody else has to come pick up the pieces.
Just because you can type like superman on speed does not mean you can code.

Find yourself using a development tool, an ide or a calculator and they’ll come pick a fight with you – telling you that you’re stupid and it could be done so much faster (read: crappier), easier (read: I have an ego the size of a house), and without noob crutches (read: I can’t learn to use anything newer than a pimped out notepad).
Just because you type like a hacker doesn’t mean you can code.

Wake the fuck up!

  • I don’t care how fast you type. I care how accurately I type.
  • I don’t care that you can do anything via Linux command line. I do care about using tools that will help me keep the big idea in mind.
  • I don’t care that you think you are Chuck Norris. I do care about producing code other people can actually read, reuse and alter. As opposed to your superman-shit that has to be replaced all the time.
  • I don’t care if anything with an icon on it is for noobs. If it makes me work faster, more efficiently and more effectively – bring it on.

You are like those hippies still driving a VW beetle with low profiles, tinted windows and a nodding little jesus on the dash. Thumbing your nose at anyone driving anything other than your bucket of bolts. We are not in high-school anymore. And us ‘noobs’ are definitely no longer interested in locker-room comparisons.

We don’t care about your penis-size, we just want to get the job done.

Most of the time the job that you so spectacularly fucked up in 10 seconds flat.

11Oct/10Off

Are Accordion Forms Better ?

478790_loan_applicationMost modern web applications require forms to be filled out online. With more and more functionality being moved onto the net, more and more information needs to be captured there too.

The growing challenge is to keep your web-based forms easy to use, accessible to all types of users and keeping the frustration and irritation level as low as possible.

A List Apart did a small study with Etre, a London-based usability firm, to test the effectiveness of accordion forms.

They tested 4 different kinds of forms on 24 average users:

  1. Standard multi-page forms
  2. Single page form
  3. Single page accordion form – opening and closing sections were up to the user
  4. Single page accordion form – opening relevant sections were guided by ‘continue’ button.

Conversion Rate

Maybe owing to the fact that their study was so small, or because their users all had about 3 years internet experience in their backpacks, the conversion rate remained the same for all the forms. In other words, nobody quit their forms halfway through, no matter which of the four forms they encountered.

This is good news really. It means that you won’t necessarily gain any benefit from moving your forms over to accordions. If you have old-style forms, you won’t necessarily notice an increased conversion rate if you change your style.

Of course, that doesn’t mean giving your forms a face-lift that comes along with a redesign won’t give you a better edge.

Speedy Forms

When it comes to how fast users were able to complete their forms, it should come as no surprise that the accordion form that guided users with a button (#4) came out on top.

I, for one, am happier the less time I have to spend filling out a form.  Moving your forms over to accordion forms might not get you better conversion rates, but it could just make for happier users. That in itself is a big leap forward.

Accessibility

It is a really big, varied public that has access to the net. And all of them expect you to create your website to be usable, fun, interactive and aesthetically pleasing no matter what their individual tastes, disabilities or preferences are. That is why accessibility is fast becoming a major player when it comes to interface design.

Apart from the normal accessibility issues to consider, accordion forms have a large impact on people who steer away from the mouse as an input device. If you do decide to go for accordion forms, make sure that you include measures allowing your users to navigate the form using their keyboards alone.

15Jun/10Off

Mobile Devices First for HTML5

Since IE is so far behind with HTML5 implementation and Firefox is behind on CSS3 implementation, Webkit is the clear leader in HTML5 and CSS3 standards compliance.[1]

For various reasons, Webkit is also a favourite amongst mobile platform providers as preferred web content rendering engine.[Webkit on Wikipedia]

It stands to reason that counter intuitively for this iteration in web technologies standards compliance and availability, our mobile phones will lead while the desktop will follow.

In short: all the cool features in HTML5 and CSS3 will be on your phone before it hits your desktop. Strange, but true.

ExtJs now Sencha

ExtJs – that heavy but very useful Javascript framework and library we have all grown to respect – are moving along with the HTML5 mobile phenomenon and have partnered with jQTouch and Raphaël projects in order to propel them into the future and gear them form the new standards push for mobile devices. In this move, they are also rebranding as Sencha.

It is an exciting time to watch how a new web standard pushes itself to the foreground and becomes a force of it’s own due to nothing more than it’s merits. Laggers like IE and (to some extend) Firefox will have no choice to deal. It’s been a long time coming, and now it is here – in a big way.