About andy

in west midlothian, born and raised... on the playground was where i spent most of my days... but yea, i'm a freak.

jQuery Listerine Plugin

I’ve been helping a friend with his site, www.thehardwareproject.org, for the past couple of months. It was a good chance to rework a lot of my php CMS and one thing I noticed was that there were a lot of pages where all I was doing was displaying information via a list of divs. Different pages might have the lists formatted differently, but rather than write page-specific backend code to format the lists, why not output all lists uniformly to the page and then have client-side code manage the display?

Listerine has 2 modes. One is “columns” which basically creates a user-set number of columns on the page and then evenly distributes the list items between columns. The other mode is “grid” which is more of a tile-like display.

simple columns example:

$('.manufacturer_list_container').listerine({
cols: 3,
transform: 'columns'
});

Download the code here.

making bossam (bo ssam)

This weekend, I finally got around to making bossam (bo ssam), the Korean version of boiled pork and cabbage, at home. Using the instructions I found on this great korean food blog, it didn’t come out half bad. Some adjustments I made to the recipe are not using an onion, using a Korean red pepper instead of a Serrano pepper, not using a vegetable boil bag, and using 2.5 lbs of skin-on pork belly (which caused me to have way too many leftovers). Here are some pics of the process.

cleaning the pork

cleaning the pork

giving the lettuce a salt bath

giving the lettuce a salt bath

dwenjang paste and coffee grounds in a pot.

dwenjang paste and coffee grounds in a pot.

boiling pork with coffee grounds.

boiling pork with coffee grounds.

everything in pot with new water.

everything in pot with new water.

boiling napa cabbage

boiling napa cabbage

time to enjoy the fruits of our labor!

time to enjoy the fruits of our labor!

 

Disable Script Debugging in Visual Web Developer 2010 Express

This little registry hack will disable javascript debugging in Visual Web Developer 2010 Express. You should really be using something like Chrome Dev Tools or Firebug when debugging javascript anyways.

reg add HKLM\SOFTWARE\Microsoft\VWDExpress\10.0\AD7Metrics\Engine\{F200A7E7-DEA5-11D0-B854-00A0244A1DE2} /v ProgramProvider /d {4FF9DEF4-8922-4D02-9379-3FFA64D1D639} /f

happy new years 2012

Happy new years! For this first post of the new year, I thought I’d take a look at last year’s resolutions and see how I fared.

  • Play MORE video games.  Try and beat them too since I have a nasty habit of just dropping them midway through.
  • Learn Python and Java.
  • Try and complete more of my programming side projects instead of leaving them half-done (this seems to be a recurring theme in my life).
  • Learn to drive stick.
  • Try and do some more grad school classes.  I had put them off to pay off some debt first, but I should really try and get this done.
  • Pay off debt.
  • Read more books.
  • Be less political.

I have managed to actually beat more of the video games I started playing this year rather than leaving them unfinished. Some exceptions include Castlevania and Oblivion. Now that SWTOR has come out, I’ll probably leave those unfinished for a while though. I’ve managed to learn a bit of python, as well as learned to use git to publish some of the stuff I’ve learned to the web. I didn’t get around to learning stick or take more grad school classes. Due to unforeseen circumstances, I wasn’t able to save up as much money as I would have liked this past year to pay off debt. I did manage to read a lot more books though and I think I’ve become a bit less political. All in all, not a bad run of resolutions.

For this next year, I’ll keep the resolutions simple.

  • Start working out more and possibly start a martial arts class.
  • Pay off debt.
  • Start working on a video game project.
  • Learn, learn, learn. Always try to continue the learning process.

jquery-querystring

Just published a plugin that extends jquery to give access to querystring params easily. For the longest time, I was just copy/pasting one function into all my projects to do this, but finally decided to make it a jquery plugin for future use. Here’s how to use it:

$.querystring(param_name_here);

example:

var q = $.querystring('q');

Ezmode. get the code here: https://github.com/gehsekky/jquery-querystring

Steve Jobs has died

apple logo

Steve Jobs has died at age 56. The internet has gone insane with everyone and their mother trying to eulogize Jobs. I even read an article where the author said he was “Moses in a turtleneck.” That’s just crazy, but whatever. While I didn’t agree with his business practices or philosophy, I acknowledge his role as a tech giant and someone who helped shape the industry we work in today. RIP. It will be interesting to see where Apple goes from here without Jobs at the helm.

ShibalBot – A Python IRC Bot using the Twisted library

I used to use eggdrops back in the day when we would idle in IRC channels for counterstrike and used to write custom TCL scripts to do all that annoying IRC bot stuff (like listing scrim availabilities, cs clan rosters, etc). So while I’m learning Python, I figured I’d try and write my own bot to see if I could do it. I first started off with this example that builds the core of the bot in less than 30 lines of code. While that was fantastic, I then came across this example which uses the Twisted lib and makes it much more robust. I didn’t implement the markov chains, but I wrote up some quick code that can handle saving and displaying IRC quotes. This version of the bot is now just under 180 lines.

You can view the code here.

To use it, you have to change this section at the bottom of the file.

if __name__ == "__main__":
    reactor.connectTCP("YOUR_IRC_SERVER_HOST",
                       IRC_SERVER_HOST_PORT,
                       ShibalBotFactory("YOUR_IRC_CHANNEL",
                                        "YOUR_IRCBOT_NICK",
                                        True, False))
    reactor.run()

Just change the parameters to your own IRC server address, server port, IRC channel, and bot nickname and you’re good to go. Some Todo’s include adding some code to fetch the titles of url’s pasted in the channel, making it modular so you can just drop in scripts instead of having to change the main file, and updating the quotes module to not load the entire quotes file at once (in case the file becomes huge).

Script to sync friends list across multiple reddit accounts

While teaching myself Python, I wanted to try and write something that I would actually use. Since I have multiple reddit accounts, a script that would sync settings across them seemed like it would be useful. So far, the only thing being synced is friends, but I’ll soon have something that also syncs subscribed subreddits as well (hopefully).

The script is being hosted on github and the link is here.

I developed the script using Python 2.7.2 so I don’t even know if it is compatible with Python 3.x. Using the script is fairly easy. Just edit the top of the file above the line that says “DO NOT MODIFY BELOW THIS LINE”.

Example:

login_info = [
["user1", "pass1"],
["user2", "pass2"],
["user3", "pass3"]
]

add_self_to_friends should be either "True" or "False"
(without quotations)

I think I’ll add in some logic to do interactive input if no settings are detected in the file. I’m also going to change the script to do dom parsing as opposed to regex because the regex could run into some weird issues (I know I’ve said dom parsing is a hassle before, but the goal here is to learn as much Python as possible so I’ll try attacking problems from all angles to learn everything).