Mostly about my amusement

Author: Jan Dembowski (page 26 of 96)

dd-wrt to the rescue (again)!

My Netgear WNR834B v2 has been showing it’s age and giving me grief lately. After a few hours of network usage, my Netgear would suddenly start rebooting itself and keep doing that every few minutes.

The only thing that would bring it back to life would be to pull the plug, wait a few seconds, and put the plug back in. The last firmware for my device is version 2.1.13 dated May 16th, 2oo8. This doesn’t fill me with confidence that the vendor can solve my problem. I don’t blame Netgear for that; they make money on the sale of hardware and not support.

I use a pair of these WNR834Bs to connect my second floor to my ISP in the basement.  It’s strictly for bridging a gap where I am not easily able to run a wire.

So I went to the dd-wrt website and picked out the firmware using their router database tool and put in my model. This lead me to their wiki page to read some instructions, and in less than an hour of playing with settings I had dd-wrt running.

The speed difference is pronounced. It’s not just my imagination, web pages are loading more quickly than before. I don’t think that means the Netgear firmware was defective, I do think that tuning additional options in dd-wrt helped improve the situation.

This is a low cost solution to extending the life of some hardware and keeps me from running cable. So far so good and I’ll just see how it goes.

Easy Twitter Button for WordPress

Twitter announced their own Tweet Button and have provided a page for creating a button on your web site. You enter some info and you get the HTML code to add.

Extending WordPress has always been easy. You can add what you want via a plugin, or you can put the functionality into your theme’s function.php file.

I wanted to play around with adding this to my blog, so I went to their page and created my button. I then used the generated code as a template for what I wanted to do.

There is no way I’m savvy enough to write a plugin, but adding a filter to my theme’s function.php file is within my reach.

This is from an idea I got when I read WP Beginner’s post on how to add post thumbnails to your RSS feed. I used his code to do this.

function tweet_button($content) {
        global $post;
        // Your Twitter ID goes here
        $twitterid = 'jan_dembowski';
        $tweetbutton = '<div class="tweet-button">';
        $tweetbutton = $tweetbutton . '<a href="http://twitter.com/share" class="twitter-share-button" data-url="' . get_permalink() .'" data-text="' . get_the_title() .'" data-count="horizontal" data-via="' . $twitterid . '">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>';
        $tweetbutton = $tweetbutton . '</div>';
        // $content = $content . $tweetbutton;
        $content = $tweetbutton . $content;
        return $content;
        }
add_filter('the_content', 'tweet_button');

You can download the code via this text file link.

It’s not exactly user friendly, but it gets the job done. I wrapped it in a <div> so I can style it later. If you want the button at the end instead of the beginning, then comment out line 9 and un-comment out line 8.

It’s a fun hack for me and I am sure that soon there will be a plugin to do this. If you do decide to do this then make sure you backup your theme’s function.php file. Any typo’s or mistakes will make your WordPress blog stop working.

Coraline child theme

Have I mentioned how easy it is to use WordPress child themes? I can’t stress it enough, never modify a WordPress theme. Create a child theme instead.

I just converted a blog from an old outdated Cutline theme to a SVN copy of Coraline.  This is the WordPress.COM replacement for the Cutline theme.  The old theme bugged me for a few reasons, mainly it was the lack of basic features such as Gravatar support. I had meant to clean it up but never got around to it.

It took me less than an hour to make the switch. I retrieved a copy of Coraline like so

$ cd wp-content/themes
$ svn co http://svn.automattic.com/wpcom-themes/coraline coraline

This keeps an unmodified copy of the Coraline theme.  Once it’s in the WordPress.ORG website, I’ll replace it with that copy.

All I had to do was create a separate directory and create a style.css file with the following:

/**
 * Theme Name: Coraline for Stefan's Stuff
 * Description: Jan Dembowski's Coraline Child Theme
 * Version: 1.0
 * Template: coraline
 */

@import url("../coraline/style.css");

/* =Asides
---------------- */

.home #content .aside {
 border-left: 1px solid red;
}

The old asides had a slightly different styling.  I made copies of the header.php and footer.php files into my child theme directory and added an archives.php template. I modified one line in each of the copies.

I tossed in a rotate.php script and copies of the random banner images and I was all set. I did need to resize the old banner images from a width of 970 to 990 but that was it.

