Fixing encoding issues on WordPress (comments display as question marks)

One of my dear friends in Russia subscribes and reads my blog :) how cool is that?

Well, we also discovered that her comments that she posts in Russian (using Cyrillic characters) don’t get saved properly into the database, and are displayed as a bunch of question marks ‘??????’

As I suspected, the character encoding was not set right. Older version of WordPress had latin1-swedish collation as default (weirdly enough). Latest version had this corrected, and the default is utf8, and you can also specify it in settings in wp-config.php file (as described in this Codex article):

define('DB_COLLATE', 'utf8_general_ci');

To fix this issue on existing installations, open your MySQL console (command line, MySQL Admin or PhpMyAdmin), backup your database (just in case), and follow these steps:

  1. Starting from the top, the database level, let’s make sure that the database encoding is correct:

    ALTER DATABASE my_wp_database CHARACTER SET utf8;
    
  2. While this applies to all the new tables within this database, it does not change encoding of the existing tables. So that’s why, we’ll need to go a bit deeper to the table level.

  3. Table level: make sure your table collation is set correctly:

    ALTER TABLE wp_comments CHARACTER SET utf8;

  4. Again – this change will be effective for all new columns within this table. For existing columns, we’ll need to go down one more level.

  5. Column level: set collaction on individual columns within your table.

    alter table wp_comments change comment_content comment_content LONGTEXT CHARACTER SET utf8;

    alter table wp_comments change comment_author comment_author LONGTEXT CHARACTER SET utf8;

  6. This will not change your existing data, but going forward, your comments will be saved and displayed with correct encoding.

Source: Codex article on converting database character sets

Free MongoDB online courses – developer and DBA tracks

I tweeted about the new MongoDB online education portal when it was announced, and signed up for both DBA and developer tracks (because I’m curious, mostly, even if I don’t become a Mongo DBA it’s still free knowlegde!).

The courses are available online and you can still sign up:

As a reminder, your friends can still join the course. We will be dropping the lowest week’s homework grade in the calculation of your score so students who join can still receive a certificate of completion.

I hope that my NYC peeps are all safe and sound after the Sandy hit, and those still with power and internet can take this chance and learn something new.

Startup infrastructure talk by Paul Hammond

Earlier this week Etsy hosted an excellent talk by Paul Hammond on scaling Typekit.

If you don’t know – Typekit is a service that lets you use beautiful fonts on our website. They provide fonts and hosting, and were acquired by Adobe in late 2011.

Here’s a summary of the main points from the talk:

Running a startup looks like this – Wallace trying to lay tracks in front of the moving train. Things change quickly, and you a task at hand – make sure your site is up and running.


*I love Wallace and Gromit so I had to borrow and include this pic as well :) Hope Paul doesn’t mind

The life of startup has 3 types of endings:
– Become profitable
– Get acquired (for technology, talent or product)
– Fail

Scaling HGH startup HGH can be summed in 3 simple steps:
– Find your biggest problem
– Fix it
– Repeat

There’s one main rule when you’re running a startup: don’t run out of money.
And one thing that requires the most money is human talent and time – don’t waste it. Outsource/buy everything that saves you time.

In the beginning, it doesn’t really matter what you use, as long as you get the job done. Paul calls this the “minimum viable infrastructure”.

Minimum viable infrastructure looks like this:
– Source countrol = Git
– Configuration management = Rsync and bash
– Servers = EC2
– Backups = via command line with S3cmd
– Monitoring = Pingdom

If you get a chance – definitely go see Paul’s presentation in person, he’s great. Full deck of his talk is available on his site.

Manage or code: pick your own adventure

I was presented with this question the other day: can you NOT code? The answer is: I can’t. I’m not the best developer out there, and my current role does not really require coding. But I really love and enjoy it, and whenever I get a chance, I like to get my hands dirty on some quick-win or hobby projects (that’s why I like Javascript and Python that let me get the job done quickly with minimal dependency overhead)

The next question that comes to mind then: do you prefer being a developer or a manager? This is a very interesting one, and I think I could go either way. Being a developer is fun. Developers’ lives allow for a delicate balance of logic and creativity. And because the nature of development is so focused, they can truly become masters, experts of their domains. Developers are like alchemists with some special secret knowledge, who can turn clay into gold with their magic touch. And of course, that earns them lots of respect (and monetary rewards too).

