Sep 20, 2012

Developers and business

Developers are bad in business questions if they work for a company. However they become much better in business if they become freelancers. Freelancers have to think about technical skills and selling their services while company developers do not have to bother with selling at all and mildly interested in improving their skills (it does not directly correspond to their income).

Conclusion: a typical freelance developer should be better than a typical company developer.

Sep 3, 2012

Creating OS X recovery partion, part 3

Thanks to Antonin Hildebrand, who found a method to do it in a much easier way to recreate the OS X recovery partition than I described earlier.

Aug 6, 2012

Sudden hue shift to blue in Mountain Lion

Today I noticed that running Google Chrome in Mountain Lion causes hue shift to blue on my MacBook Pro LCD display. I work with photos a lot and have a calibrated display. Sudden hue shift is very noticeable when you are used to work with calibrated, neutral gray monitors.

It seems that issue is specific to Mountain Lion only and it is caused when the system switches between integrated Intel and more powerful ATI or Nvidia graphics cards. There are two threads about this: here and here. At the end of the first link there is a post that reseting PRAM fixes the issue. I tried that but I cannot yet confirm if it fixes the issue or not. One thing I noticed is that after reseting PRAM my MBP does not switch to the advanced graphics when I run Twitter or Chrome. Before resting any of this apps were causing such switching.

In case if you have hue shift issue, I would appreciate if you write that in comments. There is no need to write if you do NOT have the issue :)

Thank you!

Update: more links about the issue:
Apple communitiy #1
Apple community #2
Apple community #3
Apple community #4
MacRumors thread

So it is a Mountain Lion bug.

[Update, Aug 14, 2012] The issue is fixed in OS X 10.8.1 (developer preview build 12B13).

[Update, Sept 02, 2012] The issue is back in OS X 10.8.2 (developer preview build 12C31a).

[Update, Nov 27, 2012] It appears that the problem is specific to MacBook Pros with SSD. Looks like they load too fast. OS X runs multiple tasks in parallel and it tries to load the correct color profile into the discrete card too early. To solve the issue, log out from the current user and log in. Hue will disappear.

Aug 3, 2012

Quick tip: magic methods and PhpStorm

If you use PhpStorm and add magic methods to a class (__get/__set/__call), you may notice that PhpStorm generates warnings for undefined class attributes and methods. A typical example is when you implement automatic getters and setters for protected instance variables:

Jul 6, 2012

OS X Lion and local DNS issues

Many people use their Macs for local development. They have Apache web server running on their computers. This works great. However there is an issue with Mac OS X Lion, which causes DNS issues with ".local" domains. If you use ".local" for development, you may notice that your local Apache seem to answer very slow (5 seconds or so). In fact, it is not Apache, it is DNS lookups that take most of the time. In this article I collected several ways to solve the issue.

The are several reasons for this. Therefore there is no one single solution for all cases. You can to try one or more or even all to find what works for you.

Apr 12, 2012

When not to use typoLink

For a long time I tell everybody to use typoLink to create links inside TYPO3.

A “go”:

$url = $this->cObj->typoLink_URL(array(
    'parameter' => $GLOBALS['TSFE']->id
));

A “no go”:

$url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];

But there is one case when you absolutely must not use typoLink to create the URL. It is when the URL points to the eID script. Why? Because there is no resolving of the speaking URL inside eID anyway. So it is a complete waste of time and memory to have something like /path/to/my/news/page/news/how-i-bought-a-car.html?eID=tx_myext_eid.

Just do it like this:

$url = t3lib_div::locationHeaderUrl('index.php?eID=tx_myext_eid').

That's the right way.

Mar 5, 2012

Why did 65% of russians vote for Putin?

This article is unusual for my blog because I never talk politics here. I consider this article to be one of the most important articles in my blog and my life.

Why did I write this article?

On December 7th, 2011 FoxNews showed a report about protesters in Moscow. Here it is:

The problem is: it is not Russia in the video. It is Greece. Fox News lied to its viewers. Same do other news agencies. They show you what you should see, not what really happens in Russia. They tell you what you should believe. And usually you do. Now read the truth.

I am russian. I lived in Russia until I was 27, than I emigrated (you will understand later why). But I am still russian, I follow every event that happens in Russia, I visit it regularly and I have relatives there. Most likely I will return to Russia in the near future. If you want to know the truth about Putin, read on. I must warn that this article represents my own views and talks about the history as I remember and know it. Some bits can be incorrect but general picture should be right.

I must tell that this is strictly my personal views on the subject.

Feb 29, 2012

Feb 23, 2012

Storing TypoScript in the file system

There was an interesting question in the TYPO3 mailing lists: “How do you store TypoScript?”. Here is how I do that.

I store TypoScript in the file system. There is a main file, which is included to the site TypoScript template using statement. This file contains statements to include other files.

Other files are created logically, per feature or group. For example, I usually have:
  • constants.txt – sets all constants
  • config.txt – includes all “config” settings (such as “config.absRefPrefix”, etc)
  • page.txt – creates PAGE object, including “page.headerData”
  • seo.txt – all SEO options (some “config” settings come here)
  • news.txt – includes the news plugin I use
  • home_page_objects.txt – all TypoScript object, specific for home page
  • ...and so on.
Plugin files (such as “news.txt”) also include files from corresponding extensions using . “Include static (from extensions)” is empty in the TypoScript database record. That allows granular control on all included files. TypoScript from the css_styled_content extension is included into “page.txt”.


I avoid having multiple places for the same set of options. For example, all news settings will be in “news.txt”. The only exceptions are:
  • seo.txt, which contains certain SEO options from “config”
  • “page.headerData”, which can appear in other files as necessary
