01 May 2013 - After the site upgrade, all passwords were reset and you will need to ask the site for a login reset on your first connection.

Not PHP-GTK

Introducing array_column() in PHP 5.5

Ben Ramsey - St, 20/03/2013 - 22:48

Earlier today, David Soria Parra declared a feature freeze on PHP 5.5 and tagged php-5.5.0beta1, but not before merging in pull request #257, which includes my humble addition to the PHP programming language: array_column().

The story of array_column() begins at PHP Tek in 2008. As I recall, it was Spooons who suggested it to me. It is functionality that nearly every developer has to implement in user-land code at some point in their careers, so I felt it only natural that it be built into the language, so I did just that.

My original patch for array_column() was written for PHP 5.2, but it sat around collecting dust for many years, until April of last year, when PHP moved to git and GitHub. That’s when it became easy enough to apply the patch and send a pull request, which I did. It wasn’t quite that simple, though, since I had to follow the official PHP project RFC process, but it wasn’t a pain either.

My goal for array_column() was simplicity. Many implement the functionality in different ways, and many call the function by other names (such as “pluck”), but I wanted to keep it simple and recognizable. It follows this function signature:

1 array array_column(array $input, mixed $columnKey[, mixed $indexKey])

Given a multi-dimensional array of data, array_column() returns the values from a single column of the input array, identified by the $columnKey. Optionally, you may provide an $indexKey to index the values in the returned array by the values from the $indexKey column in the input array.

For example, using the following array of data, we tell array_column() to return an array of just the last names, indexed by their record IDs.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 <?php $records = array( array( 'id' => 2135, 'first_name' => 'John', 'last_name' => 'Doe' ), array( 'id' => 3245, 'first_name' => 'Sally', 'last_name' => 'Smith' ), array( 'id' => 5342, 'first_name' => 'Jane', 'last_name' => 'Jones' ), array( 'id' => 5623, 'first_name' => 'Peter', 'last_name' => 'Doe' ) ); $lastNames = array_column($records, 'last_name', 'id');

If we call print_r() on $lastNames, you’ll see a resulting array that looks a bit like this:

1 2 3 4 5 6 7 Array ( [2135] => Doe [3245] => Smith [5342] => Jones [5623] => Doe )

And that’s all there is to it. I hope you find my little addition to the PHP language helpful. I had a lot of fun writing it, and following the PHP RFC process was a great learning experience.

Kategorie: Not PHP-GTK

Ideas of March

Ben Ramsey - So, 16/03/2013 - 19:58

Twitter pretty much killed blogging for me. When I signed up for the service six years ago, I was blogging quite a bit, but Twitter’s rapid-fire, ultra-short status updates have given me a 140-character attention span. Not only did I stop blogging, but I stopped reading blogs, too. Reading and writing became a chore. While I could fire off a message on Twitter within minutes or seconds of crafting it, blogging was an endeavor that took much longer—hours or even days, at times.

You see, the thing is: I care about the words I write. Probably too much. But with Twitter, I stopped caring. Its ephemeral nature means I don’t have to care. Until recently, even searching for posts on Twitter only went back so far. When I blog, I have to read and re-read the words I have written, over and over. This doesn’t stop after I finally decide to publish a post. Instead, I continue to pore over my post, reading it in its published form and eagerly awaiting potential comments. I’m doing it even as I write this. It can be stressful.

When Google announced this week their decision to shut down Google Reader, it stirred up unresolved emotions in me. I know that sounds silly, but while I haven’t been reading or writing blog posts very much over the last six years, the concept of the blog still holds a dear place in my heart. Blogs are important communication and knowledge-sharing tools. They have revolutionized the way we spread information (or mis-information). I believe they are still important and have a continuing part to play in how we communicate with each other. Without the concept of the blog, it would have been impossible for many of the folks we consider leaders in our various technology communities to have had a platform to share their voices and ideas.

Earlier this year, I made a resolution to myself to begin reading blogs again. I returned to the Google Reader account I had set up long ago and connected it to NetNewsWire on my desktop and phone. I have been pretty good about reading things, and I have tried to treat it a bit like I treat Twitter; if I get behind on reading, I just “mark as read” and continue on, without stressing over it. Some of the things I’m reading have been inspiring me to write again, and I felt it was only a matter of time before this incessant writer’s block was broken and the words began flowing freely again. I believe that time is now.

This isn’t a post to discuss the ramifications of Google’s decision to pull the plug on Google Reader. Nor do I want to consider whether blogs are dying. Those are thoughts better left to other bloggers. What I do want you to think about, however, is how blogging has affected you, whether through your own blog or the blogs of others. Has it helped you be more successful? The answer for me is “yes,” and for this reason, I resolve to read even more, be liberal with my comments on others’ blogs, and write without fear.

Thanks goes to Chris Shiflett for inspiring this post. Be sure to take time and read his original Ideas of March post from 2011, as well as his most recent one.

Kategorie: Not PHP-GTK

The Firebase Public Beta

Anant Narayanan's blog - St, 13/02/2013 - 23:54

Today, we announced the opening of Firebase Beta to the public!

It’s been a few months since I joined the team, and it’s been one hell of a ride. Working at a start-up was everything I imagined it would be, and more. I can easily say that I’ve never been as productive as this before, and that there’s a lot of joy in putting a product that you played a critical role in building, out in the world for every one to see. The best thing about working in a small team who are all in the same room is the speed at which everything moves. It took me an evening to implement Persona support for Firebase, but it took even lesser time to get the feature out to our users. That’s when I learned that the amount of time elapsed between making something and shipping it can play a huge role in motivating me, and I suspect many other developers feel the same way.

Last night the entire team was in the office until midnight, polishing and tweaking everything to make sure we were ready for today’s release. Bugs were found and fixed in minutes. We even managed to implement an entire feature that we decided was important to have. The dedication and caliber of my colleagues continues to amaze me.

The real reward, however, is when I talk about Firebase with other developers. The response has been overwhelmingly positive – from veterans I know at Mozilla to folks who are just learning JavaScript at Meetups. The look on their face when they first understand how Firebase works, that ‘aha!‘ moment, is priceless. A few moments later, you can almost hear their mind sprinting through the possibilities of what they could make.

We have an excellent product, and now is the time to spread the word and help people build amazing things with it. 2013 is going to be a fun and challenging year!


Kategorie: Not PHP-GTK
Syndikovat obsah