How to Get Twitter Followers

Screen Shot 2016-01-12 at 10.33.05 AM I have a proven, success not guaranteed, method to get lots of Twitter followers.

Step 1 Create Twitter account

Step 2 Start following people you think are interesting

Step 3 Tweet and retweet interesting stuff

Step 4 Follow everyone that interacts with you via replies, retweets and likes (see Bonus tip below)

Step 5 Repeat steps 3 and 4 hundreds, if not thousands of times a month.

The hard part is step three. It’s easy to retweet interesting tweets, but it’s another to craft interesting tweets yourself. It can take a long time for you to develop your voice on Twitter. And it can feel like it takes forever just to break 1,000 followers. But if you stick with it, and you’re mildly interesting, you’ll reach a tipping point around 2,000 followers where your follower count starts to just grow organically without performing step four. Even so, you should keep doing step four indefinitely, but perhaps be more selective in who you follow.

You’ll know that you’re doing it right when your tweets are getting retweeted and liked by others. But even when you get to be rich and famous, don’t stop following back, it’s arrogant.

Bonus tip: Don’t follow people who you don’t want in your Twitter network. For instance, I don’t follow racists, homophobes, bigots or people who are just assholes. Life is too short to have negative energy sucks in your life.

Buy my new book Symfony Getting Started

Buy my new book Symfony Getting Started

CSS Parent Selector

CSS Parent Selector
As of CSS version 3, there is no parent element selector.

You can’t do something like this.

#my_big_butt:parent {
   color:#ff3333;
}

If the parent selector existed, this would return, which element?

<div>
<img src="../../my_big_butt.png" alt="My Big Fat Booty" />
</div>

You would be getting the div element. It seems stupid that the browser’s and the W3C haven’t added a parent selector, but they haven’t yet and probably won’t for many years.

Jeff Williams Named Apple COO

I don’t normally write about internal reorgs, because they’re boring, but look at these two Apple executives. Is there a farm where they’re growing middle aged white guys with neatly trimmed gray hair?

Apple Names Jeff Williams COO

Apple has named Jeff Williams (left) chief operating officer. Chief marketing officer Phil Schiller is now in charge of the App Store.

What does this mean? It means Apple’s moving people around. It happens all of the time and usually means nothing more than Apple thinks Jeff Williams is doing a good job.

(h/t) Apple Insider

Apple’s Secret Lab

Screen Shot 2015-12-15 at 11.17.59 AM
Oh no, Apple has 50 engineers working at a lab in Taiwan to develop organic light emitting diode screen technology. But fear not, Forbes and Bloomberg are hip to Apple’s game.

For the record, just because Apple doesn’t put out a press release every time it hires a few engineers to do research and development doesn’t a secret make.

But having said that, the organic LED sounds pretty cool. Organic LEDs can be folded and rolled – the tech is far superior to current LEDs. Apple hopes to be using it by 2018.

UK Man Arrested in VTech Hack

Custom motorcycle cables
On November 14, VTech children’s toy electronic toy company was hacked. The thief, or thieves, pilfered nearly 5 million adult and nearly 6.5 million children personal information.

The personal data included names, email addresses, passwords, home addresses and download history of adults who purchased VTech products. The first names, genders and birthdays for children in the VTech system have been exposed as well.

Today, UK police arrested a 21-year-old male for the hack.

PHP 7 Dropped

Screen Shot 2015-12-14 at 10.04.32 AM
I missed the news, but on December 3, PHP dropped version 7.

I don’t know what happened to version 6, but version 7 is a major update from PHP 5.6.

PHP 7 comes with a new version of the Zend Engine, numerous improvements and new features such as

  • Improved performance: PHP 7 is up to twice as fast as PHP 5.6
  • Significantly reduced memory usage
  • Abstract Syntax Tree
  • Consistent 64-bit support
  • Improved Exception hierarchy
  • Many fatal errors converted to Exceptions
  • Secure random number generator
  • Removed old and unsupported SAPIs and extensions
  • The null coalescing operator (??)
  • Return and Scalar Type Declarations
  • Anonymous Classes
  • Zero cost asserts