A great technical manager is ideally a former developer, so he/she understands how other fellow developers think and work. This manager knows how to make developers happy and get great results: give them uninterrupted environment, challenging and well-defined tasks, reasonable schedules and timely and clear feedback. Managers interact with other roles in the company, so they get the visibility to everything related to a project, from different people and angles. A manager’s world is not binary: there are complex human interactions, lots of details to weigh and decisions to make. Great managers are like orchestra conductors: they know how to get everyone play their instrument in harmony with others and produce a beautiful tune.

So if both sets of skills are so valuable, can one person be a programmer and a manager at the same time? The answer to this: probably not. You could have a technical manager who spends a small percentage of time on quick one-off coding tasks. Or, you could have a great developer who plays more of a lead role, but stays very close to the code. If you start demanding of someone to be a great developer AND manage the whole process, it is bound to fail at some point. These roles demand different dynamics: development requires a lot of focus, while managers constantly interact with various people and thus get interrupted quite a lot.

So I think these scenarios work well:

– You’re a technical manager who no longer codes or who codes occasionally and on a small scale
– You’re a developer who takes a lead role within the tech team, but not heavily involved in larger project management

Should a CTO code? Be able to – absolutely. Do it as a daily routine task – no. Hire 2 people – a great manager/leader and an awesome developer, and you will win in the long term.

Don’t judge a startup by its stack

I’ve been interested and reading up in startups in NYC, curious to see what stacks they use to power their applications.

A guy with background in Java set up a Java shop. Another company runs .NET as chosen by their CTO, and also because Microsoft allows startups use their software free/cheap for the first few years under Bizspark. An online publication that runs on WordPress is being moved to Drupal because the CTO is an expert in Drupal.

Question: Does the benefit of expertise in a particular stack outweigh the benefit of using modern solutions that are more attractive to programmers?

What do some seasoned experts think? This deck by Joe Stump provides some advise:

As far as technology, go with what you know. – Marc Cuban

The technology stack you choose is an implementation detail. – Joe Stump

What do you think? Ruby/Python/PHP are easy choices nowaways, but would you go with Java/.NET for building your next big project? How about a newcomer – node.js?

Adobe leading with web standards: PhoneGap and CSS Custom Filters

Everyone remembers the HTML vs Flash debate from a couple of years ago, when it seemed like Adobe fought hard for Flash to stay relevant, when Apple declined to support it on iPhone. Fast forward to today, and look, ma – Adobe embraced mobile and web stardards, and more than that – now it owns 2 fascinating technologies that were discussed at the last Show&Tell meeting presented by our UI guru Brian.

PhoneGap (also known as Apache Cordova)

What it is

Mobile development made easy – build apps for 7 mobile platform using web standards (HTML/CSS/Javascript)

Why use it

Quicker development for multiple platforms. Instead of time/effort investment for native iOS, Android, Windows development separately, use one codebase and PhoneGap will adapt your app to multiple platrforms. Allows access to native device stay relevant.

Why not use it

Some complex functionality will not be possible – augmented reality (AR) apps, high-performance games, so in these cases you will still need to develop native.

However, looks like for a good chunk of apps out there, PhoneGap would be a great way to go. One of the examples of their site is BBC’s Olympics app. Also, read their blog post on questions and myths about PhoneGap.

CSS Custom Filters (also known as CSS Shaders)

What it is

Web-standards, CSS-based cinematic effects in your browser. So you can warp your text in crazy ways, while adding blur or color inversion to your whole web page.

Why use it

Because the technology is moving forward fast and you want some crazy effects done with web standards! Forget Flash :)

Right now it’s in experiment mode and only works in the latest Chrome Canary or WebKit release, but give it a try – it’s really REALLY cool!

Variables in Mongo query

If you ever want to create dynamic queries that you will then pass to a Mongo command, here’s how to do it:

var query = {};
query['key'] = value; 

// check a condition		    
if(myvar1===myval1){
   query['key1'] = true;
}

coll.find(query,{_id:0}).toArray(function(error,results){
    if(error) callback(error);
    else{
	callback(null,results);
    }
});