Category Archives: Workarounds

Installing Alan Storm’s LayoutViewer in Magento (works with 1.7!)

I use the debug toolbar but nothing beats Alan Storm’s configviewer and layoutviewer. Unfortunately the only archive of this on Alan’s site is missing a module config file to activate it. Below is a simple shell script to download, install and activate the LayoutViewer in any version of Magento. I can confirm it works flawlessly in Magento 1.7. If you’d like to manually install this module, read the “manual installation” section below.

Script

#!/bin/sh

#VIEWER_HTTP_DOWNLOAD="http://alanstorm.com/2005/projects/MagentoLayoutViewer.tar.gz"
VIEWER_HTTP_DOWNLOAD="http://biodegradablegeek.com/MagentoLayoutViewer.tar.gz"

# If in root, go to app/code/local
if [ -f "index.php" ]; then
    cd app/code/local;
fi

echo "Using curl to download Magento LayoutViewer"
curl -so - $VIEWER_HTTP_DOWNLOAD | tar xvzf -

echo "Writing app/etc/modules/ config file"
(
cat <<'ConfigFile'
<?php xml version="1.0"?>
<config>
<modules>
 <Alanstormdotcom_Layoutviewer>
   <active>true</active>
   <codePool>local</codePool>
 </Alanstormdotcom_Layoutviewer>
</modules>
</config>
ConfigFile
) > ../../etc/modules/Alanstormdotcom_Layoutviewer.xml

echo "Done. Visit any page with ?showLayout=page"

Save this to a file and run “sh” in your Magento root.

Manual Installation

Download the MagentoLayoutViewer and extract the Alanstormdotcom folder to [magento-root]/app/code/local/

Create a new config file in app/etc/modules/ named Alanstormdotcom_Layoutviewer.xml  and paste in it the following:

<?php xml version="1.0"?>
<config>
<modules>
 <Alanstormdotcom_Layoutviewer>
   <active>true</active>
   <codePool>local</codePool>
 </Alanstormdotcom_Layoutviewer>
</modules>
</config>

Done. See usage below.

Module Usage

Visit any URL with ?showLayout=page (or handle or package) to retrieve the layouts XML

The module also accepts a showLayoutFormat=text argument if you’d like plain text instead of XML.

Example: http://my-store.cxm/product/123?showLayout=page&showLayoutFormat=text

What Firefox’s Memory Leak Feature Taught Me About Life

(draft)

I’ve been using Firefox since the first public beta, and the one thing always on my wish list was fixing the sluggishness and unbelievable memory consumption (2 GB of RAM?) that results from keeping Firefox open for too long. This is still on my wish list today (almost 2010), and I know it’s unlikely to be fixed. In fact, I’ve realized that – Zen Moment – the ‘patch’ must come from within.

The Mozilla team claim it is a feature and not a bug. Firefox stores pages you’ve been to so that you can go back to them instantly upon hitting the “Back” button. This means that FF’s memory needs grow as you browse the net, and leaving a page doesn’t necessarily mean the page’s memory has been deallocated. It makes sense, but in practice it results in Firefox becoming unresponsive. You can go into about:config and edit hundreds of settings, but I’ve never had any success with any of them in any version of Firefox on any OS. Ever.

I probably don’t use Firefox like the majority of users, and certainly not like the developers intended. For one, I don’t close it. In fact, I’ve never voluntarily closed Firefox in my life (I don’t shut down). I purposely crash it and then re-open it so that it asks me to load up all my previously open tabs. This clears out some memory and restores responsiveness making Firefox useable again.

Why don’t I just close it? Because I usually have a minimum of 50 tabs open across several FF instances, and some of those tabs are actually those “Oops, this is embarrassing…” windows that let you choose what tabs to re-open when you re-run a crashed Firefox. That means some of the tabs hold the potential to open up dozens or even hundreds of more tabs.

I feel relieved when Firefox is unable to restore my tabs. Life starts anew.

I keep tabs open that I intend to go through (never!), and I keep different sets of windows/tabs open depending on what I’m doing. i.e., cooking tabs in one window, work tabs in another, research tabs in another, etc. But this isn’t restricted to Firefox. On my Linux desktop I have 2 displays and 8 virtual desktops, making that 16 workspaces, and they’re usually always full. Since I have the RAM/power to run this setup, it’s smooth… except for Firefox and most other browsers (not Chrome).