There’s a migration guide for the brave souls who are running to upgrade to this new version. I personally will watch how it all shakes for the next couple of months before delving in.

There’s pretty long list of incompatilities.

Here’s a change that’s going to break a lot of code.

When used in the default by-value mode, foreach will now operate on a
copy of the array being iterated rather than the array itself. This
means that changes to the array made during iteration will not affect
the values that are iterated.

A lot of the backward incompatibility is finally dumping stuff that’s been deprecated for years now.

The result of the new statement can no longer be assigned to a
variable by reference

All of those stupid ASP tags are gone. So you can’t do <%= or <% any more, but you shouldn’t have been doing that anyways.

Previously deprecated in PHP 5.6, static calls made to a non-static
method with an incompatible context will now result in the called
method having an undefined $this variable and a deprecation warning
being issued.

That’s another one that you shouldn’t have been doing. It made no sense before, and now it’s not even possible.

I didn’t even know this was possible, but in PHP 7, you can’t have more than one function parameter with the same name. Why would anyone do that, it’s stupid?

And whoever was doing this next one should be get into therapy quickly, but now you can no longer have more than one default block in a switch statement. Um, why would you want two default blocks? I guess, because you don’t know what default means.

So all you hacks out there that have been “making it work,” you’re going to be having a lot of fun cleaning up all of our shitty code.

Although, it’s unfortunate that the PHP gurus didn’t dump the mysql_* functions. That shit has been deprecated since forever and they need to go. I haven’t used them in well over 10 years, but I just cringe when I see someone posting a question on SO about them. Go away.

Other than that foreach loop working on a copy thing, I don’t see much in the backwards incompatibilities that will trip me up. I’ll wait to see a few minor releases come out before I start thinking about upgrading.

Symfony Exception Display Your Custom Message

Roland Sands Design Custom Indian

Roland Sands Design Custom Indian

Let’s pretend that you don’t want to use the ugly default error pages that come with Symfony. So you create a template to override the default error template and it looks like this.

{% extends 'base.html.twig' %}

{% block body %}
    <h1>Resource not found</h1>
    <p>{{ status_text }}</p>
{% endblock %}

When you’re throwing this exception, you’re providing your own message, but {{ status_text }} is showing the default generic message.

throw new HttpException(404, 'Um, sorry but I have no idea what you are talking about.');

What you see rendered from {{ status_text }} is “Not found” rather than your snarky response.

In the error pages, you have access to the FlattenException object, so you need to fetch the exception’s message rather than status text. Do this instead.

{% extends 'base.html.twig' %}

{% block body %}
    <h1>Resource not found</h1>
    <p>{{ exception.message }}</p>
{% endblock %}

PHP’s Foreach is the Fastest

1977 Yamaha RD400

1977 Yamaha RD400

I have always assumed that using PHP’s foreach loop was the easiest, but not the fastest way to loop through an array. I also assumed that the PHP *array_** functions were the preferred method, as the PHP developers would be able to do some super-efficient magic to make these function super fast.

Apparently, I was wrong.

For me, when looping, I almost exclusively use foreach loops, but only because I think they’re the easiest and more readable loop in PHP. But I often use the *array_** functions thinking there’s a performance improvement for doing so. But now it turns out that the foreach loop is actually the fastest way to process and array.

In a blog post, the writer ran some speed tests on the various looping methods and array_** functions. The *foreach loop performed better than every looping method or array_** function. The *while loop is pretty close in terms of performance, and there are instances when it makes sense. I haven’t felt the need to use a for loop in years, which is the slowest, but that seems obvious.

There’s still obviously a use for the array_* functions, but quick and dirty stuff, the foreach loop is the way to go.

Interesting stuff, it’s always a good idea to test ones assumptions from time-to-time. What was the best way to write PHP in 1997, is very different today.