Oct 14, 2015

Removing merged git banches

If you work in a team, create many git branches and push them to the server, you may end up with many local branches that were merged and removed on the server. The following simple command will clean up your repository from local branches that track missing remote branches:

git fetch --all -p

Oct 12, 2015

Set environment variable when "cd"ing to the directory

I love automation! It saves a lot of time and helps to avoid mistakes.

When I work on projects, I sometimes need to set environment variables in the shell when I cd into a directory in the terminal. I ended up with a shell function that replaces the standard cd command. It checks if there is a .env file in the current directory and executes it on entering. When you leave the directory, if checks if the file .env_off exists and calls that. That file can contain normal shell commands, not just environment variables.

Do not forget to export variables in the .env file!

The script is here.

Jul 15, 2015

Evernote plugin for browsers

Just discovered a nice feature of Evernote plugin for Safari: if you search in Google it can show related results in your notes:


Jun 14, 2015

Chinese IP camera user name and password

I forgot what was the default user name and password to access one no none IP camera. However I found those settings "encrypted" in the configuration file:

acID=61656F6A6A
acPW=313131373131

After a couple of minutes the solution came with the help of phpsh:

php> $arr = array(0x61,0x65,0x6F,0x6A,0x6A);for ($i = 0; $i < count($arr); $i++) echo chr($arr[$i] ^ $i);
admin
php> $arr = array(0x31,0x33,0x31,0x37,0x31,0x33);for ($i = 0; $i < count($arr); $i++) echo chr($arr[$i] ^ $i);
123456

Yeah, really "strong" encryption...

Apr 3, 2015

Why scam emails fail



Dear scammers!

PayPal is spelled like "PayPal", not like "paypal".

There should be no space after the punctuation mark.

And, please, improw yor Ingiz before you write those emails, ok?

I am bored to get this in my mailbox. You can do better than this!

Mar 15, 2015

realurl and dd_googlesitemap are released for TYPO3 7.0

realurl still supports 4.5 LTS while dd_googlesitemap requires 6.x or newer now. Also in preparation to support the newer news extension, former news sitemap is renamed to tt_news.

I think realurl and dd_googlesitemap can be used with TYPO3 7.1 too but I did not test that version yet. O hope to make it soon.

If you wonder why this happens slowly, the answer is simple: there is daily work and family, which takes priority over free work. As to 7.0, my employer is interested in getting these extension work with TYPO3 7.0, so they sponsored it with certain amount of time. This is how I could get these extensions out.

Mar 10, 2015

Apple is over

Does anybody else think that it is a complete lack of style or it is only me so conservative?

I am getting really disappointed by Apple recently:
  • Killing Aperture - the "best quality" RAW processing program!
  • All those stability and Wi-Fi issues in all recent hardware
  • Maps flop
  • Abnormal prices when everything else goes cheaper
  • Annoying "continuity" forced in Yosemite
  • Inability to make something as convenient as DropBox but creating iCloud Drive, which nobody wants to use
  • Trying to block Spotify instead of doing something similar

I start thinking about alternatives. Not because of the price but because it seems that Apple has finally lost its main key thing: usability.

I am still using iPhone 4s because all newer devices were not worth the money. And I am still on Macbook Pro 2011 with HiRes matte screen and Mavericks because it is the best working environment available now.

What will I do if my iPhone 4s or Macbook Pro breaks? What should I get next? Definitely not Samsung or Lenovo or Acer. But what? What notebook has the same great matte display with good resolution and colors suitable for photo manipulation? What phone works nicely with decent battery life?

Mar 3, 2015

Status update about RealURL

There are two things I want to tell today:

  • RealURL 2.x is still in the work and it will take time until it will become ready & public
  • A new release of RealURL 1.x will be out this or next week and it will be compatible with TYPO3 from 4.5.40 to 7.1.999 (without core compatibility layer). The same extension for all supported TYPO3 versions. 1.x releases will come out until 2.x is available and if there are bug fixes to publish.

Feb 18, 2015

Getting OS X keychain password from terminal

Sometimes I have to run curl queries in the terminal for hosts that have password protection. If I do not remember a [usually random] password or forget that the site is protected, I get a 401 response:

Atlas:~/Projects/**** [development] $ curl  -I 'http://host.example.com/'
HTTP/1.1 401 Authorization Required
Date: Wed, 18 Feb 2015 09:41:18 GMT
Server: Apache
WWW-Authenticate: Basic realm="Preview"
Vary: Accept-Encoding
Content-Type: text/html; charset=iso-8859-1

Than I have to go to my keychain to look up the password. Thanks to Alfred, it is easy to invoke the keychain but it means switching applications and entering the password for the keychain. I looked for the way to do this from terminal.

Here is the command:

rsnapshot, anyone?

Recently I came across rsnapshot as a backup solution that can do hourly, daily and monthly backups. I am interested in any experience but it is hard to find except for this.

Does anybody have experience with it?

Feb 13, 2015

bash completions for my "Projects" directory

Linux bash shell has a nice feature called “completions”. You type a command and you press a TAB key. This will bring you a list of options that the command supports for completions. You type the first letter of any option and press TAB again. Now the list is reduced only to options starting from that letter. And so on.

I use terminal quite a lot. All projects for my work are located under ~/Projects/Snowflake (I work for snowflake productions gmbh). To quickly go to that projects from terminal I added the following to my ~/.bash_profile:

alias "cds=cd ~/Projects/Snowflake; cd "

Now I can just type cds projectname and get to ~/Projects/Snowflake/projectname. But I have to remember project names. Many of them are German and it is hard to remember for me. Why not use autocompletion for that? So I made a new file in /opt/local/bash_completion.d:

Feb 12, 2015

GIT: show log since the branch was created

Quite often I have to use a git log command to show what was made in the branch:

git log development...feature/add-solr-news-search

One thing that I'd like to know is about using short notations. If I am on feature/add-solr-news-search, than I can use this:

git log development...

Git will be smart enough to figure out that it is about the current branch. Sadly it is not smart enough for this:

git log ...

I hoped it will figure out that I want a log from the parent branch to the current branch...

How good are you at Git?


Find out using Git Game! You need to clone the repository and look at README.md for the next clue. Ten levels, getting more difficult with each level.

Can you pass?

Feb 11, 2015

Quality is no compromise

When it comes to the code quality, there are no compromises. You either write good code or bad code. There is nothing in the middle.

Many years ago I read an excellent book about code quality named “Clean Code”. That book goes to extreme and not all recipes are acceptable but I read and re-read, thought again and again until I set my own rules to writing code.

I think I have a certain advantage over people, who start using PHP as their first programming language. I started with Pascal and used assembler in parallel during my first five years of programming. Neither allows compromises. Pascal is very strict and assembler is just a razor sharp to errors: one minor error and your head is off. Next I used C++, which was more relaxed but than coded in Java for a couple of years, which was also very strict programming.

PHP is very relaxed when it comes to quality standards. You can assign a string to a variable and compare it to the number or to virtually anything else. You can assign any type to any variable, return anything from the function or do not return anything at all. If the programmer did not have good practice with other languages, he may start writing code, which is not that good. It is not necessarily true but it happens.

These things came to me today when I tried to use my TYPO3 extension named sentry. This extension automatically catches all kind of PHP warnings and exceptions (that you do not normally see) into a centralised repository when warnings and exceptions for various projects can be viewed, analysed and processed:




Details screen for the first warning looks like:

Feb 10, 2015

SVN one-liner

Using SVN command on the old host to find modified files:

svn st | grep '[^MAD\?]'

Looks mad? ;)

Jan 27, 2015

When it fails...

Failures happen all the time in every aspect of our life. While I am going to discuss failures of software developers, methods to handle those failures can be also applicable to other situations, even for families and friends.

When something fails, we all are unhappy about it. When developers screw up an important launch, when hotfixes break the system even more, when the site does not go online in sync with related sites, it is a failure. Failures has to be handled.

How do people handle failures? There are different ways. One of the most dangerous and bad ways to handle failures is to start looking for the responsible person and blaming him for errors.

Why is it bad?

Jan 24, 2015

Opening images directly in Photoshop on Mac

I work with Adobe Photoshop CC 2014 quite a lot. Often I have to open JPEG images there from Finder. By default, JPEG images are opened in Preview. To open them in Photoshop I have to right-click on the image, scroll down to Open With..., wait until the pop up menu appears (or click it to open faster), find Adobe Photoshop CC 2014 there and click it. Too long.

Can this be simplified? Oh, yes!

Jan 16, 2015

Strange localisation code in the Extbase persistence layer

Quite often I see that people do mistakes when they work with localisation in TYPO3. This topic is quite complex and often misunderstood.

TYPO3 localisation is defined by the Frontend Localisation Guide document, which was written by Kasper. I was one of the early reviewers of the document before it was published. While screenshots there are old, the document is still accurate. Let's have a quick look how localisation of records is handled in TYPO3.

Record localisation in TYPO3

Note that we are talking about records here, not pages. Pages are localised slightly differently.

All localisable records can be logically divided into the records in the main language and in other languages. This is an important distinction. Main language in TYPO3 always had id equals to zero. Other languages are defined on the tree top level and have id values starting from one.

The record in the main language is very important because it contains all fields. Records in other languages may either contain all fields or only some fields that depend on the localisation. For example, a record like Event can have the following fields: