NBA Playoffs 2016 second round recap

The second round of the Playoffs has come to a close, and it’s been a nice mixture of surprises and things that went almost exactly as anticipated.

East

1. Cavs vs 4. Hawks

Despite my Cavs in six prediction, early in the series it was clear that Atlanta didn’t stand a real chance against these Cavs, that have now a full 10-men rotation in place, and that have found an exceptionally great mojo from downtown. They played four games in both of their rounds so far, which means not so much playing time and lots of rest, which will surely come in handy in the conference finals.

2. Raptors vs 3. Heat

Could I have been any more wrong about this? I don’t think so. The injuries to Valanciunas and Whiteside proved to be tough to overcome, but the series has given us plenty of highlights: Dwyane shining like its 2010, the initial struggle of Lowry that was able to recover from his slump and make huge plays in games 5, 6 and 7, and Bismack Biyombo running for Toronto’s mayor office. The Raptors reached the conference finals for the first time in their history: they won’t get much farther away than that, but boy was this a great playoff run!

West

1. Warriors vs 5. Trail Blazers

I predicted Portland to be able to win at least a couple in the series, but I clearly though that Curry’s injury would impact the Warriors much more severely. What Steph has done in game 4 is something, yet another thing, that you’ll likely tell your grandchildren. Golden State went through some moments though in which they didn’t look completely in control, and will have to get some things in order (Green techs, for one) before the conference finals, since…

2. Spurs vs 3. Thunder

… the Thunder pulled off the biggest surprise in these Playoffs so far, by convincingly slamming away the Spurs in six games. Westbrook wasn’t probably at his best, Durant looked great, which is something that we haven’t seen in a while, and their phisical presence was phenomenal against a San Antonio team that failed at doing what they do best than everyone else, which is executing on offense. Two names stand above the others: Steven Adams, a true presence in the paint, and Billy Donovan, a rookie coach straight from college that has made the one thing that few, me included, thought possible, which was instilling a winning mentality in his guys.

Conference finals predictions

East

1. Cavs vs 2. Raptors

Toronto won the season series against Cleveland, but it’s clear that these Cavs are something else. They’re playing with confidence, and if the shots are going in like they have, it’ll all be over soon. Still, the Raptors have the men to guard both the perimeter and the paint (also, how about giving James Johnson some minutes now?), and if DeRozan gets a little confidence (that’s a giant “if”), they might be able to sneak a couple of wins. Cavs in 5.

West

1. Warriors vs 3. Thunder

This series is much closer to call than it would seem. OKC have the confidence on their side, they lost the regular season series against Golden State, but they were the ones that looked best against the Warriors. Again, Golden State must regain some composure and some flow, they desperately need to have Green mentally in control, and they need to have Harrison Barnes back in it, since he has been a non-factor so far. Steph gonna Steph, KD gonna KD, Russ gonna Russ, and the Thunder better pound the inside, with Adams and Kanter. All I want for Christmas is this series to last seven games. Warriors in 7.

How to deploy on a production server from your local Git repository

If you’re like me and began to do what you do more than a decade ago, you’ll definitely remember how we all used to push updates to our production servers via FTP. There’s no shame in that: we’ve all been beginners.

Using FTP might even be fine today for teeny-weeny projects, but two things are for sure:

  1. it’s slow,
  2. it will almost always lead to uncertainty regarding the syncronization between your local copy of the project, and the remote one on the server (even if I hear that some people still develop directly on a server, but that’s a rant for another occasion).

Luckily for us, we have version control systems such as Git and our work is never really lost.

So how can we avoid using FTP to upload updates to our production servers?

You set up a new repository that’s hosted on the very same production server you’ll project will end up on and also push updates to that repository.

So let’s assume that you have developed a theme for WordPress and you want to keep it in sync with your local copy.

I wouldn’t want to have the theme folder on the production server to host the repository itself, so I’d opt to set it up in a folder outside public_html and then listen for push events on that repository and perform a checkout of the project to the actual theme folder.

So, since I’m lazy, I’ve created a little script to make my life easier:

#!/bin/sh
rm -rf $1.git
mkdir -p $1.git
cd $1.git
git --bare init
cat <<EOF >hooks/post-receive
#!/bin/sh
mkdir -p $2
export GIT_WORK_TREE=$2
git checkout -f
EOF
chmod +x hooks/post-receive

You can create a file (let’s say create-repo.sh) in the folder that will host your repositories on the server, adjust the file permissions so that it can be executed (chmod +x ./create-repo.sh), and launch it with the following syntax:

./create-repo.sh repository-name path-to-actual-folder

This script does the following things in sequence:

  1. remove any pre-existing repository with the specified name,
  2. set up a new blank repository in a specific folder whose name is indicated by the first parameter (in our case repository-name),
  3. create a hook that is triggered upon receiving a push that will perform the checkout in the actual project folder (second parameter passed to the script, in our case path-to-actual-folder).

So, assuming that you have a standard WordPress installation in the root directory, you could create a repository that points to the themes folder:

./create-repo.sh your-theme-name /home/your-user/public_html/wp-content/themes/your-theme-name

The only remaining thing is to upload stuff to the production server, for which you’ll have to create a new remote pointing to the newly created repository through SSH and then execute a push towards said remote:

ssh://your-username@your-host.dev/~/repos/your-theme-name.git

assuming that you’ve created the repository in a repos folder in your home directory, which I’d recommend.

As you can see, this is nothing too complex, but it’s a pretty nice time saver nonetheless.

It’s only rock ‘n’ roll, but I like it!

The experience of walking through the city center of my town can be bizarre at times: you typically encounter various types of people and some of them are nothing short of cuckoo.

When you apply this scenario to street music, what you get are mostly unpleasant and annoying sounds, that really don’t fit well with being at work, trying to do something productive, while keeping windows open.

Today was an exception. There was a talented electric guitarist that was playing a few medleys not very far from our office, and the incredible acoustics of Genova’s caruggi (you should know what they are by now) brought his notes to my ears.

As soon as I stepped away from the office, I couldn’t stop my self from swinging by and capturing a video of his performance.

His name is Valerio Papa, and he’s got a Facebook page.

Keep it up, Valerio!

Caruggi

In Genova we’ve got a word that defines the typical narrow intricate street that form the historic center of our city, and that word is caruggio. There are hundreds and hundreds of those streets.

So today I found myself wandering around a few of them in search for a place to eat, and given the particularly pleasant weather, I took a couple of shots.

P1020097 P1020100 P1020111

NBA Playoffs 2016 first round recap

The first round of the NBA Playoffs is coming to a close and a few weeks ago I had been dumb enough to make predictions. Not all of the series are done yet and juicy game 7s between Raptors and Pacers, and Heat and Hornets await, but let’s see how it went anyway.

East

1. Cavs vs 8. Pistons

The Cavs convincingly swept the Pistons.I had predicted Detroit winning at least one, and from what we’ve seen they could’ve brought home one or two games, but in the end the difference in roster quality and depth was substantial.

4. Hawks vs 5. Celtics

I got this one completely wrong, but Atlanta has proven to be a great team on both sides of the floor, and they’ll be a match for Cleveland in round two for sure. The Celtics lost Avery Bradley early in the series, and despite the heroics of Thomas, couldn’t finish the job. Still, the future looks extremely bright for them.

2. Raptors vs 7. Pacers

At the moment of me writing this, the series is tied with three games apiece, and despite this, Toronto never looked completely in control. They’ve been outcoached, and Lowry and DeRozan have sort of been annihilated throughout the first six games, but luckily for Raptors fans the rest of the crew stepped up (Joseph!). Paul George has kept reminding me how good of a defender he can be. I still think that Toronto is going to make it, but that’s absolutely not a given.

3. Heat vs 6. Hornets

What a series. The Hornets bouncing back from a 2-0 deficit to grab a 3-2 lead away in game 5 was little short of epic, and so was Dwyane Wade’s final 5 minutes in game 6, to get things back in Florida. I had predicted Hornets in 7, but I feel like the momentum of the series has shifted towards more tropical climates.

