Twig template: find the length of an array

It's not immediately apparent in the documentation for Twig, but finding the size of an array in a twig template is simple:

{% if my_list|length > 10 %}
{% endif %}

Or, you can extract the size into a variable:

{% set size = my_list | length %}


demotivational posters - IF YOU SEE DOTS

Is Google preparing for the future by profiling you now?

This just in from the Desk of the Minister In Charge of Conspiracy Theories: there may be a more sinister reason why Google wants to force us to use our real names: advertisers. We all understand what a gold mine a social network is for distilling trends and statistics, usage habits, likes and dislikes.

We all understand how marketers drool at the thought of getting access to this data. But how much will they pay if Google can actually tie usage statistics directly to named people? Think about it: suppose I am a mass marketer. I can buy a database of names and addresses and take my chances with a mass mailout.

But what if I could buy usage data from Google, complete with names of individuals, and then cross reference it with the addresses I now have on file? Suddenly, I have a database of pinpoint data. I know their likes and dislikes. I know their habits. I know what they've been doing these past few months. And I have their phone number and address.

The good news is that this is just a far fetched conspiracy theory. Google's privacy policies imply that they will not do this. However, there is a hot debate about the concept of online privacy. A year from now, two years from now, five years from now, the idea of online privacy may completely change. It may be considered normal to share your online activities. It may be considered an acceptable practice to profile users, and then allow marketers access to these profiles. If so, Google is well positioned to provide the most accurate user data available on the web.

 None of it is happening now, as far as any of us know. But the world changes on a dime. There appears to be a long term method to this short term madness.

Writing PHPexcel to a buffer

The standard way to export an excel spreadsheet with PHPExcel is to have it written to disk, then extract that data using file_get_content(). But I am using symfony and wanted to be able to pass it around from a widget to a controller that would send it out with the appropriate headers. I didn't want to write to disk because it was a high volume application that would result in a lot of disk writes, and possible race conditions, if done poorly. Which is how I typically do things.

Not sure how to do it, I put a question up on stack overflow. I only got one answer, but it was the right answer, and I'm able to make PHPExcel write the contents of an excel file directly into a variable:

$writer = PHPExcel_IOFactory::createWriter($phpExcelObj, 'Excel2007');
   $excelOutput = ob_get_clean();

However, the guy that replied also made a snooty remark about how I was perhaps an idiot for not writing to disk first. I wrote a response saying that, while I appreciated his insights into my intellect, my question was how to do something, not his by-the-gospel opinion on whether or not I should follow the PHPExcel playbook.

Just before sending it, however, I started to wonder why he would say something like that, and whether or not he was just some crank trolling StackOverflow, so I checked out his profile.

Turns out he's one of the actual authors of PHPExcel. And rather well respected. I have 49 reputation points on Stack Overflow. He has 36,000. His opinion carries a bit more weight, I should think.

I sent him a note thanking him for his input, and then I voted him up.

This morning's email

TO: All Employees


Everyone, I won't be in to work today. Last night I tried to drown my sorrows, but my sorrows were stronger than I expected, and fought back and oh god it was horrible just horrible.