Steve Grunwell

Open-source contributor, speaker, and electronics tinkerer

Category: Code

Quick-tip: git add –patch

If you’ve ever found yourself in a situation where you’re working on multiple code changes at once and want to split them across multiple Git commits (or simply not commit parts of it), git add -p will let you interactively specify separate parts of the file to be committed.

Continue reading→

SQL-generated Hyperlinks in your Spreadsheets

I was building a QA spreadsheet the other day, where I needed to generate a number of randomly-generated WordPress posts with the posts’ titles, URLs, admin URLs, and publication date to be shared with the client via Google Drive, and needed my SQL query to generate links that could readily be pasted into the spreadsheet.

Continue reading→

Resolving PHPUnit issues on VIP Quickstart

I ran into this issue on my VIP Quickstart Vagrant box today while attempting to run PHPUnit:

Warning: require_once(PHP/CodeCoverage/Filter.php): failed to open stream: No such file or directory in /usr/bin/phpunit on line 38

Continue reading→

Bypassing JavaScript Anti-Clipboard Measures

As I write this, my new Epiphone Casino is sitting in my lap and I’m looking up George Harrison guitar tabs. Unfortunately, when you’re best known as one of the Fab Four, lawyers love to block access to your work that doesn’t bring in royalty checks for your estate. When looking for one song in particular, What is Life, my go-to tab site, Ultimate-Guitar.com, came up short.

Continue reading→

Making Apps Personal with Gravatar

If you haven’t already implemented it in one of your own apps, you’ve almost certainly used a site that uses Gravatar, an Automattic-maintained project that provides the web with Globally-recognized avatars. WordPress sites naturally use them for author and commenter avatars, but Gravatars are also used by major sites like Stack Overflow, GitHub, and more.

For maximum portability, Gravatars are always square and can be automatically resized to fit most applications. Defaults can be specified, including several types of uniquely-generated avatars including identicons, wavatars, and the 8-bit inspired “retro” avatars. Let’s take a look at how easy it can be to implement Gravatar in your next project, shall we?

Continue reading→

Quick Tip: JavaScript Resize Timer

I wanted to share a little trick that I use a lot when building responsive sites that can be a huge help for your front-end performance, which I call the “resize timer”:

Imagine the following scenario: you have a series of horizontally-aligned boxes on your page, which should be equal height. Of course, this is easy to pull off with Flexbox, but browser support isn’t exactly where we want it just yet. Use it where you can, of course, but you might still need a JavaScript-based fallback for older browsers.

Continue reading→

HubSpot Signals and Your Privacy

This week a few people in the office got really excited about the Signals app from HubSpot, which lets you see when your emails have been opened and whether or not links have been clicked in your emails. While it’s extremely useful for marketers, project managers, and others who have a vested interest in knowing you’ve read their emails, I’d prefer to be able to read the email at my leisure without having the sender essentially standing over my shoulder to see if I’ve read it. For most people it’s not a big concern, but it is incredibly simple to thwart if you’d like a little more privacy in your inbox.

Continue reading→

Quick Tip: Prevent OneAll from Creating New Users

I’m working on a site right now that uses the Social Login plugin by OneAll, which is the first time I’ve dealt with users logging into a WordPress account via social networks. The plugin works really well, but I ran into one major issue: new user accounts were being created when matches weren’t found.

This particular project is a BuddyPress site for a fraternity; brothers can log in to see private events, content, and the full roster but the general public can only see the public pages. There’s also a public roster page with basic information about each member (name, graduation year, major, etc.), but those are dynamically generated by listing all BuddyPress members (excluding my team’s accounts, of course). Out of the box, OneAll would create a new user account for anyone who tried to log in, resulting in my mug appearing in the roster right along all the registered fraternity members…yikes!

Continue reading→

Automatically Restart PHP-FPM During Deployments

At work we’ve been rolling out PHP-FPM to more and more of our clients’ servers, which has been great for performance and keeping server loads down. The only issue we’ve had (beyond some initial configuration) was related to our deployments: many of our projects, especially our web applications, are deployed through Capistrano, a Ruby-based task runner that’s extremely popular among the Ruby on Rails crowd. While Capistrano let’s us reduce deployments to running cap production deploy, PHP-FPM typically needs to be restarted before it will start using the new code.

Having to manually SSH into a server to restart PHP-FPM after a deployment takes some of the sexy out of one-line deployments, so we sought to find a better way. The goal: be able to restart PHP-FPM (sudo service php5-fpm restart) from within a Capistrano task without being prompted for passwords (we use Public-Key authentication) or having to manually SSH in to restart the server.

Continue reading→

Laravel Application Environments without Hostnames

Forgive me if this is old news, but hostname-based environment switching isn’t as nice as it could be; I like using *.dev for my development environments, but other people I know like  *.development, *.local, etc. The truth of it is the more developers you have working on a project the higher chance you run of the application being run at a variety of hostnames, mucking up your bootstrap/start.php file.

Fortunately, Laravel doesn’t force us into using hostname-based environment switching. At work we’ve developed this little workflow, and it seems to be working really well.

Continue reading→

Page 5 of 7

Be excellent to each other.