On this desktop I worked around the Firefox memory problem by creating multiple profiles and using different profiles for different tasks (one for work, one for multimedia, etc). This also allowed me to crash one without affecting the others. It’s a temporary and crude solution until Firefox natively supports multiple processes like Chrome (see Electrolysis.)

But while there are some workarounds, fixing the technical issue isn’t going to increase productivity much. Having more sites open will probably make things worse. The habit of putting things off for later is inherently the problem. Having many sites/apps open is normal only amongst abnormal people. There’s nothing ‘wrong’ with it, but I don’t feel it’s very efficient, even if it may seem so at the time.

I’m generally disorganized and severely ADD-ed, and so this issue doesn’t only exist digitally. My desk is just as messy as Firefox. I have pieces of paper, napkins and anything else I jotted down notes on. I have unopened snail mail, opened but unchecked mail, and mail that has been checked and separated into 2 piles, those that require a reply and those that are to be trashed. There’s books I’m reading (multiple), and always unsorted pages of ideas/diagrams/blueprints of things I’ll probably never get to.

I’m obviously spreading my attention span thin. Going back to Firefox, if there’s an important piece of news on a page buried beneath other sites, I subconsciously still have “must read that article” somewhere deep in my head. It probably doesn’t result in any noticeable effect on its own, but when multiplied by 100x, the decline in calmness becomes significant enough to kill productivity. It produces a weak feeling of anxiety or overwhelmingness.

The Gmail Captcha is Optional

When you try to login with bad credentials, Gmail gives you a captcha to fill in before your next login attempt. Not only does this captcha appear randomly (keep putting in the wrong username and it will sometimes appear, sometimes not) (update: now it appears to be more consistent), but it’s also optional*. Just put in your correct username and password, ignoring the captcha, and it will log you in.

I probably discovered this out of frustration, but for the past few months (or years) I thought it was something we all knew until I saw one of my friend’s enter the captcha value. I never actually stopped to think about why a captcha would be “optional” – it’s ridiculous, and I’m probably overlooking an obvious point to this.

Enter the correct name/pass and hit login
Enter the correct name/pass and hit login
Seemingly random captcha
Seemingly random captcha

* I’m not sure why, but some people are saying that they cannot login without entering the captcha. I’ve tried on Swiftweasel and Firefox 3.x/Opera 9.x and 10/Konqueror/Chrome on Linux, and on Safari on the Mac, and have never needed to enter the captcha.

Also worth mentioning, a lot of forms you get when you try to download something are optional. For example, if you try to download Mimer SQL, it gives you this form: http://developer.mimer.com/downloads/downloads_licens.tml?id=528 but you can just scroll down and hit the download button without putting any info in.

How to Block AIM’s Annoying ‘AOL System Msg’ in Pidgin

The following plugin for Pidgin will block the incredibly annoying and useless notifications from AOLSystemMsg on AIM.

“AOL System Msg: Your screen name (mrEman) is now signed into AOL(R) Instant Messenger (TM) in 2 locations. Click here for more information.”

To use, paste code in file, save file as blockaolsystemmsg.pl in ~/.purple/plugins/ and then open (or re-open) Pidgin and go to Tools -> Plugins (or press CTRL+U), and enable “Block AOLSystemMsg.” That should be it!

If you’re having any trouble, try going to Help -> Debug to open up Pidgin’s debug console.

#!/usr/bin/perl
# BlockAOLSystemMsg plugin tested on Pidgin 2.5.5. Put in ~/.purple/plugins/ and enable
use Purple;
our $target = 'AOL System Msg'; # case-insensitive
our $plugin_name = 'Block AOLSystemMsg'; 

%PLUGIN_INFO = (
  perl_api_version => 2,
  name => $plugin_name,
  version => "0.1",
  summary => "Blocks the screen name 'AOL System Msg'",
  description => "Ignore annoying 'your SN has signed on at 2 locations' AIM message",
  author => "Isam ",
  url => "http://biodegradablegeek.com",
  load => "plugin_load",
  unload => "plugin_unload"
);

sub loginfo { Purple::Debug::info($plugin_name, " @_\n"); }
sub minimize {
  my $r = lc($_[0]);
  $r =~ s/ //g;
  return $r;
}