West

1. Warriors vs 8. Rockets

Agony: after injuring his right ankle and his knee in the series, Curry is said to be potentially able to play before the Conference Finals start, which is a good news for Golden State, and one that keeps their championship hopes intact. The Rockets were a no match for the Warriors, playing with little character, with their stars fading out from the challenge.

4. Clippers vs 5. Trail Blazers

The Clippers are clearly taking the definition of “being jinxed” to new heights, and not having Paul and Griffin for game 5 and 6 surely made Portland’s life way easier. The Blazers proved to be a team, led by Dame, and supported by an incredible group of young players, including the MIP McCollum. I think they’re capable of creating a few troubles to the Curry-less Warriors.

2. Spurs vs 7. Grizzlies

At least I got one entirely correct, but the fate of the series was set in stone before the series even began. Again, props to Memphis and their coach, because looking legit with such a depleted roster is something that can’t go unnoticed.

3. Thunder vs 6. Mavericks

Oh, so I got two series right, in the end! The Thunder have always been in control, but it’s hard not to consider their efforts just a warm up to their upcoming battle with the Spurs that begins tonight.


Ok, that’s it. It didn’t go all that well, but it hasn’t been a catastrophe either. I might even improve my predicting skills for round two. So…

Round two predictions

East

1. Cavs vs 4. Hawks

Cavs in 6. Atlanta is great and is deeper than I thought, but Kyrie is playing like he never has, and with LeBron always being the basketball android we’ve come to know in the past decade, I can’t see this series going anywhere else than Ohio.

2. Raptors vs 3. Heat

Disclaimer: with two game 7s still to be played, it is only my assumption that the Raptors and the Heat are going to make it. Still, if this were the actual second round series, I would project the Heat winning in 5.

West

1. Warriors vs 5. Trail Blazers

Warriors in 6. Warriors are mentally tough (did you see their reaction to Curry’s knee injury?), and the Blazers are on a wild and partially lucky ride, it’s going to be a fun series.

2. Spurs vs 3. Thunder

I can’t imagine the Thunder winning this, against such a complete and experienced team such as the Spurs, and this is a problem for an organization that has winning the championship as their sole goal. I’d say Spurs for a couple of reasons: 1) I’m not ready yet to see Tim and Manu wave goodbye, 2) I’m not ready for anything else than a Warriors vs. Spurs Western Conference Final. So, Spurs in 5.

A note regarding importing serialized data in WordPress

The WordPress Importer hasn’t received much love lately.

It does work without any particular issue, it’s a tad slow, but in the end it doesn’t give you any particular headache, if not throwing a couple of warnings here and there if you have the WP_DEBUG constant turned on.

Luckily for us, a redux version is in the works, maintained by the fine folks at Human Made, that looks very promising.

The other day I was trying to import a couple of pages that had serialized data in one of their post metas and the Importer kept failing at adding those metas, while still being able to correctly create the pages.

This situation left me baffled for a while, so I started digging.

The reason for the Importer not being able to import serialized data was related to line endings contained in the array I was dealing with: in particular \r\n line endings had to be converted to \n in order for the importer not to fail.

I’ve written a recursive function you might want to pass your data through before actually saving your post meta, in case it might contain values with line endings, such as the ones generated by user input in a textarea:

function replace_endlines_deep( $data ) {
	if ( ! is_array( $data ) ) {
		return $data;
	}

	foreach ( $data as $k => $v ) {
		if ( is_array( $v ) ) {
			$data[$k] = replace_endlines_deep( $v );
		}
		else {
			$data[$k] = str_replace( "\r\n", "\n", $data[$k] );
		}
	}

	return $data;
}

So actually saving the data to the database would become:

// ... make sure to sanitize user input ...

$data = replace_endlines_deep( $data );

update_post_meta( $post_id, 'my_serialized_data', $data );

NBA Playoffs 2016 first round preview

The NBA Playoffs start in a couple of hours and sports-wise this is by far my favorite period of the year.

We can all pretty much agree on the fact that this has been an incredible and memorable regular season, for various reasons:

  • Golden State, of course, winning 73 games and breaking a record that most of us thought couldn’t be broken,
  • Steph joining the 50+40+90 club, hitting more than 400 threes, all while playing less than 35 minutes per game,
  • Kobe retiring in flames,
  • Karl-Anthony Towns having one of the best rookie seasons in recent years.

Back to the Playoffs bracket, I’d like to try and write down a couple of considerations on each pairing.

East

1. Cavs vs 8. Pistons

The Pistons finally being back in the Playoffs after a few years represent a great business card for their boss Stan Van Gundy, who was able to turn the franchise around in just a couple of seasons. Unfortunately for them, they go up against a Cavs team that is rejuvenated in spirit with Lue and LeBron co-coaching, and that should be healthier than last year. Strangely, Detroit is up 3-1 in the regular season series against the Cavs, so it’ll be an interesting series after all, but Playoffs basketball is a radically different kind of game. Cavs in 5.

4. Hawks vs 5. Celtics

The Celtics are tough. They don’t have the best roster out there, but they’re solid and well coached. Atlanta, on the other hand, is a team that will need to restructure itself and make choices comes summer time. Despite the record, I think that the Celtics might have more motivations to go through, they can affirm themselves as a solid basketball team, and they can keep the energy going, but it won’t be easy. Celtics in 6.

2. Raptors vs 7. Pacers

The Raptors have the first serious chance of getting past their first best-of-7 series in their history, and I’m not sure the Pacers, even though they’re a pretty good defensive team, are the team that can stop that. Raptors are deep, even with DeMarre Carroll nowhere near 100% health, and in the Playoffs the difference this makes is much greater. Raptors in 5.

3. Heat vs 6. Hornets

The Charlotte Hornets are one of the surprises of this seasons. They’re unsuspectedly deep, even more after moving Al Jefferson to dominate their second unit. The Heat, on the other hand, won’t have Bosh due to his health issues (get well soon, Chris!), but Johnson is playing great since joining Miami. Of all the first round, this is probably the most balanced series. I’m inclined to say Hornets in 7, but I wouldn’t be shocked if the Heat won it.

West

1. Warriors vs 8. Rockets

As I’m having a hard time finding words to describe the Warriors seasons, so am I trying to find adjectives to qualify the Rockets’. Harden is great and all, but I don’t think that the Rockets stand a chance here. Golden State is the deepest team the game has seen in the past decades, can go small or big at will (they have a fully qualified 4-men rotation in the PF/C positions, not including Green and Iguodala), which is a plus against Houston. Warriors in 4.

4. Clippers vs 5. Trail Blazers

A big big BIG round of applause for the Blazers and their leader Damien Lillard. I don’t think anyone could’ve predicted they would have been here at this point. The Clippers are, well, still the Clippers. They don’t have what it takes to go much past the first round, yet they will, and finish their season with the same sense of incompleteness that always accompanies the franchise. Clippers in 6.

2. Spurs vs 7. Grizzlies

We’re all in awe with the Warriors and what they did, but the Spurs have produced an equally impressive season, with locked down D, the usual long bench, enriched by quality veterans. Duncan is probably at his last dance, and so is Manu, which makes this Playoffs even more worth watching. The Grizzlies, on the other hand, have been clearly jinxed by and old woodoo queen of a remote Caribbean island: nearly everyone has suffered an injury, they’ve used a grand total of 28 players throughout the whole season, and they’ve gotten to these Playoffs decimated, yet showing sparks of the kind of good basketball they’re capable of. Huge props to mr. Joerger for that. Spurs in 4.

3. Thunder vs 6. Mavericks

This won’t be the Thunder’s year. Again. It’s curious that a team that has two of the top 8 players in the game, and that now has a proper coach running the show, won’t be able to accomplish what they’re meant to, that is winning the title. Yet, I can’t wait to see their matchup against the Spurs in the second round. The Mavs will probably be able to win one (Carlisle is a genius after all), but that’s about it. Thunder in 5.

I can’t wait for this to get started and see of many predictions will I miss!