Joddit Global CSS Fixed for WordPress 4

I really like the simple CSS plugin — Joddit Global CSS. It works great. Well, it worked great until I upgraded to WordPress 4. Then it broke.

After upgrading, I couldn’t see any of my stylesheets via the admin interface, but they were still loading.

So I posted a message to the author of the plugin to let them know there’s a bug and that I’d be happy to help out with fixing it.

I didn’t hear back from the author, but it seemed like an easy enough thing to fix, which it was.

The problem with the Joddit Global CSS plugin is that it uses the WP_List_Table class that comes with WordPress. You aren’t supposed to do that.

According to the WordPress documentation, plugin and theme developers are supposed to make a copy of the version of WP_List_Table and include it with the plugin or theme that needs it. The one included with WordPress is subject to change and will break code that relies on it directly, even sub-classing it is wrong. That’s what happened with Joddit Global CSS.

So I made a copy of the version of WP_List_Table (class-wp-list-table.php) from WordPress 3.9.2 and put it in the plugin lib director. I changed the name of the class from WP_List_Table to My_List_Table to avoid collisions with WordPress core and other plugins or themes that could load WP_List_Table.

So if you’re running WordPress 4 and you can’t see your Joddit Global CSS stylesheets in the admin, just run my tweaked fork.

In your plugins directory, after you delete or remove the version of Joddit Global CSS is in there, clone my Git fork of the plugin.

git clone https://github.com/hack3r3d/joddit-global-css.git

How to Add a Linux User for Mail but Not Login

I’ve had to, from time-to-time, create users on Linux boxes that need to connect via IMAP to get email, but they can’t SSH or login to the server.

There are certainly more elaborate ways to solve this problem, but here’s my ghetto solution.

When creating the user set their shell to /bin/false.

useradd --shell /bin/false gack

Now when gack tries to SSH into the server, he can’t get in. But gack can get email via IMAP using SSL to encrypt gack’s password. The SSL part isn’t technically necessary, but only a fool would be sending plain text passwords around like that.

I remember researching this and I initially I thought the –disabled-login on useradd would do the trick, but no. It’s strange, on my Debian server, the man page for useradd doesn’t even mention –disabled-login, but it’s totally an option.

The problem is that while –disabled-login does in fact disable the login, it does so by putting an ! in the /etc/shadow file for the user’s password. If the user’s password in the /etc/shadow file is an exclamation point, they can’t login, but they also can’t get email either, since they’re account is disabled. It makes sense.

If however, you set the user’s shell to /bin/false, she can get email but can’t login via SSH.

And if you forget the –shell parameter when calling useradd, you can just edit the /etc/passwd file and set it there.

Tip Jar

If you think what I’m publishing here is worth more than nothing and you want to see me keep publishing, leave a tip.

When I bartend, I get a buck for pouring someone a beer, the shit I’m doing here is worth at least a dollar.

And no, I don’t want to sell ads.

Configure Netbeans to Auto-upload Files using SFTP

Here’s how to configure Netbeans to automagically upload files to a server using SFTP.

Before you can begin, you have to have a Netbeans project. No, wait, you actually need to have Netbeans installed. So if you don’t have Netbeans installed, or you don’t know what Netbeans is, you should go get it. If you’re an emacs user, this tutorial will be totally meaningless.

Open Netbeans.

Select a project properties and select “Run Configuration” under Categories.

In the “Run As,” select “Remote Web Site (FTP, SFTP).”

Screen shot 2014-10-17 at 10.23.09 AM

Now setup a “Remote Connection.” To do that click the Manage button.
Screen shot 2014-10-17 at 10.23.57 AM
Add and configure your server connection and select whether it’s FTP or SFTP. Do people still use FTP?

Once you’ve got the connection configured, you can set the “Upload Directory.” That’s the directory on the server where your files will land.

You can choose to upload your files manually, on save or on run. I’m usually doing this sort of thing because I can’t execute the code on my local machine, so I upload on save.

Netbeans IDE

Netbeans

Netbeans

My preferred editor for at least 10 years was emacs. I still love emacs and use it often, but Netbeans has definitely won me over.

Is Netbeans perfect? Not by a long shot. I find the keyboard controls to be clunky and difficult to make work for how I prefer to code, but I’ve figured it out.

What I really like, is the ability to integrate Netbeans into various development environments.

Sometimes I find myself working with version controlled source code. That’s awesome. But sometimes I get stuck dealing with an organization that, for some insane reason, doesn’t use version control. So the auto-upload SFTP on save feature is really nice.