Child Themes are cool and once again I can keep the parent theme up to date without worrying about my changes.

Android or iPhone 4?

Do I get an Android phone or an iPhone 4? I’m in no rush to get a new phone but I do periodically suffer from phone envy.

I am a fan of easy-to-use technology. I currently own an iPhone 3G with iOS 4.0.1 installed. My phone has been jailbroken not because I have a “SOFTWARE MUST BE FREE!!!1!” itch, but because I wanted to tweek my phone in ways that Apple doesn’t support for my hardware.

Cool Applications, not so cool app store

One of my favorite apps on my iPhone is Camera+. It lets me take photos, make adjustments, and share those photos online. All within the app and very easily.

The Camera+ developers came up with the idea of modifying the volume up button to be used as a shutter button. This re-mapping of the button would only be done while the user is in the app. It’s a great idea and makes using Camera+ easier.  But the idea was rejected by the app store, so the developers created a back door to enable that setting.

That’s a sensible work around because the app store was apparently afraid that re-mapping the volume up key while in the Camera+ app would create confusion. Since the end-user would have to access a specific application URL, they would have to know what they were doing.

But as expected the Camera+ app has been removed from the app store. Rules are rules, especially when they are arbitrary, imaginary, mostly made up, and not published.

Do I really want to continue using a product that fosters an environment like this? I know that the Android Market Place has it’s pitfalls too but the Apple App store is driven by incompetence.

Android is becoming more cool

I know two people who have Android phones from Verizon.  The first phone I’ve seen is the HTC Incredible.  The UI is easy to use and makes the experience fun.

The other phone is the Droid X.  The display portion alone feels like it’s bigger than my iPhone 3G.  It’s not a small phone in comparison but the display is fantastic. It’s not as slick as an HTC phone but it is close.

How would a Gorilla design a better Gorilla?

I’ve also seen the iPhone 4.  The display is phenomenal but it’s essentially a better iPhone 3GS. It’s more resolution, more memory, faster CPU.  But it’s still an iPhone and I already have an inferior version right now.

Why just get a better version of the iPhone 3G? Why not get a new phone and try out the other guys? If Camera+ existed for the Android phone, that would go a long way to hastening my decision.

iPhone 3G slowness

Within days of my putting on iOS 4.0.1 onto my iPhone 3G, the phone started to crawl. Playing music was painful and using applications became a joke. For example doing anything with Camera+ (a very cool photo app BTW) would take minutes when it used to take seconds. Downgrading to 3.1.3 caused my apps to become responsive.

Last Wednesday I installed iOS 4.0.1 and did not restore my backup. I factory defaulted the phone and when it was plugged into my PC, I treated it like a new phone. This meant I had to copy my song library, apps, etc. from scratch. I recovered my contacts easily enough because I use Google Sync.

Next up I went into my iPhone’s settings app and turned off all Spotlight searches. If I could disable Spotlight 100% I would do it; this is one feature that Apple should have left on design table.

I also jailbreak’ed my iPhone and made the following changes:

  1. I turned on SpringBoard’s image backgrounds.
  2. I enabled Multitasking.
  3. I turned on the percentage battery meter option.

Why not? I ended up turning off multitasking because while everything ran acceptably, when you are out of memory, apps would not start properly. The background image is not as fast as a 3GS but still usable and makes the phone more attractive.

To make my modifications, I installed iPhone Explorer on my PC to copy and modify a .plist file manually. This is not not the safest way to do it. In the Cydia app store is an application called Features (for iPhone 3G) that installs in WinterBoard.

So far the performance has been alright. If/when I get an iPhone 4 the display and speed will probably startle me.

Some imaginary files are alright

This is probably a case of my not reading the manual.

I use W3 Total Cache not because I get a ton of hits. I run it because it’s cool and interesting. With the current 0.9.1 version it suggests that you add to your .htaccess file a section to handle 404 for missing static files. So non-existent txt, css, jpg, etc. will just get the web server’s 404 page and save on CPU processing via WordPress PHP.

Sensible, but robots.txt  is an imaginary file for my WordPress blog.  Requests to that file get sent to index.php and the output is dynamically created. Without the exclusion, that file URL always gets 404’ed.

Easy to fix. Right above the W3TC lines just add these lines to your .htaccess file.

<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^robots.txt index.php [L]
</IfModule>