However, “plugin.tt_news” will never appear outside of news.txt. Thus, if I need to choose news settings, I always know where they are. Also I can replace news plugins or remove it completely as necessary.

The buggest advantages of such approach are:
  • It is versionable. I use Git to store projects and store TypoScript in Git.
  • It is very clean and clear. I always know where the stuff is. Any new maintainer will be able to see it too immediately.
  • It allows to customise, replace or remove features very quickly.
If you have your own practices, please, share in comments.

Feb 22, 2012

Apple integrates Vimeo to Mountain Lion instead of YouTube

Apple integrates Vimeo to Mountain Lion, skips YouTube. This is interesting news, which shows several important signs to us.

Firsts, Apple does not follow trends, it creates trends.

When Apple refused to support flash, many saw this like an obvious fault, which would seriously decrease ratings of iOS. That did not happen. Flash came to Android but was unusable. In the end both Adobe and Google abandoned Flash support for mobile devices.

Secondly, if the service is absent on iOS, it looses a lot of audience.

While Facebook is a huge web site, it is not really present on iOS. Due to unknown reasons Facebook and Apple did not agree on Facebook integration to iOS. As a result Apple integrated Twitter support to iOS, which gave Twitter a huge boost: lots of twits now come from iOS devices. iOS is also known as the OS, which makes the most of Internet traffic these days.

Thirdly, Google should not have fought Apple.

When Google decided to make a concurrent product and hired a former Apple employee, who was working on iPhone to create Android, this was unfair. Apple now ignores all new Google services and includes products from alternative solution vendors. Twitter instead of Google Buzz, Vimeo instead of YouTube.

Will Apple remove YouTube and Gmail support from iOS?

I do not think this will happen soon but it is likely. Apple becomes more and more agressive in defending its inventions, so I do not see why they would promote competitor's services any more. Personally I have nothing against Google (I like Gmail) but Apple may think different.

We can also remember a huge scandal when Google cheated on Safari users, implementing workarounds for Safari privacy policy to avoid cookie blocking by users. Not nice at all.

“If you are against us, you are not with us”, that's current Apple policy. If somebody acts against you, you do not have to be good to him. Sounds natural.

Feb 16, 2012

Jedi programmers

There are three levels of coding that you can master: dumb, professional and jedi.

Dumb level is for those, who go for straight solutions, who never learn anything new, who do not care to find a better solution that they already know. Dumb programmers are best seen when they receive a bug report. Upon receiving a report, they start adding messages to the web page content at every possible code point, including points that are far from the cause of the problem (meanwhile visitors wonder what does that rubbish mean on the site). Sometimes dumb programmers just go and “fix” the issue by making the straightest, fastest and dumbest solution possible: the solution, which is neither good, nor it is entirely correct. Fixing typically happens on the live host and disrupts host's work with error messages and down times. Well, it is dumb.

Professional level is for those, who understand the importance of learning, the priority of the quality and that the first solution is not necessarily the best one. When it comes to bug fixing, they realize that to fix the issue, they need to find its cause. Professional people typically investigate first. Often they use developer's log, debug messages that are visible only to them or a debugger. People, who mastered the debugger, usually figure out the cause of the bug faster. Next they try to resolve the bug in a good way. Professionals do not take the first obvious approach but try to evaluate it from all sides and see the consequences of their fixes. They usually work at development host and choose to integrate their changes to the live environment with no or minimal disruption.

Jedy never do like dumb people but they often do the same as professional people do. Often, but not always. For example, with bugs a jedy can investigate the bug by just clicking and looking. Often they do not need to use the debugger or debug messages at all. And here I can't resist posting a quote from a sixth Harry Potter book:

Jan 31, 2012

Mac: adding a keyboard layout using AppleScript

Update: This no longer works in Mavericks because Apple changed the whole layout window. Last working OS version was Mountain Lion.

We have a special keyboard layout in the country, where I live (Latvia). It includes certain special letters: like ā, ē, ū and so on. Many people here set Latvian keyboard layout as a default. However I cannot do that because this layout has one major disadvantage for people like me.

Those special letters are typed by one of two ways: Alt+normal letter or '+normal letter. While the first way is goot, the second one is bad for programmers. I often use ' in the code, so having ' as a "dead key" (this is how it is called officially) is not suitable. But I still have to type those latvian chars sometimes. Until yesterday I kept English US layout as a default and added Latvian manually when I had to type latvian letters. This is a multiple move-and-click process. Yesterday I finally found a way to automate addition and removal of the layout.

Jan 17, 2012

Current life

I am not very much visible in TYPO3 these days. So I though I would give a short update on what I am doing or going to do.


Jan 10, 2012

Cleaning and optimising cache tables in TYPO3

There is an important issue with cache tables in TYPO3, which I am going to address in this article. The issue can become critical for projects with a limited disk space, projects with lots of user groups, which use indexed search or Solr, or projects with lots of pages.

Cache tables are designed to provide a high-performance access for simultaneous reads and writes. This means that several reads at a time should be possible as well as several writes and none should block each other. This is possible when cache tables use InnoDB MySQL database engine. InnoDB provides concurrency and data safety against sudden failures. TYPO3 uses InnoDB for several critical tables, including cache tables.

Sometimes cache tables can grow a lot. The more records exist in the cache table, the slower it is to find a necessary record there. TYPO3 provides a special scheduler task to clean up old cache records. If you have TYPO3 4.6 or newer, you should always use that task.

However, there is a certain fact that very few users know: running the task will remove entries from the table but it will not recover the disk space taken by removed records. InnoDB does not reuse the space when records are deleted. It always appends new data to the end of the allocated data file. Thus it is possible to have a fully empty InnoDB table, which takes 100GB on the disk.