Jan 19 2010

Enabling the Developer menu in Safari 4 (for Vista and Windows 7)

Had a little bit of a run-around trying to do this because some information I found was for another version so I thought I’d post a quick ‘how-to’ up here. We’re going to be editing the preferences file for Safari. This file has a .plist extension and to edit it you’ll need to get this. After you finish downloading and installing it, launch it. Now go to File -> Open, and browse to this location: \Users\<your user name>\AppData\Roaming\Apple Computer\Preferences\, the file we need to edit is com.apple.Safari.plist so go ahead and open it.

Append these lines before the final </dict> and </plist> elements:

<key>IncludeDebugMenu</key>
<true/>

Restart Safari, you’ll now notice the ‘Develop’ menu option next to ‘Bookmarks’ and ‘Window’.

Enjoy.


Oct 24 2009

SingleFeed Export Module for Magento – How to strip HTML tags and special characters

Tested on:
SingleFeed Export Module v1.1.0
Magento v1.3.2.4

So I found this great module for Magento the other day, made by SingleFeed. It will export a product data feed every night. Then, we can import this feed into things like Google Base.

I ran into a problem though. You can’t import a data feed into Google Base that contains HTML tags and special characters. Most of the clients I work with prefer to have a WYSIWYG editor for things like the CMS pages, product descriptions, etc., which will add HTML formatting in the database. The SingleFeed Export Module does not automatically strip HTML on the fly (however I believe if you sign-up for an account at their website, they have a wizard that can do it for you.)

I poked around at the code for a bit and discovered that stripping the HTML tags and special chars would be quite easy using two functions: strip_tags, htmlspecialchars_decode.

Open app/code/community/SingleFeed/Export/Model/Mysql4/Profile.php and goto line 360:

360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
// format product data as needed
foreach ($products as $id=>&$p) {
  foreach ($p as $attr=>&$value) {
    // replace raw numeric values with source option labels
    if ($options = $this->attr($attr, 'options')) {
      if (is_array($value)) {
        foreach ($value as &$v) {
          $v = isset($options[$v]) ? $options[$v] : '';
        }
      } else {
        $value = isset($options[$value]) ? $options[$value] : '';
      }
    }
    // combine multiselect values
    if (is_array($value)) {
      $value = join(', ', $value);
    }
    // process special cases of loaded attributes
    switch ($attr) {
    // product url
    case 'url_path':
      $p["singlefeed.url"] = $baseUrl.$value;
      break;

I love well-written code, especially with good comments. All we’re going to do is add in our new formatting (in this case, just for the product description.)

360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
// format product data as needed
foreach ($products as $id=>&$p) {
  foreach ($p as $attr=>&$value) {
    // replace raw numeric values with source option labels
    if ($options = $this->attr($attr, 'options')) {
      if (is_array($value)) {
        foreach ($value as &$v) {
          $v = isset($options[$v]) ? $options[$v] : '';
        }
      } else {
        $value = isset($options[$value]) ? $options[$value] : '';
      }
    }
    // combine multiselect values
    if (is_array($value)) {
      $value = join(', ', $value);
    }
    // process special cases of loaded attributes
    switch ($attr) {
    // product url
    case 'url_path':
      $p["singlefeed.url"] = $baseUrl.$value;
      break;
    // product descriptions
    case 'description':
      $p["description"] = htmlspecialchars_decode(strip_tags($value));
      break;

That was almost a little too easy…


Aug 5 2009

DD-WRT350N v24 SP2 – Updated!

Originally I had thought my USB storage device was successfully connecting to router, it wasn’t. After reading a bit I discovered why…

From www-947.ibm.com:

The USB 2.0 specification requires a 10ms reset recovery time (TRSTRCY) after port resets before commands are issued to USB devices.

However linux kernels before 2.6.11 do not implement this recovery time leading to failures on USB 2.0 devices.

This failure is intermittent and seen on some devices (If other system activity causes there to be a 10ms delay between port resume and device access, then it works, else it would fail).

It also depends on the Host controller implementation.

The EHCI controller in the Broadcom HT1000 (BCM5785) SouthBridge does not like this violation of the spec. and fails to initialize devices.

I was using DD-WRT v24-sp1, and unfortunately I was having this problem. Luckily there is an unstable SVN version that fixes this problem.

From www.dd-wrt.com:

The unstable SVN version is in the others/EKO directory

Eko TNG svn 11296
http://www.dd-wrt.com/dd-wrtv2/down.php?path=downloads%2Fothers%2Feko%2FV24_TNG%2Fsvn11296/

dd-wrt.v24-11296_NEWD_mega.bin
TNG means the next generation,V24 SP2
NEWD means new driver, 500gpv2 should use NEWD version

I was nervous about installing this because it’s not an official release, but I felt re-assured after seeing several other people with the same router (Linksys WRT350N) running this SVN version. Installation went perfectly, and there is a new section/tab for USB.

DD-WRT v24-sp2 USB Screenshot

After I could see that everything was working properly, I temporarily moved the data on the USB storage and re-partitioned the hard drive. I made 4 partitions: opt (2GB ext3), jffs (2GB ext3), swap (2GB linux swap), storage (~ FAT32.) I did this so that I would be able to install optware packages onto the USB storage instead of using the memory on the router. The memory on the router is very limited, mounting optware to the USB storage now gives me the space to install whatever I want.

After everything was said and done, I installed Samba and now the FAT32 partition is shared over my network. I’m not going to go over all the steps involved such as mounting the partitions and installing Samba, because this is already covered on the DD-WRT Wiki. Good luck!!


Aug 5 2009

TweetSuite for WordPress Plugin – W3C Validation Error: Fixed

TweetSuite is a great plugin, it has a widget for displaying your latest tweets, displays tweetbacks, and lets you add in links to tweet or re-tweet a post on your blog. There’s more then a few things that need to be fixed with this plugin (ref: TweetSuite Errors and Troubleshooting), right now I’m just going to focus on some markup validation errors I came across.

The widget for displaying your latest tweets lists each tweet enclosed with li (listed item) tags. Unfortunately, these listed items have no unordered or ordered list parent tag. This causes a the markup to be invalid. To fix this is quite easy…

Open TweetSuite.php and goto line 907:

907
908
909
910
911
912
913
914
915
$buff = $wpdb->get_results("SELECT * FROM $table_name order by datetime desc limit $max");
 
foreach ($buff as $line) {
	$tweet = $line->tweet;
	$link = $line->link;
	$dt = date('m/d/y h:ia', $line->datetime);
	$output .="<li class=\"tweet\">$tweet <a href='$link'?phpMyAdmin=GNiTviqADsNCTwBkw2A2k7Yfxf8>$dt</a></li>";
}
echo $output;

and add in the appropriate opening and closing tags…

907
908
909
910
911
912
913
914
915
916
917
918
919
920
$buff = $wpdb->get_results("SELECT * FROM $table_name order by datetime desc limit $max");
 
$output = "<ul>";
 
foreach ($buff as $line) {
	$tweet = $line->tweet;
	$link = $line->link;
	$dt = date('m/d/y h:ia', $line->datetime);
	$output .="<li class=\"tweet\">$tweet <a href='$link'?phpMyAdmin=GNiTviqADsNCTwBkw2A2k7Yfxf8>$dt</a></li>";
}
 
$output .="</ul>";
 
echo $output;

This will enclose all the listed items with an unordered list tag, thus fixing the invalid markup.

The other problem I found was that some of the tweets had special characters (such as an ampersand) that were not converted to the specific html character code. This will also cause validation errors. To convert any special characters to use the appropriate special character code, we’ll need to make a real simple change.

Open TweetSuite.php and goto line 915:

915
$output .="<li class=\"tweet\">$tweet <a href='$link'?phpMyAdmin=GNiTviqADsNCTwBkw2A2k7Yfxf8>$dt</a></li>";

and change it to…

915
$output .="<li class=\"tweet\">" . htmlspecialchars($tweet) . " <a href='$link'?phpMyAdmin=GNiTviqADsNCTwBkw2A2k7Yfxf8>$dt</a></li>";

This will now convert any special characters in a tweet to use special character code.


Mar 1 2009

DD-WRT350N – USB Multimedia

So I run DD-WRT on my Linksys WRT-350N router. I know the router comes with a media server, allowing music and videos to be played through a wireless connection. My goal is to get this working using DD-WRT, but I’m having trouble figuring out how to do this.

My first step was to upgrade my version of DD-WRT to v24-FINAL. Doing this gave me the option to enable USB via the web control panel. The upgrade went flawlessly. I enabled USB and my external hard drive is connected.

This is where I am right now. I’m doing a bit of reading into where to go from here, but it looks like I’m going to have to install some Optware packages. My main concern now is how much space I have on the router to be able install the packages I will need.


Jan 16 2009

Adding a mini login box to Magento

I’m surprised there is not one in the default template for Magento.  Nevertheless, it’s pretty common to see a login box on a sidebar, and I need one.  This is actually pretty simple to do, we’re going to be modifying templates, layouts, and unfortunatly we’re going to have to alter the core (for something really silly.)

First, lets go ahead and make a template for the mini login box.  Take a look in ⁄template⁄customer⁄form⁄…  What’s this!?  We already see that there is a mini.login.phtml.  For a closer look:

<form action="<?php echo $this->getPostActionUrl() ?>" method="post">
    <table width="100%" class="mini-login">
        <tr><td><?php echo $this->__('Email') ?>:</td><td><input name="login[username]" /></td></tr>
        <tr><td><?php echo $this->__('Password') ?>:</td><td><input name="login[password]" /></td></tr>
        <tr><td>&nbsp;</td><td><input type="submit" value="<?php echo $this->__('Login') ?>" /></td></tr>
    </table>
</form>

We’ll, even though functional, this isn’t styled nor does it fit in with the default Magento template. So let’s change this.

<div class="box base-mini mini-login-form">
    <div class="head">
        <h4><?php echo $this->__('Login') ?></h4>
    </div>
    <form action="<?php echo $this->getPostActionUrl() ?>" method="post" id="login-form">
        <div class="content">
            <ul class="form-list">
                    <li>
                        <label for="email"><?php echo $this->__('Email Address') ?> <span class="required">*</span></label><br />
                        <input name="login[username]" value="<?php echo $this->htmlEscape($this->getUsername()) ?>" title="<?php echo $this->__('Email Address') ?>" id="email" type="text" class="input-text required-entry" style="width:122px;" />
                    </li>
                    <li>
                        <label for="pass"><?php echo $this->__('Password') ?> <span class="required">*</span></label><br />
                        <input name="login[password]" type="password" class="input-text required-entry validate-password" id="pass" style="width:122px;" />
                    </li>
                </ul>
                <p class="required"><?php echo $this->__('* Required Fields') ?></p>
          </div>
    <div class="actions">
        <button class="form-button-alt" type="submit" name="send" id="send2"><span><?php echo $this->__('Login') ?></span></button>
    </div>
</form>
<script type="text/javascript">
    var dataForm = new VarienForm('login-form', true);
</script>
</div>

Also add this to your CSS:

.mini-login-form h4 { background-image:url(../images/icon_page_white_text.gif); }

Now that we have a template (mini.login.phtml), we’re going to have to add it to our block structure. Open layout/customer.xml, and make this change starting at line 65.

<customer_logged_out>
        <reference name="top.links">
            <action method="addLink" translate="label title" module="customer"><label>Log In</label><url helper="customer/getLoginUrl"/><title>Log In</title><prepare/><urlParams/><position>100</position></action>
        </reference>
        <remove name="wishlist_sidebar"></remove>
        <remove name="reorder"></remove>
        <reference name="right"> 
            <block type="customer/form_login" name="mini_login" template="customer/form/mini.login.phtml" /> 
        </reference> 
    </customer_logged_out>

Remember to copy this file/folder structure and put it in app/code/local. We do this, because when you go to upgrade your Magento installation, your core files get patched, thus erasing all the hard work you did :P


Dec 19 2008

3 books I’d like to read

VIM is probably one of the most powerful text editors I’ve ever come across. I can’t even begin to tell you what it’s capabilities are. This book is probably a little advanced for me, but I’ll still be able to learn from it.

Java is always something I wanted to learn. Also, I enjoy reading books published by Apress.

Beginning Java Objects: From Concepts To Code, Second Edition
Price: USD 37.11

38 used & new available from USD 17.60

MooTools is a light, modular JavaScript framework that makes adding Ajax, animations, and interactive elements to your site a breeze. This would help a lot with web animation, and avoiding building applications in Flash.


Dec 19 2008

Thinkpad x61 with Ubuntu: Getting the 3rd mouse button to work.

There are two different methods I found, which work for different version of Ubuntu.

Ubuntu 8.10

First, copy/paste below

<match key="info.product" string="TPPS/2 IBM TrackPoint">
<merge key="input.x11_options.EmulateWheel" type="string">true</merge>
<merge key="input.x11_options.EmulateWheelButton" type="string">2</merge>
<merge key="input.x11_options.YAxisMapping" type="string">4 5</merge>
<merge key="input.x11_options.XAxisMapping" type="string">6 7</merge>
<merge key="input.x11_options.Emulate3Buttons" type="string">true</merge>
<merge key="input.x11_options.EmulateWheelTimeout" type="string">200</merge>
</match>

Then, make a new file /etc/hal/fdi/policy/mouse-wheel.fdi

sudo vi /etc/hal/fdi/policy/mouse-wheel.fdi

Insert a new line by hitting the letter i
Paste by hitting shift+ctrl+v
Save and quit by typing :wq
Reboot.
That’s it, pretty hard eh?

Ubuntu 7.10

Replace the mouse entry of your /etc/X11/xorg.conf with the following (its a good idea to back up your xorg.conf before making any changes):

Section "InputDevice"
 
Identifier "Mouse1"
 
Driver "mouse"
 
Option "Protocol" "ExplorerPS/2" # IMPS/2 is not recommend for TrackPoints
 
Option "Device" "/dev/input/mice"
 
Option "EmulateWheel" "on"
 
Option "EmulateWheelTimeout" "200"
 
Option "EmulateWheelButton" "2"
 
Option "YAxisMapping" "4 5"
 
Option "XAxisMapping" "6 7"
 
EndSection

Reboot.


Dec 17 2008

X61 Wireless: Fixed

Ok the subject is a little misleading, I didn’t actually fix anything, because nothing was broke to begin with.  I have verified that the problem is not hardware related.  I have a strong belief the culprit was the AccessConnections software.  When I last used the ThinkVantage software updater, it upgraded my AccessConnections software.  After this update, the integrated network adapter just completely stopped working.

As I said before, I tried installing Debian to see if the card was working, unfortunatly I didn’t realize that I was using the stable (old) kernel version, and I needed the newer kernel version to get the correct modules for the network adapter.

I just installed Ubuntu 8.10, and during installation the wireless light lit up, very much like a Christmas tree :-)

So, I didn’t exactly solve the problem, I didn’t really even figure out what the problem was, but I now know what it isn’t, it’s not hardware failure.

I advise anyone having this problem, to either revert to a backup copy before you did any updates.  This is the only thing I can advise at this point.  Or if you’re feeling frisky, go ahead and give Ubuntu a try :-)  Everything should “work out of the box.”

Good luck.  If this post helped you at all please leave a comment, anything will do.
I barely get any comments.

EDIT: http://betweengo.com/2006/10/31/thinkpad-t60-wireless-keeps-powering-off/


Dec 16 2008

America’s Most Wanted’s John Walsh – CASE SOLVED TODAY

I’m in complete awe, 27 years later this case is finally solved.

If you didn’t know, “America’s Most Wanted” TV host John Walsh’s son went missing on July 27, 1981.  Today this case was finally solved.

My deepest condolences to the Walsh family.

Read more here:
Fla. police close books on ‘81 Walsh killing