sub plugin_init { return %PLUGIN_INFO; }

sub plugin_load {
  my $plugin = shift;
  $target = minimize($target);
  loginfo("Sight set on '$target'");
  Purple::Signal::connect(Purple::Conversations::get_handle(),
                          'receiving-im-msg', $plugin, \&callback, '');
}

sub plugin_unload {
  my $plugin = shift;
  loginfo('Block AOLSystemMsg Unloaded.');
}

sub callback {
  my ($acc, $sender, $msg, $flags) = @_;
  if (minimize($sender) eq $target) {
    loginfo("(BLOCKED) <$sender> $msg");
    return 1
  };
}

update: Fixed the botched code. Thanks.

Burning Xbox 360 Games on Linux (Stealth!)

xbox360-bg
You could run ImgBurn in Wine, or probably burn the games in VirtualBox running Windows, but that’s no solution… you’re reading this because you want to burn Xbox 360 games on Linux using native tools. It’s surprisingly easy!

The games are usually an ISO file, along with a little DVD (.dvd) file that tells the burner to use a layer break value of 1913760. This file is not necessary in Linux (or Windows) as we will be telling the app to use that break value explicitly.

I will go into detail on how to setup what you need. If you’re impatient, you might wanna skip the setup and jump straight to the quick recap.

Extract the ISO

cd /games/360/GameX
rar  x kfc-gamex.part01.rar

If you don’t have rar (“winrar”) installed, lookie:

The program 'unrar' can be found in the following packages:
 * unrar-free
 * unrar
Try: sudo apt-get install 

you can also DL it from rarlabs.com.

Now we need to see if the game is stealth/valid. This is done using an app that runs natively on Linux (and OS X) called abgx360.

Install abgx360

abgx360-linux

Download the tar.gz files from http://abgx360.net/download.html. The TUI is nice. Don’t bother getting the GUI for abgx360.

tar -zxvf abgx360-1.0.0.tar.gz
cd abgx360-1.0.0/
./configure && make
sudo checkinstall -D

(You may use ‘make install’ but this is not recommended on Debian/Ubuntu. checkinstall keeps your shit organized.)

If ./configure fails with an error about wx-config/wxWidgets, make sure wxWidgets is installed..

apt-cache search wxgtk2 

and make sure wx-config is in your PATH. On Ubuntu Intrepid, it wasn’t. Find it and make a symlink to something in your path.. i.e.,

locate wx-config # (finds it in /etc/alternatives/wx-config)
sudo ln -s /etc/alternatives/wx-config /usr/bin/wx-config

Rerun ./configure/make/checkinstall

If you downloaded the local database (abgx360-data) from the site above, install it now; Just extract and move the .abgx360/ dir into your ~/

Checking ISO CRC/SS – Is the game stealth?

abgx360 -af3 kfc-gamex.iso

the af3 flag will automagically fix/patch the ISO should it encounter any problems.
What abgx360 will do is check the ISO’s CRC against an online (or offline, ~/.abgx360/) database. It might begin by updating its database. If this is a problem (no net connection), pass it -localonly

When that’s done…

Burning the ISO Using growisofs

Making sure the dual layer DVD is in your drive, run the following command:

# growisofs -use-the-force-luke=dao -use-the-force-luke=break:1913760  -dvd-compat -speed=4 -Z /dev/burner=kfc-gamex.iso

I commented it out so you don’t execute it trying to paste it. Let’s look closer at this command…

The break:1913760 is the layer break, which you’ll find in the .dvd file. If for whatever reason you can’t check the .dvd file, just use this value.

Set your speed to something low. Some say 2.5x but I have no problems burning at 4X (my max is 8X). You don’t need to know the lowest speed your burner can go. Just set it to 2-4 and you’ll be fine.

Set /dev/burner to your own device. It’s probably /dev/scd0, /dev/scd1, or may already have a symlink like /dev/dvd6 /dev/dvd etc..

Try grepping dmesg to find your device. i.e.,

dmesg | grep "LITE"

This might give you some information but probably nothing too helpful:

sudo dvdrecord -scanbus

To see if you have the right device, try ejecting it.

eject /dev/dvd6