The ReWriteCond is not really needed, I’m just putting it in to be complete. If a request comes in for robots.txt it will be sent to WordPress for handling.

Why would the Chinese do that?

Reading the NY Times Editorial this morning made me shake my head.

China, which has abetted its neighbor’s excesses for too long, needs to ensure that the North’s bluster is only bluster. And it needs to tone down its own.

via Editorial – North Korea’s Latest Tantrum – NYTimes.com.

The North Korean government has successfully turned the carrot and stick idea on its head. Kim Jong-Il has successfully become the James Bond villain and knows that he’ll get more food, more fuel, or just more money.

While the Chinese government may be embarrassed by their neighbor’s behavior, there is not much reason for them to flex their muscle. Stability in the region is important but while it is the U.S. interests that does not translate into the interests of the Chinese government.

I do agree that the Chinese government could get involved differently, I just don’t believe they’ll do so because the west wants them to.

Use WordPress child themes

Before WordPress 3.0 the default Kubrick theme was called, um, “Default”. In the support forums people would update to the latest and greatest WordPress version and become shocked when their edits to the Default theme were lost.

It’s part of the WordPress distribution. When you override the WordPress files, those get included as well. Now with 3.0 the Default theme is gone and replaced with Twenty Ten. People will still make the mistake and modify the theme directly.

It’s not necessary and by creating a few simple file and directories, using a child them on your own is easy.

I’m a fan of the Hybrid theme and have been using a child theme already. The Vigilance theme caught my eye and I thought I’d give it a try. It was even easier when I located their instructions on how to start off.

1. Start with a pristine copy

I downloaded a copy of Vigilance from the Theme Foundry website and extracted it to my wp-content/themes directory. The version on their website is 1.51 which is slightly more up to date than the version on WordPress.ORG’s site.

2. Create your child theme directory

In wp-content/themes I create a directory called mostlyharmless-vigilance and extracted the files from this zip file into it. This is outlined in The Theme Foundry’s instructions.

3. Modify the CSS on the child theme

In the child theme directory I modified the style.css and added  a few lines:

.center-ad { text-align: center; margin:10px 0 10px 0; }
ul li.widget ul li a {
 display: inline;
 padding: 0;
 background: none;
}
embed {
 background: #fff;
 border: 2px solid #eee;
 }
#wrapper {
 background-color: white;
 border: 1px solid #ccc;
 padding: 15px;
 margin: 25px;
 margin-left: auto;
 margin-right: auto;
 border-radius: 10px;
 -webkit-border-radius: 10px;
 -moz-border-radius: 10px;
}
body {
 background-color: #ecf1ef;
}

This was to do provide me a CSS class to

  1. Provide a class to center my 2 ads
  2. Modify how the sidebar links look
  3. Put a border around and embedded videos
  4. Mess with the wrapper ID
  5. And change the color of the body background.

Nothing dramatic and the rounded corners are very 2004.

4. Modify the child theme’s functions.php file

My child theme has one useful line in it like so


php
$GLOBALS['content_width'] = $content_width = 600;
?>

I use oembed to insert YouTube and Vimeo videos into my posts. By adding this line, the embeds become 600px wide when the content supports that.

5. Start modifying files (if you want to)

The Vigilance theme will display that posts featured image if it exists. I comment out that line in index.php to disable the from happening. I copied index.php from wp-content/vigilance into wp-content/mostlyharmless-vigilance and edited line 15

<div class="entry clear">
<?php if ( function_exists( 'add_theme_support' ) ) the_post_thumbnail( array(250,9999), array( 'class' => 'alignleft' ) ); ?>

and commented out the if function.

<div class="entry clear">
<?php // if ( function_exists( 'add_theme_support' ) ) the_post_thumbnail( array(250,9999), array( 'class' => 'alignleft' ) ); ?>

Next I copied the header.php file into my child directory and modified the second line DOCTYPE from strict to transitional. Some plugins I use look better in transiti0nal.

Last, I made a copyof single.php and modified it to insert my second ad.

6. Upgrades wont worry me now

The whole point of this exercise was to make changes to the Vigilance theme while not touching the Vigilance theme’s files. When an update to the parent theme comes out, I won’t have to worry about what I’ve changed.  The three files I have modified are easily determined and simple for me to support.

If you only want change the CSS, then it’s even less work and you can skip step #5.