Here are the posts tagged with trick:

Skipping frames in Python OpenCV

posted by Herman on Feb. 27, 2013, comments

Here's a quick pro tip for (more) efficiently skipping frames while reading video input in OpenCV: OpenCV comes with a grab that does almost exactly that:

capture.grab() # go the next frame, but don't waste time reading it 

So you can even write a very short little function ...... Read more

 

Clipping or adding a mask to a shape in Kinetic JS

posted by Herman on Feb. 24, 2013, comments

A short intro on how to clip object in KineticJS, the JavaScript animation library. You'll see it in action in my soon-to-be-released Chinese-learning game PinyinMaster!

One feature that is curiously lacking from the KineticJS JavaScript animation library is the ability to clip or mask shapes. For this reason, ...... Read more

 

How to get your picture next to Google results

posted by Herman on Feb. 23, 2013, comments

Alternative Title: How Google tricked me into using Google+ again...


I don't always try to improve the SEO of the IronZebra blog, but when I do, I make it quick and I make it count. - Most Interesting Man In The World

That's ...... Read more

 

Facebook, Youtube, LinkedIn and other CSS and JavaScript files from CDNs not loading on Ubuntu

posted by Herman on Dec. 3, 2012, comments

The Problem Story

For most of last week, I did not have a DSL Internet connection at all due to a broken physical line to the network. After the network errors were fixed I switched to a new ISP account, and all was well. Or so I thought.

My connections ...... Read more

 

Introducing Jade for Templates in Django and Flask

posted by Herman on Oct. 30, 2012, comments

Jade is a great template engine built for Node.js, and I recently had the pleasure of using it in a Node.js project. The built-in Django templating engine and Jinja2 have always served me well when it comes to templates for Django and Flask, respectively, but I quickly fell ...... Read more

 

Shorter Django Class-based Views Using Lambda Functions

posted by Herman on March 22, 2012, comments
A frequent pattern in Django Class-based Views, specifically when using it for forms, is the need to specify a success_url, like this: from django.views.generic.edit import FormView class MyView(FormView):     form_class = forms.MyForm     success_url = '/accounts/success/' However, you don't want to hardcode the URL like that, because that violates DRY ...... Read more
 

How to get Flash webcam to work on Ubuntu Linux

posted by Herman on Feb. 17, 2012, comments
If you're on Linux and trying to use a webcam Flash plugin, such as the one provided by Nimbb or red5-recorder, or many others to be found online, you might also run into this screen, as I did: Because of this, it took me about two hours of cursing to ...... Read more
 

Setting the Instance on a Django Model Form Class Based View

posted by Herman on Jan. 9, 2012, comments
I've been converting some of my code to the new Django 1.3 class-based views recently, and I must say that overall, it's been quite a frustration. I see the merits of class based views. It has resulted in some shorter code in certain places, and helped avoid some duplication (that ...... Read more
 

How to Generate Pixel Perfect CSS Sprites in Inkscape

posted by Herman on Dec. 7, 2011, comments
Figuring out how to make pixel-perfect CSS sprites on Inkscape can be tricky if you're relatively new to it. Here's a quick how-to on how to make the sprite .png you see below, starting from just the separate icons for the first row. In it is contained some of the ...... Read more
 

How to create separate Name and Surname inputs as one widget in Django

posted by Herman on Dec. 1, 2011, comments
Today I'll show you a nice little trick that's useful if you want your new users to input their first name and last name separately, so that you know where the separation is. This allows you to say things like "Hello, Mr. Smith" or "Hello, Keanu" on your site, instead ...... Read more
 

Element Inspector not Working in Chrome after Upgrade? Here's how to fix it

posted by Herman on June 4, 2011, comments
After upgrading Chromium on 64bit Ubuntu, I found that my element inspector suddenly started showing empty results. After some digging around, I figured out that the cause is that the chromium-browser-inspector package must also be upgraded, not just the Chromium package. To make sure it updates, I renamed /usr/lib/chromium-browser/resources/inspector, and upgraded the chromium-browser-inspector ...... Read more
 

Django: It's DRY, but you can sink your teeth into it

posted by Herman on June 1, 2011, comments
One of Django's core principles is the concept of DRY: Don't Repeat Yourself. Overall, the framework does a fantastic job at forcing you to follow that principle by default (and it's never a bad thing). Here and there, however, we need to add some initiative. I'd like to quickly share ...... Read more
 

The difference between jQuery bind() and live(), and where to use which

posted by Herman on March 28, 2011, comments
One of the things that makes jQuery so nice is its bind() function. This function is the primary method to attach events to your document. Any event (such as click, mouseover, mouseout, resize, or even your own custom events), can be bound to any HTML elements using this method. Then, ...... Read more
 

Rapid HTML development in Kate, using Zen Coding and the Insane HTML plugin

posted by Herman on Feb. 18, 2011, comments
There's a little-know feature in the latest versions of Kate (the open source text-editor) that allows developers to generate html markup in a flash.  It happens using a plugin called Insane HTML, which is based on the Zen-coding project. This allows us to type CSS selectors, such as the following: ...... Read more
 

Django: Showing the help_text of a model field as a title attribute in the form

posted by Herman on Jan. 22, 2011, comments
Maybe it's just me, but I find the standard way Django outputs the help_text on form elements quite annoying. If you use form.as_ul, it looks something like this: <li><label>Label text:</label><input type="text">This is the helptext.</li> Which is great, except it's really difficult to make it look nice. What I would rather ...... Read more
 

How to get comments for a certain object in Django

posted by Herman on Jan. 21, 2011, comments
The Django documentation gives very detailed explanations of how to show comments for objects in templates, but makes no reference to how to actually get the comment objects associated to a certain object when your still in the view. Well, there's a handy little function for that, called for_model, which is used ...... Read more
 

How to test whether a javascript variable exists

posted by Herman on Jan. 19, 2011, comments
Now and again, especially when working with different files and dependencies in Javascript, it's useful to be able to check whether a variable is defined without risk of getting a 'x is not defined' error. There is a neat trick to do it, which makes use of the javascript window ...... Read more
 

How to quickly create a Django edit form from object instance

posted by Herman on Jan. 11, 2011, comments
One of the great things about Django is that it makes creating forms painless and easy. However, it's not always obvious how to do certain things if you don't already know the functions. Creating an "edit form" from an existing Model object instance is one of those cases. For this ...... Read more