I also like the color coding, syntax highlighting and quick formatting controls in Netbeans.

What I hate about Netbeans is that it’s a resource pig. And if I leave it open long enough, it eventually makes my workstation unusable and I have to restart Netbeans.

But for me, Netbeans is a better editor than emacs. It’s just easier. I guess I’m getting old and lazy.

Common Alerting Protocol Version 1.1

For my job building web services for the government, I’m currently tasked with adding an alert feature to the state’s amber alert system.

To do that I’m going to build a Common Alerting Protocol version 1.1 feed.

The sample Common Alerting Protocol version 1.1 looks like this.

<?xml version="1.0" encoding="utf-8"?>
 <alert xmlns"urn:oasis:names:tc:emergency:cap:1:1">
 <identifier>KAR0-0306112239-SW</identifier>
 <sender>KARO@CLETS.DOJ.CA.GOV</sender>
 <sent>2003-06-11T22:39:00-07:00</sent>
 <status>Actual</status>
 <msgType>Alert</msgType>
 <source>SW</source>
 <scope>Public</scope>
 <info>
 <category>Rescue</category>
 <event>Child Abduction</event>
 <urgency>Immediate</urgency>
 <severity>Severe</severity>
 <certainty>Likely</certainty>
 <eventCode>
 <valueName>SAME</valueName>
 <value>CAE</value>
 </eventCode>
 <senderName>LOS ANGELES POLICE DEPT - LAPD</senderName>
 <headline>AMBER ALERT</headline>
 <description>DATE/TIME: 06/11/03, 1915 HRS. VICTIM(S): KHAYRI DOE JR. M/B BLK/BRO 3'0", 40
 LBS. LIGHT COMPLEXION. DOB 06/24/01. WEARING RED SHORTS, WHITE T-SHIRT, W/BLUE COLLAR.
 LOCATION: 5721 DOE ST., LOS ANGELES, CA. SUSPECT(S): KHAYRI DOE SR. DOB 04/18/71 M/B, BLK HAIR,
 BRO EYE. VEHICLE: 81' BUICK 2-DR, BLUE (4XXX000).</description>
 <contact>DET. SMITH, 77TH DIV, LOS ANGELES POLICE DEPT-LAPD AT 213 485-2389</contact>
 <area>
 <areaDesc>Los Angeles County</areaDesc>
 <geocode>
 <valueName>SAME</valueName>
 <value>006037</value>
 </geocode>
 </area>
 </info>
 </alert>

I found this CAP file format validator to be useful.

Improve Google Adwords Performance with Placements

Screen Shot 2014-10-15 at 9.56.20 AM
A low Google Adwords click-thru rate could be because of the sites your ads are running. Adjusting your ad campaign placements can greatly improve your click-thru rate and your ad performance.

If you haven’t tweaked your Google Adwords placements, there’s a good chance your ads are getting tons of impressions on sites that will likely not lead to a click, for instance, GMail.

To fix this, login in to your Adwords account.

Click on a campaign.

Click on Display Network tab.

Click on Placements tabs.

It should look something like this.

Google Adwords Screenshot Google Adwords Placement Edit Menu

Look through the list of sites your ads are running on. Look for the ones that are generating a ton of impressions, but very few clicks. Look for sites that are irrelevant to your ad campaign. Click the checkbox for sites you want to exclude.

Rather than excluding from the Ad Group, I recommend scrolling to the top of the list, click the Edit button and select exclude the selected sites from the entire campaign.

How To Insert Custom WordPress Plugin and Widget into any WordPress Post or Page

Screen Shot 2014-10-14 at 4.02.55 PMHave you ever wondered how to create a custom WordPress plugin and a custom WordPress widget, and you want to be able to embed your new custom WordPress widget in any page or post? If so, you my friend have come to the right place.

Keep reading and you will learn how to install a custom WordPress plugin and a custom WordPress widget. You will also learn how to insert aforementioned custom WordPress widget into any WordPress post or page.

To show you how to do all of this, install a this WordPress plugin called percentager. Just download it, clone it, fork it, or whatever from Github.

If you’re cloning, in your wp-content/plugins directory run this:

git clone https://github.com/hack3r3d/percentager.git

Obviously if you forked it, you need to change the URL.

Let’s digress for one second. Why are we installing a WordPress plugin called “percentager”?

Figuring out the percent different between two numbers is something I have to do often. Embarrassingly, I have to think about how to do it for a minute. I can always come up with the correct answer, but it takes me longer than I think it should.

