A A

Archive | Code

Bulk Upload Images as Simple Products in Magento

Friday, September 14, 2012

0 Comments

The client has thousands of images, each of which is a (simple) product they want in Magento. Each image is named the associated product’s SKU number with a JPG extension. I began by using a recorded Batch script in Photoshop to resize all the images to reduce filesize and make the image more web-friendly. The [...]

Add Items to Category Programmatically in Magento

Wednesday, September 12, 2012

0 Comments

The code on the bottom will take the following array: The $lineItems array contains a line of category+sku-items in the format “CategoryNick SKU1 SKU2 SKU3.” CategoryNick is matched against the $categories array above to figure out the Magento category ID. If the product is already in the category, it doesn’t do anything. The product will [...]

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

Tuesday, August 21, 2012

0 Comments

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 [...]

Calculate Your GPA Using this Bash Script

Thursday, May 21, 2009

0 Comments

This Bash script is used to calculate your Grade Point Average (GPA) on the command line. Usage might not be intuitive. Please see the usage function or just run the script without passing it any arguments. The gval function should be edited to reflect your own region or university. It has been written and tested [...]

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

Friday, May 1, 2009

11 Comments

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 [...]

How to Maintain Static Sites with Git & Jekyll

Tuesday, March 31, 2009

4 Comments

Static sites in this context just means non-database driven sites. Your static site can be an elaborate PHP script or just a few markup and image files. For this I am using Jekyll – A neat Ruby gem that makes your static sites dynamic. It lets you create layouts and embed custom variables in your [...]

Scraping Google Trends with Mechanize and Hpricot

Saturday, January 24, 2009

3 Comments

This is a small Ruby script that fetches the 100 trends of the day for a specific date. If multiple dates are searched, one can find out how many times a keyword occurred between two dates, or just find out what keywords are constantly appearing on the top 100 list. The script is incomplete and [...]

AnimeCrazy Scraper Example Using Hpricot & Mechanize

Sunday, January 11, 2009

2 Comments

This is a little (as of now incomplete) scraper I wrote to grab all the anime video code off of AnimeCrazy (dot) net. This site doesn’t host any videos on its own server, but just embeds ones that have been uploaded to other sites (Megavideo, YouTube, Vimeo, etc). I don’t know who the original uploaders [...]

Quick BASH Script to Dump & Compress a MySQL Database

Saturday, December 27, 2008

2 Comments

A quick script I whipped up to dump my MySQL database. Usage: sh backthatsqlup.sh (be warned that it dumps ALL databases. This can get huge uncompressed) download BackThatSqlUp.sh

Refactoring Tip: Eliminating Model.find(params[:id]) Duplication

Sunday, December 7, 2008

0 Comments

In a controller, you’ll commonly have a method that requires you have an instance variable containing the object you’re working with. An example would be the show, edit, update, and destroy methods (REST). To eliminate having find(params[:id]) in multiple methods, you can use before_filter, like this: class Admin::PostsController < Admin::ApplicationController before_filter :find_post, :only => [:show, [...]