Set the kfc-gamex.iso to whatever the name/path of your ISO is (case sensitive of course).

Now I usually begin with a dry run. By passing -dry-run to growisofs, it will proceed as normal but quit before writing anything to disk. Actually, it kind of just spits out a command and dies. Awful design! i.e.,

$ growisofs -dry-run -use-the-force-luke=dao -use-the-force-luke=break:1913760  -dvd-compat -speed=4 -Z /dev/burner=kfc-gamex.iso
Executing 'builtin_dd if=kfc-bh5.iso of=/dev/dvd6 obs=32k seek=0'
$ 

So the above is good. Now remove the -dry-run flag to proceed with the actual burn.

growisofs -use-the-force-luke=dao -use-the-force-luke=break:1913760  -dvd-compat -speed=4 -Z /dev/burner=kfc-gamex.iso

Find something to do, or just stare at the screen. After about 20 minutes (at 4X), you’ll see the burn end successfully with output like this:

 7798128640/7835492352 (99.5%) @3.8x, remaining 0:06 RBU 100.0% UBU  99.8%
 7815495680/7835492352 (99.7%) @3.8x, remaining 0:03 RBU  59.7% UBU  99.8%
 7832862720/7835492352 (100.0%) @3.8x, remaining 0:00 RBU   7.9% UBU  99.8%
builtin_dd: 3825936*2KB out @ average 3.9x1352KBps
/dev/burner: flushing cache
/dev/burner: closing track
/dev/burner: closing disc

You’re done!


Quick Recap


Assuming you installed all the dependencies above, here’s a quick recap of what needs to be done to burn a game.
It really takes about 1 minute to begin the process. Write a shell script if you like.

cd GameX_REGION_FREE_XBOX360_KFC/
rar x kfc-gamex.part01.rar # Extract game ISO 
abgx360 -af3 kfc-gamex.iso # Checks if rip is valid/stealth/ss patched
growisofs -use-the-force-luke=dao -use-the-force-luke=break:1913760  -dvd-compat -speed=4 -Z /dev/burner=kfc-gamex.iso
eject /dev/burner # When burn is done, eject & play. 

Create Unique Email Addresses From One Gmail Account

gmail_logo
Many sites won’t let you use one email address to register multiple accounts. Sometimes you have legitimate reasons to, and other times you just wanna spam build backlinks. Either or, here’s how you can get around this…

Gmail accepts email that has a ‘+’ appended to the username of your email address. Text can be anything alphanumeric. I.e., BigBadPenguin+123@gmail.com

The validation on the site won’t pick this up as a duplicate email address, and messages will still go through to your inbox. If I want 3 accounts on WordPress.com under the same email, for example, I just append +1 and +2:
(You might want your postfix to be more descriptive than this)

  • BigBadPenguin@gmail.com
  • BigBadPenguin+1@gmail.com
  • BigBadPenguin+2@gmail.com

Mephisto for the Masses – Installation HOWTO

I’ve recently taken a fancy to Mephisto, a blogging-platform written in Rails. I have nothing against WordPress, but being in Ruby and using Liquid for themes, Mephisto is far easier (and more fun) to tweak and configure, especially when I want to migrate my sites away from the “blog look” and make them more dynamic.

It’s unfortunate development isn’t as active as say, Typo (also a Rails app, but I haven’t tried it), but I find that Mephisto at its current level makes a simple and fast starting point for most of my projects.

The point of this post is to address numerous problems with the installation. These are present in the tarball release of 0.8 Drax, and in trunk (as of 10/21).

Git The Code

Get the files, either the compressed archive or from edge (recommended).

git clone git://github.com/technoweenie/mephisto.git

Pre-installation

You’ll need to freeze rails 2.0.2, and have the latest tzinfo gem installed:

gem install tzinfo 
cd mephisto/ 
rake rails:freeze:edge RELEASE=2.0.2

The file it downloads should be named rails_2.0.2.zip and NOT rails_edge.zip.

Copy the “new” boot.rb into the config/ folder, overwriting the existing one:

cp vendor/rails/railties/environments/boot.rb config/boot.rb

Now rename the database sample file in config/ to database.yml and edit it to fit your own DB settings. You’ll probably only be using production.

Bootstrapping

Now bootstrap:

