The Weekly Recommender is a weekly series that I plan to write for two purposes, giving myself a reason to revisit the content I encountered the past week, collect them in one place and make the highlights accessible to my readers. They don't necesarily have been published last week, I just found them during the past seven days. You can also checkout my profiles on Pinboard and Instapaper.
When dealing with character encodings in MySQL you soon realise that
utf8is not really UTF-8. UTF-8 is a variable-length encoding, that means ASCII characters require only one byte while it also supports more characters by requiring more bytes.
The MySQL character encoding
utf8has a maximum of 3 bytes, which contains most characters widely used in the western world. However, Chinese, Japanese or Korean alphabets require 4 bytes and therefore cannot be stored in a MySQL column that is encoded with
utf8. MySQL provides an additional character encoding
utf8mb4to support those characters. By the way, Emojis also require 4 bytes and
In this article I am explaining how to create
utf8mb4databases, tables and columns with plain SQL and with Doctrine ORM.
Update 25th of July 2016 Starting with MySQL 5.7.7 this is no longer a problem. More information can be found here.
It's easy to press star, like, favorite or bookmark in an app while consuming content. I do this regularly in Feedbin, Instapaper or Pinboard, but once I pressed the button I never revisit the saved stuff. There are many great articles, libraries and tools out there that I saved for keeping because they could be useful to me at some point in the future, but when I would need them I don't think about looking in my archives because I forgot that I encountered and saved them.
The Weekly Recommender is a new weekly series that I plan to write for two purposes, giving myself a reason to revisit the content I encountered the past week, collect them in one place and make the highlights accessible to my readers.
Since a few years I generate a new password for every service I sign up and I use 1Password to manage them for me. But one thing that bothered me for a while was the generation of new passwords. It involves a lot of mouse usage and I like to use the keyboard as much as possible. Also changing the password receipt is quite cumbersome and I wanted to have a faster way to generate passwords of differnet length and complexity.
Therefore I created a small PHP library and CLI script as well as a Alfred workflow to invoke it. I am using it for a few weeks now and it works great for my purposes.
If you are using Doctrine for a project that is bigger than very small you probably have encountered performance problems with hydration. Hydration is the layer of the ORM that transforms the data that is returned by the database into a form that is comfortable for the developer to work with.
Object hydration is the default one and it returns the data as objects. This provides the greatest convinience for the developer, but requires a complex and memory intensive hydration process. In most projects for 95 to 100% of the quries this is a reasonable trade-off, but then there is this single import or export script that deals with 100,000 of objects and object hydration takes too much time or consumes too much memory. For these cases Doctrine supports array hydration which creates arrays instead of objects.
And then there exist ultra-rare cases where you don't import a few hundred thousand rows, but something like 50 million and even array hydration is too slow. In these cases I have fallen back to native SQL queries in the past.
Most of the time I have too many applications and windows open on my Mac. Even on my 24 inch external display there is not much space left when I have PHPStorm or Sublime Text open and there is less space when I am not at home and only have 13 inches. When I write code or text I regularly look things up in another window, specifications for a feature, an API documentation or some other stuff and therefore I press
Cmd+Tabvery very often. If the information I need to get my work done is in more than one other window this system starts to fail completely.
Recently I caught myself pressing
Cmd+Tabto get to Safari, then
Ctrl+Tabto get to the next tab,
Cmd+Tabto get back into PHPStorm and after a few minutes this process starts again. What I needed was a way to temporarily hide the current top-most window to peak into the background.
In this article I am going to create a Peak keyboard shortcut using Keyboard Maestro to do exactly this. When the shortcut is pressed the current top-most window is hidden, pressing the shortcut a second time shows the window again. I am going to share not only the code for the shortcut, but also the process on how to create it.
When writing an article or code I often need to try something out or create a small benchmark. Typically I create a PHP file, open it in Sublime Text and run it in the terminal whenever I change something. Easy enough, but it happens regularly so I thought about automating this process.
On Friday I was procrastinating by reading some command line tricks articles and I encountered three commands I haven't noticed before:
lolcat. A little bit earlier someone also posted this Buzzfeed article with inspirational Andy Dwyer quotes and one thing let to another.
Quite often I have to write a script that takes data from a source, filter and converts it and stores it some way. Nearly every time I use the great data-import library by David de Boer and the Symfony Console component. It annoyed me that I have to write some boiler plate code every single time and therefore I created Console Import Standard Edition.
Today Bernhard asked on Twitter where we see asset handling going and I replied that Grunt or Gulp will take over. I am currently using Grunt in some of my projects (including to build this website) and Gulp for some smaller stuff. However, I wanted to move one of my larger Symfony2 projects from Grunt to Gulp for a while now and I took the discussion on Twitter as a reason to finally do it. In this article I want to explain some of the aspects of using Gulp (and Bower) in a Symfony2 project.
I use Gulp not only for building my assets but also to run my tests, code coverage and checkstyle and I will tackle all these aspects in these article.
In the beginning of May I spent a weekend with some friends in Prague, Czech Republic. Due to a late arrival and a thorough exploration of Pragues nightlife I had only half a day to walk around the city. Here are some of the photos I took on this weekend.
Last Monday Apple released a new programming language for the iOS and Mac platforms: Swift. Currently I am about half way through the The Swift Programming Language (iBook Store) book from Apple and I want to help you getting started to write some code in Swift. This is not a exhaustive guide, it introduces you to some of the basic concepts of Swift.
I just searched 15 minutes to find out how to resize a image using GraphicsMagick.
gm convert -resize 150x100 in.jpg out.jpg
This will resize the image
in.jpgto 150x100 and saves the result in
out.jpg. You can resize the image by either providing the width or the height:
gm convert -resize 150 in.jpg out.jpg gm convert -resize x100 in.jpg out.jpg