So instead of waiting to get smarter, I just created this little WordPress plugin and a custom WordPress widget, shown here.

Percent Change Calculator

The difference between X and Y is a Z

This WordPress custom plugin consists of the following files.

Your percentager.php file should look like this.

With the percentager custom WordPress plugin installed and activated, let’s add it to a post. You activated it right? If not, do that before continuing.

To add the percentager custom WordPress widget to a post or page, you have to install AMR Shortcode Any Widget. Do that.

Once you have the AMR Shortcode Any Widget installed and activated, go to Appearance -> Widgets. There you will now see “Widgets for Shortcodes.” You should also see the Percentager widget. Drag Percentager onto the “Widgets for Shortcodes” box.

Now Percentager is available to be included in a posts and pages.

Create a post and add this to the body in Text mode.

[do_widget Percentager]

If you did everything correctly, and I didn’t mess up my instructions, you should see the Percentager widget in your new blog post. It’s a great way to customize pages and posts with custom WordPress plugins and widgets.

I hope you enjoyed this post. If you need help customizing your WordPress site, I’m available for hire, send me a message.

Writers Demand a Living Wage

Writers need to stop working for chump change.

If you’re a writer and you work for less than $200 a day, you are a chump. Just think about it, if you work 8 hours a day at $200 a day, that comes out to only $25 an hour. And for self-employed people that’s before you pay both sides of the payroll tax.

Just the other day I was working with an editor for Smashing Magazine on a story pitch. Everything was great until we started discussing money.

The story was to be about Symfony. It was to show designers and developers how to spin up a Symfony framework, and to demonstrate how quickly one can utilize Symfony to get to the creative stage quickly.

To write a story like that with a working Symfony sample application would take several days. I would have included at least one interview.

The editor wanted to pay me $250. I wanted $800. The editor wasn’t able, or willing, to pay me what I wanted. He did assure me that my story would reach a large audience. While Smashing Magazine has a large audience, that apparently doesn’t equate to paying writers what they’re worth. I’ve been published hundreds and hundreds of times and don’t get excited about getting a byline. Therefore, I won’t be writing for Smashing Magazine.

More writers need to be willing to walk away from a bad deal. Accepting low rates for your writing is ruining it for everyone.

I understand that noobs need to do what they need to do get published, but once you’ve established yourself as a professional writer and you can write with a voice, expect to be paid, and if you aren’t, walk away.

Math Tidbit: Percent Change Formula

Problem: You have two numbers – X and Y – and you want to figure out what percentage of increase or decrease there is from X to Y.

Solution: I’ve had to do this a bunch of times in my life and while I always come up with the correct answer, it always takes me longer than I think it should.

If X = 2.3125 and Y = 2.3750, you could do this:

(Y – X) / X * 100 = Z

(2.3750 – 2.3125) / 2.3125 * 100 = 2.70270270

That means that if I change the gear ratio on my motorcycle from 2.3125 to 2.3750, that would be a 2.7 percent increase.

Percent Change Calculator

The difference between X and Y is a Z

Lubuntu on Asus EEE PC 900

I have an Asus EEE PC900, but the bastardized version of Debian that came with the computer was wildly out-of-date. No sane person should put an un-patched computer on the Internet without patching it. Unfortunately there isn’t apparently any way to update the hacked Debian install that came with the computer.

Fortunately, I was able to simply install the latest version of Lubuntu. Now rather than that lame window manager that came with the computer, I can run whatever I want.

Here’s how I did it.

  1. First I downloaded Lubuntu and put it on USB stick. I downloaded the 32-bit version.
  2. Plug the USB stick in and figure out where it’s mounted.
    sudo fdisk -l
  3. Mine was located at /dev/sdb1, adjust for your setup and unmount your stick.
    umount /dev/sdb1
  4. According to my research, FAT32 is the more reliable format, so I formatted with this command.
    sudo mkdosfs -n 'MYSTICK' -I /dev/sdb -F 32
  5. Copied the .iso to the USB stick partition copying to the partition, sdb1, not the device, sdb.
    sudo dd if=lubuntu.iso of=/dev/sdb1 bs=4k
  6. Force the completion of any disk writes and eject the stick
    sync
    sudo eject /dev/sdb
  7. Now my Asus EEE PC was booting, I pressed ESC and selected the USB stick as the boot device. Don’t try and set the boot order in the BIOS, it’s ignored, you have to hit ESC and select the boot device.
  8. Once I booted Lubuntu from the USB stick and it seemed to work, I installed Lubuntu. While installing, I also repartitioned the drive to include 256MB swap space.