rake db:bootstrap RAILS_ENV=production

If it works, GREAT. But you’ll probably get an error or two. If you’re getting the following error:

Error message:
  undefined method `initialize_schema_information' for module  
  `ActiveRecord::ConnectionAdapters::SchemaStatements'
Exception class:
  NameError

You forgot to copy over boot.rb from vendor/rails/ – scroll up. If you’re getting an error that redcloth is missing (no such file to load—RedCloth-3.0.4/lib/redcloth), even though it’s in vendor/, it’s because the path to RedCloth is relative in config/environment.rb. Change it from:

require '../vendor/RedCloth-3.0.4/lib/redcloth' unless Object.const_defined?(:RedCloth)

to

require File.join(File.dirname(__FILE__), '../vendor/RedCloth-3.0.4/lib/redcloth') unless Object.const_defined?(:RedCloth)

Running

After the bootstrap, you may either start the server (ruby script/server, thin, mongrel, etc), or go with mod_rails (Phusion Passanger). I recommend the latter – Passenger is amazing, and the error screen is pretty.

Just point your Apache2 vhost to Mephisto’s PUBLIC/ dir. Here’s an example:


   ServerAdmin mrEman@domain.com
   ServerName domain.com
   ServerAlias www.domain.com

   # DocumentRoot must be rails_app/public/
   DocumentRoot /home/kiwi/www/domain.com/public/public
   Railsenv production

   DirectoryIndex index.html index.htm index.php
   ErrorLog /home/blue/www/domain.com/log/error.log
   CustomLog /home/blue/www/domain.com/log/access.log combined

Restart Apache2, and you’re done. The site should work right away. If you get the following error:

No such file or directory - /tmp/mysql.sock

It’s because the socket file resides somewhere else on your (host’s) distro. Just find (man find, locate, etc) and add a symlink to it. Here’s an example (Debian):

ln -s /var/run/mysqld/mysqld.sock mysql.sock

If you’re getting an error that gems you know you have aren’t found, like:

no such file to load -- tzinfo (MissingSourceFile)

it is due to the fact that Gems are not located anywhere Ruby checks. You’ll have to explicity pass Ruby -rubygems or require ‘rubygems’ — what a nuisance. Open config/environment.rb and add the latter line:

# requires vendor-loaded redcloth
require 'rubygems'

This will be global. Now either restart the server you ran (i.e., thin), or tell mod_rails to restart the app. To do so, just create a file named “restart.txt” in the tmp/ folder of the RAILS app:

cd mephisto_root/
touch tmp/restart.txt

and refresh the page. Passenger will restart the app and restart.txt will vanish.

The default login for the /admin page is admin/test. Wasn’t that a blast?

Sharing Files Locally Without a Crossover Cable on OS X

Mac OS X is capable of intelligently detecting whether a cat5 cable is connected to a network device or to another PC. When connected to another PC, it will (digitally) flip the pins to “emulate” a cat5 crossover cable.

Here’s an example on how to share files between a Macbook and another box (XP, Linux etc). All you need is a standard CAT-5 cable.

First, connect the Macbook directly to the machine running XP using the cat5 cable.

Now on the mac, go to System Preferences -> Network, and manually (no dhcp) set the following:
IP address: 192.168.1.1
Gateway: 255.255.255.0
Router: 192.168.1.1

Please note that these settings don’t need to be different if have a router running on that, or a similar IP. I.e., if your Belkin router is at 192.168.2.1, it doesn’t mean you should substitute that for the above settings. Just use the settings provided here as-is before experimenting, or you might run into problems.

Now on the other box (XP, Linux, whatever), set the following manually:
IP address: 192.168.1.2
Gateway: 255.255.255.0
Router: 192.168.1.1

The only difference is the last segment of the IP address. You can make this anything between 2-255.

You’re done. Make sure some files are being shared, and then browse the local network on either box.

Fetching Lots of Small Files from RapidShare? Tip to Save Time

I was staring at the 30+ RapidShare tabs I have open, annoyed that I had to keep waiting for the countdown timer before starting each download. The problem was that I kept forgetting about the countdown and the downloads altogether (30 second timer + Geek-ADD… impossible). It literally took me 10+ hours to get one file just because the session kept expiring.

