How-To: Show All Network Connections On Your DD-WRT Router

Find the bandwidth hog by viewing all network connections passing through your DD-WRT router

Something was using all of my upstream bandwidth, wasn’t sure what device or who it was (had friends over). To get to the bottom of it quickly, a simple command can be run from the DD-WRT web-based gui that will show all network connections on your DD-WRT router.

Just follow these 5 easy steps below:

1. Login to your router’s web interface.

2. Click the “Administration” tab, and then click the “Commands” tab.

3. In the text area to enter commands, enter this:

cat /proc/net/ip_conntrack

4. Click the “Run Commands” button below where you entered the command above.

Once you’ve clicked the “Run Commands” button, wait a few seconds, and you’ll eventually see some output similar to what you see in the image above, below is the raw text from the image:

Now the key to tracking down the offending user/device is to look for a source IP (almost always a non-routable IP, like 192.168.1.x, 10.10.10.x or whatever) that shows up a LOT more often than other non-routable IP’s.

Once you’ve found that IP, go to the “Status” tab in the DD-WRT web interface, click “LAN”, find the IP that you suspected was the culprit from above and make a note of the MAC address associated with that IP.

9+

Use Docker for Fast WordPress Development Environments

A Dockerfile That Provides Quick WordPress Development Environments

Back in May of this year I started playing around with Docker quite a bit. Took me a bit to wrap my brain around everything Docker can do, wish I had read this article from Adam Ierymenko before starting.

Anyway, Docker describes itself as such:

Docker is an open platform for building, shipping and running distributed applications. It gives programmers, development teams and operations engineers the common toolbox they need to take advantage of the distributed and networked nature of modern applications.

I’m not using Docker to it’s fullest extent, not even close. I mostly use it for setting up quick WordPress development environments for building client sites or just to do some testing.

I came across an outdated Dockerfile that had exactly what I needed but lacked the ability to SSH to the Docker container. I forked it on GitHub and added some modifications (like SSH).

It’s on the Docker Hub Registry, making it super easy to use. There’s a few items on the to-do list, but the one I want to take care of first is adding support for Docker Compose, which will make installation even easier.

To get started with this Docker image, you just need to have Docker installed and then run the following command:

sudo docker pull tlongren/docker-wordpress-nginx-ssh:latest

Once you’ve got the Docker image pulled, fire up a new container like with the command below. It will create a new Docker container named project-name.

sudo docker run -p 80:80 -p 2222:22 --name project-name -d tlongren/docker-wordpress-nginx-ssh:latest

Give it a bit to get everything setup then navigate to http://127.0.0.1:80 in your browser to access your new WordPress install.

For more information I suggest checking out the readme. Every time that I push commits to GitHub, a new build of the Docker image will automatically be built as I’ve got it setup as an automated build repository at the Docker Hub Registry. Pretty nifty.

So, I’m relatively new to Docker, if you’re a pro and see something I should be doing differently, please let me know. Any advice on setting up Docker Compose for this project would be great, too (if I’m not mistaken, it just involved linking multiple containers together).

Do you use Docker?

View Results

Loading ... Loading ...
8+

Use Composer in Your WordPress Plugin or Theme

Simple Tutorial Showing How To Use Composer in Your WordPress Plugin or Theme

I love Composer. It just makes including libraries or scripts in your app incredibly easy. So easy that it’s stupid not to use it (in many, if not most cases).

The number of libraries/scripts available on Packagist is astounding, all of which can be included in your plugin with Composer. Packagist is the main Composer repository. It basically aggregates all types of PHP packages that can be installed via Composer.

I’d never used Composer with a proprietary WordPress plugin before. The plugin is for a client so it’ll never be available to the public.

Here’s the steps I took to make this WordPress plugin compatible with Composer so that I can easily bring in third-party libraries.

We’ll be using mailgun-php throughout this example, as the plugin that inspired this post uses Mailgun to send all sorts of emails.

1. First, install composer on your server.

I install Composer globally, like so:

curl -sS https://getcomposer.org/installer | php<br>sudo mv composer.phar /usr/local/bin/composer

2. Add Mailgun as a dependency.

cd /path/to/plugin/
composer require mailgun/mailgun-php:~1.7.2

3. Check your composer.json file.

We’re including Mailgun and guzzle from Packagist. Your composer.json file should look similar to the example below.

4. Tell composer to install Mailgun.

tyler@yourmachine:~/path/to/plugin$ composer install

5. Autoload Our Mailgun Classes in Our Plugin.

The following should go in your plugin-name.php file, before any other PHP code.

<?php
require 'vendor/autoload.php';
use MailgunMailgun;

You can now use Mailgun in your WordPress plugin or theme, some basic examples of using Mailgun can be found on GitHub and in their official documentation.

2+

Fix StanleyWP WordPress Theme Portfolio Grid

Fix display of portfolio grid rows

Back in September of 2014 I wrote about using the StanleyWP WordPress theme for a portfolio site. After I added some projects, I noticed the grid on the Portfolio page template wasn’t displaying rows correctly. I even noted it in my original post, towards the end.

I’ve had a few people contact me about how to fix the StanleyWP portfolio grid issue, and earlier today Arun left a comment asking how to fix the grid issue.

You need to be using a child theme for this, it’s just good practice. If you don’t know how to create a child theme, read my post on creating a child theme. It’s really easy to do, but may require you to reset your menu or some widgets after changing to the child theme.

Anyway, Arun confirmed that this gist fixed the problem for him.

Just save that code as template-portfolio.php and put it in your child theme directory. Your portfolio should now show three projects per row. No CSS or anything else needs to be modified, just that one page template.

Let me know if you have any issues or questions.

2+

Passwds.io Source Available on GitHub

Now on GitHub

Took a bit longer than I wanted, but the source for passwds.io is up on GitHub now.

It’s extremely simple, using Twitter Bootstrap, straight PHP, jQuery, and the jQuery prettySocial plugin for the social buttons at the bottom of the site.

Passwords are generated using pwgen-php from Superwayne. pwgen-php was forked a couple years ago by Roderik van der Veer, which I was unaware of.

I’ll be updating to the somewhat newer pwgen-php library from Roderik at some point.

Basically, an AJAX request is sent to a PHP file, grabbing the requested passwords, and then the results are displayed.

Pretty simple. Let me know if you have suggestions or questions. Please be kind, I threw this together in about an hour one evening.

0