Model saving vs. model validation when uploading files

Newbies to Yii and ActiveRecord design pattern, are often confused, what is difference between $model->save() and $model->validate(). though difference should be obvious, there are many code examples in the forum and Yii wiki, that proves, that many people still doesn’t understand it. Especially, when it comes to performing additional operations around saving model, like file upload.

Read More “Model saving vs. model validation when uploading files”

Using Twitter Bootstrap’s popups like real menu items

Twitter Bootstrap framework is fabulous and thanks to many Yii extensions supporting it (Yii-Boostrap, Yii-Booster, Yiistrap, YiiWheels and more) using it in own application is like snapping with fingers.

One of the best features of Bootstrap is a very easy way of creating menus and adding popup menus to elements (like buttons). However, in default implementation popups are oriented toward working just like a fancy links — i.e. redirecting browser to destination URL. In this article, you’ll find how force them to work as real menu items — i.e. capturing their onclick event and doing something with content.

Read More “Using Twitter Bootstrap’s popups like real menu items”

Self-documenting code is a myth

How many times did I heard that stupid talk? “Comments aren’t needed! Code should be self-documenting”. If you think this way, then… believe me or not, you’re wrong. Good developer does not need comments to describe, what he or she is doing. But there’s always a purpose for doing something, which must be documented for future reference. If you think, you can achieve the same with self-documenting code, you’re going strictly into violating fourth of Five major software development rules. Which says: “Premature optimization is the beginning of all hell!“.

Read More “Self-documenting code is a myth”

CSS and JS minifier/beautifier that rocks!

I definitely love and adore Avivo’s CSS/JS Minifier/Beautifier. Mostly for options that similar tools lack. Like: braces on own line, preserve empty lines and ability to select intend character.

It has a small bug in CSS Beautifier. Every : is beautified to : (with space), which breaks pseudo-classes like :hover and and pseudo-objects like ::before. But, this can be easily fixed (manually; simple find-and-replace in text editor).

So, even with this, Avivo’s tool is just fabulous!

Upgrading MySQL on-board XAMPP

XAMPP is a great package of Apache, MySQL, phpmyadmin and some others (actually the best I’ve ever used). The only disadvantage of it, is that guys behind this project haven’t got much spare time and update it fairly slow. Newest XAMPP version (1.8.1) is over a year old now and still has MySQL 5.1.41 on-board, while version 5.6.10 is available for download, as of writing this. Here are some tips on manually upgrading MySQL on-board your XAMPP package.

Simple copy & folder switch does the job and is enough to upgrade MySQL on-board XAMPP from 5.1.41 to 5.6.10. However there are slight side effects, you must consider.

Read More “Upgrading MySQL on-board XAMPP”

HTML-to-Markdown on-line tool, that actually works

If you search the web for “convert HTML to Markdown online“, Google will return you a quite big bunch of useless links. Mostly pointing to websites that only claims that can do HTML-to-Markdown conversion (while actually doing opposite one) or that are doing conversion in a really poor quality (failing on simple HTML).

After digging through many of them, I finally found “html2text” — a simple, yet powerful Python script that just do the job. It was the only online tool, that I found, that actually was able to convert my simple (three unordered lists with some links inside) HTML text into pure Markdown.

Using tcpdump for capturing data sent by TK102 GPS tracker

Xexun TK102 GPS Tracker and most of its clones can send localization data either via SMS messages (some models offers just a pure data, that you have to analyze yourself, some sends it out along with Google Maps link) or via GPRS protocol, directly to specified server. Which then can analyze and visualize that data. SMS sending works just great in most cases, while getting GPS data via GPRS can be a real pain in the ass. This post is written with hope to help you a little bit, if you’re facing the same problem.

Read More “Using tcpdump for capturing data sent by TK102 GPS tracker”

TK102 connector / plug / cable type (and schematic diagram)

The Xexun TK102 GPS Tracker and most of its clones is using something, what English Wikipedia calls UC-E6 proprietary (non-USB) plug. So, this is neither microUSB nor miniUSB as I was assuming in the first place.

Here you’ll find some links to information about this plug and some simple schematic diagram for tracker.

Here is mentioned schematic diagram:


If you’d like to purchase a cable for Xexun TK102 GPS Tracker, then eBay should be your friend. If, on contrary you’d like to craft your own cable, then this great article will help you or can be at least a good starting point.

node.js based TK102 listener

There is a fairly good looking listener for TK-102 localizers, based on node.js. You can find it in this GitHub repository. I wasn’t able to check it out yet, but from the first sight it looks promising.

The only thing, that concerns me, is that many TK-102 clones requires properly formated reply from the server, to continue connection and send actual GPS data. If localizer does not receive such reply, it will break connection. I don’t see nothing about sending reply back to localizer, so I’m worried, if this will work with these clones requiring reply-back. But… we’ll check it, we’ll see it! :]

Xexun TK102 GPS tracker master password reset

Many sellers will tell you, that if you forget your master password (if you change it ever from default 123456, as you should do), then you’re deep in black ass, and the only option for you, is to send tracker to them or to the producer, to reinstall (re-flash) original firmware. This is lie in most cases and probably it is aimed to fool people paying extra money for reseting tracker, they can easily reset themselves. Here is how.

Read More “Xexun TK102 GPS tracker master password reset”