Posts Categorized: Programming

Stop building shitty PHP web applications

I’m sort of active on Stackoverflow.com and I see so many stupid questions from people who know nothing about PHP trying to cobble together a pile of shit web application. I admit that nearly 20 years ago when I started working with PHP, I wrote some awful code, just wretched shit. But back then, everyone… Read more »

Google Fonts Generates Invalid HTML

So if you go to Google Fonts and pick a couple of funky fonts for your next super funky web app, you might get something that looks like this from Google. <link href=’http://fonts.googleapis.com/css?family=PT+Sans|Anton’ rel=’stylesheet’ type=’text/css’ /> That’s what Google tells you to use in your markup to access those fonts. It technically works, but if… Read more »

Online Police Scanner

In my spare time, I’m a geek about information and government transparency. I foolishly believe that technology can and will make government agencies more transparent, subject agencies to criticism and make government better. To further that agenda, I created this online police scanner for my hometown of Montpelier, Vermont. The technology to make this work… Read more »

Symfony 2: Enable Twig Extensions

The other day I was dicking around with some code and I felt like I needed to truncate a string. Fortunately I was working with Symfony, which uses Twig templates, which is definitely my preferred templating system in 2014. But by default Symfony’s Twig extensions, which give you stuff like a truncate filter, is not… Read more »

Responsive Design: Unfloat An HTML Element

Have you ever sat down and said, “I’m going to float that fucking logo to the right.” Whether it makes any sense to float that motherfucker to the right is irrelevant, you do it. But doing so has caused your design to get all tore up for users at less than 800 pixels. That fucking… Read more »

How to Fire Up jQuery

When I want to fire up jQuery, I do it like this. $(document).ready(function() { setInterval(function() { console.log(‘Poop’); }, 30000); });

How to Insert Data with PHP PDO

Here’s one way to insert a record using PHP PDO into a MySQL database. $dbh = new PDO(‘mysql:host=localhost;dbname=myfunkydata’, ‘dbusername’, ‘dbpassword’); $dbh->beginTransaction(); $sth = $dbh->prepare(“INSERT INTO recording(name, date) VALUES(?, ?)”); $file = time(); $sth->execute(array($file, date(‘Y-m-d H:i:s’, $file))); $dbh->commit();

How to Create PHP PDO MySQL Connection

Here’s how I create a PDO connection to a MySQL database. $dbh = new PDO(‘mysql:host=localhost;dbname=myfunkydata’, ‘dbusername’, ‘dbpassword’); $dbh->beginTransaction(); $sth = $dbh->prepare(“INSERT INTO recording(name, date) VALUES(?, ?)”); $file = time(); $sth->execute(array($file, date(‘Y-m-d H:i:s’, $file))); $dbh->commit();

Tutorial: HTML5 Local Storage

Until HTML5 came along, storing data on the client side was always a total hack. Now it is remarkably easy and it works consistently across all modern browsers. I’ll demonstrate how to do it by creating a dummy application for saving user preferences. I wrote this demo app as a Symfony bundle. You can download… Read more »

Why I hate Modernizr

Modernizr is great, but I hate it. I hate, hate, hate it that the name is simply a misspelled word. Every time I add Modernizr to a new project, it always takes like three tries to spell modernizer, er, modernzr, derp, modernizr correctly.