Posts Tagged ‘nerdery’

How to never again see WordPress’ update nag – no plugin necessary

Wednesday, February 8th, 2012

One reason I like WordPress is because they come out with frequent updates. When you run a WordPress site, it checks periodically for new versions. It reminds you with a helpful little yellow bar at the top. It feels great to install a new version, be up to date, and get rid of the nag. However, because of their awesome frequent updates, it also means you’re only ever free of that annoying reminder for a couple days.

A screenshot of the annyoing yellow bar

While it’s important to keep software up to date, I do have a life beyond updating WordPress. I wanted to get rid of that yellow nag once and for all. There are a couple plugins to disable it, but I don’t see any sense in adding more code (and more plugins to update) when I can just add one line to a stylesheet. So, here is how to rid of it at the cost of 13 characters per page load*:

Open wp-admin/css/colors-fresh.css. All newlines and extraneous spaces have been stripped from the file in the interest of speedier loading (this file loads anew every time you load a page in your Dashboard). Search for: #update-nag

In my version of WordPress, it starts on line 11593 of 34572. Expanded, it looks like the following:
#update-nag, .update-nag {
    background-color: #FFFBCC;
    border-color: #E6DB55;
    color: #555555;
}

Add the following after the opening curly bracket:
    display: none;

When you refresh the admin page, the update nag will be gone forever.

However! With great power moustache CSS comes great responsibility. The WordPress developers made such a prominent prompt because keeping software up to date is important. There are often important security improvements between versions. If you turn off the nag, you still have a responsibility to yourself, your users and The Internet at large to keep WordPress reasonably up to date. Put a recurring item in your calendar to update about once a month.

*You could also eliminate all the other styling applied to the now-invisible element and end up with fewer characters than you started.

Links for this week

Sunday, January 22nd, 2012

Any given day I pick out several stories in my RSS feed reader to follow up on, and so far they’ve just been building up. In an effort to un-flag some of them, I’ll be linking to stories that caught my interest this week:

Upgrading to WordPress 3.3 – the missing “Format” box

Friday, December 16th, 2011

I recently installed WordPress 3.3 for a client, and I was very impressed. Specifically I was excited about tinkering around with the “Format” box, which allows you to post in a variety of formats, including, “Status”, “Gallery” and the regular post format “Standard”.

I wasted no time upgrading this site to WordPress 3.3, but no fun format box. I poked around at options and Googled, to no avail. Most suggestions seemed to revolve around some browser problem, but I could see it on the other site, plain as day, so my browser was obviously capable of displaying it.

For lack of a better idea, I started grepping. I used Firebug to get the id attribute (“formatdiv”), figuring there would be a finite number of instances in the code. Indeed, there was exactly one. It was in wp-admin/edit-form-advanced.php. There were two relevant lines:
if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post_type, 'post-formats' ) )
    add_meta_box( 'formatdiv', _x( 'Format', 'post format' ), 'post_format_meta_box', null, 'side', 'core' );

This alerted me that it was a problem with the theme, which unsurprising considering that I’m still using a customized version of the 2009 default theme. I knew it worked in the latest theme, twentyeleven, so I went to that directory and grepped for ‘format’ and braced myself for the worst. Once I eliminated the CSS files, it was easy to hone in on line 104 of functions.php
add_theme_support( 'post-formats', array( 'aside', 'link', 'gallery', 'status', 'quote', 'image' ) );

This takes place in a function called setup. I went over to my theme and looked for a similar function in the functions.php file. It did not have one. I pasted it in toward the middle of the file and hoped for the best. The format box appeared like magic. I haven’t actually tinkered with it yet, but I wanted to write up my experiences – before I forget them – so that someone else with an old theme can bring some new magic into their WordPress experience.

Privacy is controlling your own data

Sunday, November 27th, 2011

One topic I find myself ruminating on is the ability to own your own data. For example, many of us use Facebook or Google Calendar, and all the information we’ve painstakingly entered there is available for our use, but if we want to move to a different service, we can’t just pick up our data and go, we have to re-enter a lot of information, but some of the information we just lose.

Google and Facebook and Twitter have various APIs to allow some amount of access to our (and other peoples’ data), but it’s still only as much as the provider cares to share. The data is still subject to the providers’ deletion. Also, an API is fantastic if you’re a programmer with spare time, but an end user doesn’t have a lot of options.

There are some tools that aid to this end, but not nearly as many as I’d like. I haven’t investigated any of the following as thoroughly as I’d like, but for any interested party:

Although not a specific tool, there are distributed social networks. These are pieces of software with functionality similar to Facebook or MySpace or Friendster that you can install on your own machine. I believe some support being install across multiple machines, so I could have a copy on my server, my friend who’s a privacy nut could have a copy on their server, but we could interact with eachother like we’re both on the same site. To me, this type of social network has the most advantage, because it allows anyone who wants absolute ownership of their data to have it, while those who don’t care can just sign up and be an end user.

The downfall with a social network that isn’t already established is that since we use it to socialize, it’s not very useful until it reaches a certain critical mass. Most of our friends don’t want to leave their existing social network because it has all their data and all their friends. However, now is a great time to try to break that barrier. The buzz (no pun intended) around Google+ is putting doubt into people’s minds that Facebook is The Only Way. A lot of my friends are signing up without any investment, mostly to just see what it’s about. Now would be a great time for some enterprising nerd to take advantage of that curiosity.

Improved improved GPS removal

Friday, October 22nd, 2010

I updated my jpeg geotag-removal script to recurse subdirectories. With that came the requirement to filter out irelevant files (not jpeg, no EXIF information). Below is the new script. I hope you find it useful:
#!/bin/bash
# Will remove non-essential EXIF from a jpeg while retaining Date/Time value.
# Use it to remove GPS information from pictures I want to put on the internet.
 
# Created Wed Aug 11 18:43:03 PDT 2010
 
# For handling spaces. See:
# http://www.cyberciti.biz/tips/handling-filenames-with-spaces-in-bash.html
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
 
for img in $@; do
 
    file_type=`file -b $img`
    file_type=${file_type:0:15}
 
    if [ -d "$img" ]; then
        echo "$img" is a directory - recursing
    $0 "$img/*"
 
    elif [ $file_type == "JPEG image data" ]; then
        # Grab the original date/time
        DT=`jhead "$img"|grep 'Date/Time'`
 
        # If the date information started out
        # blank, trying to tack it back on
        # will result in an error
        if [ "$DT" == '' ]; then
            continue;
        else
 
            # Current format: " Date/Time : yyyy:mm:dd hh:mm:ss"
            # jhead requires: yyyy:mm:dd-hh:mm:ss
            DT=${DT:15:25}-${DT:25}
 
            # Strip non-essential information
            jhead -purejpg "$img"
 
            # Put the date/time back
            jhead -mkexif -ts$DT "$img"
 
        fi
    else
        echo "$img" is not a JPG - ignoring $file_type
    fi
done

Hacking Tracks to accept shorter usernames

Monday, October 18th, 2010

I’m looking at Tracks/Shuffle to manage to-do lists on my phone/computer. I’m scouring the tubes for one that doesn’t involve me handing my data off to someone else. I like Shuffle because it can synch to any Tracks server you specify, and since Tracks is free software, it’s easy to install on any server.

In an effort to be able to use my usual login (kj), I H@X0R-H@X0R-H@X0R-ed the code to lower the minimum login from 3 to 2 characters. It’s not rocket science, but I hope it’ll save somebody else a bit of grepping:

In app/models/user.rb, line 115, change

validates_length_of :login, :within => 3..80

to

validates_length_of :login, :within => 2..80

In spec./models/user_spec.rb, line 81, change

it_should_validate_length_of :login, :within => 3..80

to

it_should_validate_length_of :login, :within => 2..80

If you’re feeling really ambitious, you could even change the error messages to be accurate. In test/unit/user_test.rb,. line 87:

assert_error_on u, :login, “is too short (minimum is 3 characters)”

to

assert_error_on u, :login, “is too short (minimum is 2 characters)”

Again in test/unit/user_test.rb,. this time on line 107:

assert_errors_on u, :login, ["can't be blank", "is too short (minimum is 3 characters)"]

to

assert_errors_on u, :login, ["can't be blank", "is too short (minimum is 2 characters)"]

Improved GPS removal

Friday, August 13th, 2010

I recently posted about a way to remove the GPS information from pictures. I wrote a script that will retain the Date/Time information. It requires jhead.
#!/bin/bash
# Will remove non-essential EXIF from a jpeg
# while retaining Date/Time value. I use it to
# remove GPS information from pictures I
# want to put on the internet.
 
# Created Wed Aug 11 18:43:03 PDT 2010
 
# For handling spaces. See:
# http://www.cyberciti.biz/tips/handling-filenames-with-spaces-in-bash.html
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
 
for img in $@; do
    echo Working on "$img"
 
    # Grab the original date/time
    DT=`jhead "$img"|grep 'Date/Time'`
 
    # Current format: " Date/Time : yyyy:mm:dd hh:mm:ss"
    # jhead requires: yyyy:mm:dd-hh:mm:ss
    DT=${DT:15:25}-${DT:25}
 
    # Strip non-essential information
    jhead -purejpg "$img"
 
    # Put the date/time back
    jhead -mkexif -ts$DT "$img"
done

It accepts image files as arguments. You can pass as many or as few as you feel like. If you’re interested in keeping other non-essential exif data, you might want to look into the jhead argument “-te”.

Removing GPS data from an image

Wednesday, August 11th, 2010

I constantly forget how to remove the geotags from my pictures before I put them on the internet. Here’s an imperfect way to do so:
jhead -purejpg /path/to/image.jpg
Source

This will get rid of timestamps and other ancillary information that you may want to keep attached to the image. It seems like it would be pretty simple to write a script that uses jhead with no arguments to grab the Date/Time field, then run it again with -purejpg to remove all extraneous data, then run it a third time with the appropriate arguments to re-set the Date/Time field.

Technology as explained by my mother: The Internet

Wednesday, July 7th, 2010

I was lamenting to my mother the difficulty in explaining technical answers to people who have limited experience with technology. She sighed sympathetically and said something along the lines of, “It’s very difficult for people who are used to dealing with a physical object to understand this thing fluttering all around us, breaking all the laws of physics.”
“Wait, where did you think the Internet is?”
She made a fluttering motion with her hands, “All around us. Like God.”

Technology as explained by my mother

Friday, July 2nd, 2010

Someday I’d like to rent out a hall or theater and charge $5 a head for my mom to answer the audience’s technical questions. The audience would require a certain amount of savvy to realize that her answers are hilarious, not informative.

I’ll probably never get around to renting that space, so in the mean time, I’ll be posting them here, in a series I call “Technology As Explained By My Mother “. The first installment has already been posted. I’ve got a few such episodes drafted, I can be reasonably certain this will be at least a three-part series. I hope you enjoy them as much as I do.