Get up and running with NGINX

A great primer to get started using NGINX, probably the best web server out there for open source stuff at this time:

If you are a web developer, you’ve probably heard of nginx (pronounced engine-x). Nginx is a fast and extremely powerful http and reverse proxy server that can be used to quickly and easily serve webpages.

Unfortunately, like many sysops tools, there is very little documentation and very few tutorials that explain how it works and how to get up and running. There is a wiki, which is extensive and confusing – showing you all possible options rather than presenting the important ones as you need them. After struggling with it myself for a bit, I finally got down the basics of how to work with nginx, and wanted to share it so that other developers would have an easier time picking it up.

So let’s dive right into it. For this tutorial, you’re going to want a VPS of some sort, preferably fresh so that you can avoid potential conflict with other old setups etc.

You know they’ve got something killer when 1/5 of the top 1000 websites in the world use it, including Facebook, WordPress, and TechCrunch.

Tagged | Leave a comment

Poor Man’s “top” for MySQL

Ted Naleid somehow read my mind today from 4 years ago, and saved my sanity with the following very helpful tidbit, that you can just plug right into your terminal:

watch -n 5 --differences "mysql -u [username] -p[password] -e 'show processlist'"

Basically sets up a way to watch queries come in on your MySQL server. it doesn’t give you enough time to read them, but you should be able to see which of them are taking forever, and then take action accordingly. Happy Querying!

Tagged | Leave a comment

Using Git and Push-to-Deploy on Google’s App Engine

One think I love about Amazon’s Elastic Beanstalk service is their push to deploy ability using git. I’ve recently started doing research into Capistrano, which will probably supersede some of this stuff for me, but still awesome:

App Engine supports the deployment of Python and PHP applications with the Git version control system. Enabling this feature will create a remote Git repository for your application’s source code. Pushing your application’s source code to this repository will simultaneously archive the latest the version of the code and deploy it to the App Engine platform. This speeds up the development process.

The repository is not publicly visible. Only application administrators with developer or owner permissions can access it from a command prompt. When a user disables this feature, the remote repository will no longer be linked to the application and the repo will eventually be deleted. Re-enabling the feature creates a new, empty repository.

Automate all the things!!!

Tagged | Leave a comment

Beyond the default Rails environments

David from 37Signals describes their different environment options for Rails

Rails ships with a default configuration for the three most common environments that all applications need: test, development, and production. That’s a great start, and for smaller apps, probably enough too. But for Basecamp, we have another three

He describes rolling out new features to 10% of their users, utilizing Capistrano to point the users to the “Rollout” environment.

The great thing about doing it like this is that the enable/disable action is very fast. It’s not like the scramble to do a full capistrano rollback. This just ticks the load balancer to send some traffic or not. So the second you catch an issue, you can get the 10% back on regular production, fix the problem, and then try again. Great for your blood pressure levels!

Awesome standards for web development. I with more shops worked this way.

Tagged | Leave a comment

JavaScript Array Remove

For some reason I just came across this: John Resig’s JavaScript Array Remove:

I have another handy method, that I recently developed, that allows you to simply remove an item – or a group of items – from an array. Like with my implementation of JavaScript Method Overloading I wanted something that was concise, elegant, speedy, and highly effective.

Adding another entry to my Javascript toolkit for all projects!

Tagged | Leave a comment

Microsoft is snarky, loses E3. But it doesn’t matter.

TechCrunch rules:

“We have a product for people who aren’t able to get some form of connectivity,” explained Xbox chief Don Mattrick. “It’s called Xbox 360.”

With those snarky words, Microsoft lost E3. That much was clear as soon as Sony’s press conference started. And it’s not because the Xbox One is a bad system. If we ignore Microsoft’s terrible marketing and judge the Xbox One objectively, it’s a fine system – a home entertainment system built for the future that should provide an unparalleled user experience.

Usually I love snark, but I think TechCrunch is right here. Microsoft is shooting themselves in the foot with this one.