Some Greasemonkey scripts helped a bit, but I don’t like keeping Greasemonkey enabled just for 1-2 tiny scripts that aren’t that useful anyway, nor restarting Firefox (which I’d need to do to re-enable it). I also don’t really need a solution that’s 100% automatic because I’m usually on the PC when I’m downloading these files, so a little manual work isn’t a problem. A premium account would be fine, but I don’t trust RapidShare with my payment information. I don’t know what other information they store (I emailed them, see reply below) . It’s like giving BTJunkie (good people) your name and address before you’re authorized to download torrents. It’s 100% safe, but just makes me feel uneasy. Even though my downloads are public domain. Warez is BAD NEWS, like Weed or premarital sex.

So I just kept refreshing the site and viewing the source hoping that something useful would magically appear, sort of like when I’m hungry and keep opening the fridge, even though I know there’s nothing interesting in it because I checked it a few minutes earlier.

A lot of older scripts and hacks don’t work because RapidShare now (actually it has been a few years) does most of its auth stuff server-side instead of using Javascript. The following tip is useful in some cases. It isn’t a “hack,” and wouldn’t work when downloading big (10MB+) files. It works great for me because I use RapidShare to download ebooks, scripts, and other not-so-big files (usually 1-10 megs each).

RapidShare displays a countdown timer with a duration that depends on the size of the file. Files about 500KB or less have no countdown, while files up to ~30-40 megs have a 30 second countdown. Bigger files have a 50-60 second countdown. I’m not sure of the exact numbers, but you get the idea. After the countdown is done, the page reloads with a unique URL to download the file. This URL expires after some time, but …

Countdown Can Be Started on Multiple Files Simultaneously

When the countdown is active on a file, you can click “Free user” on other RS links you have open, and the link to download each of the other files (the big DOWNLOAD icon) remains active for awhile. If you can finish any downloads before this time expires, you can begin the other downloads using this link, without having to go through the countdown again.

So this basically saves having to wait the 30 seconds. That’s it. You can’t download more than one file simultaneously when you aren’t registered, but by having all the download links ready to go, you can begin each download as soon as the prior download has finished.

I’m not sure when the download link expires, but the time seems to have increased to at least a few minutes. Unfortunately, download speed is capped at around 70-80 KB/s on free accounts, but in my experience this still works great (I DL at the max speed).

Note, clicking “download” when another file isn’t complete will give you a warning that your IP is already downloading another file, and you must now refresh – meaning you must wait for the countdown again.

Usual Scenario

Pamela has 9 tabs open - Normally, she would have to click “Free user,” wait for the countdown timer, and then DL… and when done, click the next tab and repeat the process.

But now, she can get some of that work (waiting) out of the way – She clicks “Free user” on the first file. 30.. 29.. 28.., … while she waits for that to reach zero, she goes through every other tab, hitting “Free user.”

Now ALL her RS tabs’ countdown timers are going down, and when finished, they will each redirect to the page featuring the download button. After the first download is done – Pamela just goes to the next tab and clicks “Download” and the next download instantly starts. No waiting.

And so on. Again, this wouldn’t work with big files (or anything on a slow connection) because by the time you have finished downloading one item, the other RapidShare download sessions will have expired.

You can squeeze more time out of the session by waiting till the first countdown is almost done before activating the rest. This can give you a 20-25 second headstart. If the session(s) do expire, you can just repeat the process, preferably starting with smaller files first. Also, this might differ depending on time of the day, as RapidShare’s limits are changing throughout the day. I.e., rush hour, happy hour, etc.

I don’t use RapidShare.de, just .com. If you’re tried this on .de, be sure to report your results.

Bypassing spaceball.gif When Savings Images From Flickr

There are plenty of ways to save pictures you find on Flickr. One way of doing so (in Firefox) is right-clicking the browser page and heading to View Page Info -> Media. This is too much work.

Flickr layers a transparent file named spaceball.gif – a 43 byte 1×1 px file – over some images, rendering the traditional right-click -> save as…, or dragging the image to the address bar methods useless. This simple technique probably fools most people, but you can simply bypass this by right clicking the bottom edge (1-2 pixels in height) of an image and saving as usual. You can also drag the image from the last row of pixels and drop it where ever you like.

Practice: http://flickr.com/photos/ancientwisdom/2195884158/