However, it doesn’t matter. Microsoft doesn’t care about the people that complain about DRM, or online checking in, or not being able to trade games. They’re going after the people that you hate listening to while playing games online: Kids. Kids don’t care about all that crap, because their parents buy their games for them. They don’t trade them in, either, because they don’t care. They want to be connected all the time, so they can call your mother fat while playing Call of Duty 7.

What’s worse, they’ll be successful with it. By indoctrinating children that all these things are normal, they’ll get that generation used to the fact that Microsoft has a machine in their home, watching them all the time. Once that part of it is complete, it’ll be cake to implement other things that most people would balk at.

An example, you ask?

Lots of progress as been made in parsing images. What if your Xbox One was able to detect a Coke can on your table in front of you, and show you an ad for a Pepsi? Working on your Dell laptop on the couch? Check out this ad for an Acer.

The possibilities are endless, and very lucrative, for a system like that sitting in millions of living rooms.

One final note; something that came to me while writing the last couple paragraphs. What if your new Xbox requires an internet connection all the time, not because they’re concerned about piracy, but because of the above? It wouldn’t be able to call home and find out what to look for in your living room without an always-on internet connection.

All in all, it sort of creeps me out.

Tagged | Leave a comment

PHP Performance Crash Course, Part 1: The Basics

This article should be required reading for anyone looking to set up a scalable website:

We all know performance is important, but performance tuning is too often an afterthought. As a result, taking on a performance tuning project for a slow application can be pretty intimidating – where do you even begin? In this series I’ll tell you about the strategies and technologies that (in my experience) have been the most successful in improving PHP performance. To start off, however, we’ll talk about some of the easy wins in PHP performance tuning. These are the things you can do that’ll get you the most performance bang for your buck, and you should be sure you’ve checked off all of them before you take on any of the more complex stuff.

Afterthought doesn’t begin to describe it. Whether you use WordPress at the outset or a lightning fast MVC framework like CodeIgniter, it seems like there’s always items that get overlooked for the sake of getting it out the door.

Look to your caching. Look to your SQL queries and the indexes they work on. Learn about Memcache. Varnish. It will save your sanity, in the long run.

Tagged | Leave a comment

Faster JavaScript Trim

Stumbled across Steven Levithan’s excellent breakdown of Javascript TRIM functions while looking for, well, a decently implemented TRIM function.

Since JavaScript doesn’t include a trim method natively, it’s included by countless JavaScript libraries – usually as a global function or appended to String.prototype. However, I’ve never seen an implementation which performs as well as it could, probably because most programmers don’t deeply understand or care about regex efficiency issues.

After seeing a particularly bad trim implementation, I decided to do a little research towards finding the most efficient approach. Before getting into the analysis, here are the results…

Definitely bookmarking this.

Tagged | Leave a comment

Google acquired Waze, the social mapping app

A post from the Google Maps team, talking about acquiring Waze, the social mapping app:

We’ve all been there: stuck in traffic, frustrated that you chose the wrong route on the drive to work. But imagine if you could see real-time traffic updates from friends and fellow travelers ahead of you, calling out “fender bender…totally stuck in left lane!” and showing faster routes that others are taking.

To help you outsmart traffic, today we’re excited to announce we’ve closed the acquisition of Waze. This fast-growing community of traffic-obsessed drivers is working together to find the best routes from home to work, every day.

Most times, a starting being acquired by a larger corporation (even Google) can spell the death knell for the application. However, I think this will be the exact opposite. I see Google totally integrating the way Waze works into their Maps application and services, so that their traffic prediction is even more accurate. For sure, Waze won’t exist in the same way, but Google is buying them for the way they collect data, and hopefully getting the network of people that are basically “curating traffic” in real time.

Congrats to the Waze team, and smart acquisition by Google.

Tagged | Leave a comment

Don’t let anyone see your git repository configuration!

This one is totally true, and will be a concern for a lot of people in this age of having your website version controlled. I checked out my employer’s website and we’re guilty too!

Please take one moment to fetch your-domain.com/.git/config. If it returns text, fix it up today!

You can fix it by adding this to your .htaccess:
RewriteEngine on
RewriteRule .*\.git/.* - [F]

Be safe with your code out there; hide your git repository information from the outside world!

Tagged | Leave a comment