Category: How-To

  • Apps That Seem to Crash WoW on OS X 10.5.5

    I wrote this quick script to take care of apps that seem to Crash OS X 10.5.5 on my Macbook Pro. I have just 1GiB of RAM instead of the recommended 2GiB, but ever since killing the processes in the script below, I haven’t had a crash.

    The bad guys are:

    • Google Updater
    • Cross Over
    • HPEventHandler
    • HP IO Classic Proxy
    • HP IO Classic Proxy 2

    I killed privoxy in my script below just to get more memory to run Warcraft.

    #!/bin/bash

    C1=`ps ax | grep Cross | grep -v grep | cut -c3-6`
    echo “C1: $C1”
    kill -9 $C1
    C1=`ps ax | grep “Google Updater” | grep -v grep | cut -c3-6`
    echo “C1: $C1”
    kill -9 $C1
    C1=`ps ax | grep “HPEventHandler” | grep -v grep | cut -c3-6`
    echo “C1: $C1”
    kill -9 $C1
    C1=`ps ax | grep “HP IO Classic Proxy 2” | grep -v grep | cut -c3-6`
    echo “C1: $C1”
    kill -9 $C1
    C1=`ps ax | grep “HP IO Classic Proxy \-” | grep -v grep | cut -c3-6`
    echo “C1: $C1”
    kill -9 $C1
    C1=`ps ax | grep “privoxy” | grep -v grep | cut -c3-6`
    echo “C1: $C1”
    kill -9 $C1

  • Redboxing with Rails: Modal Windows FTW

    There’s a great lightbox plugin for Ruby on Rails called Redbox. Unfortunately, it doesn’t work out of the box, but here’s the patch for redbox.js:

    Replace:

    Element.setTop(window_id, boxTop);
    Element.setLeft(window_id, boxLeft);

    With:

    $(window_id).style.top = boxTop + “px”;
    $(window_id).style.left = boxLeft + “px”;

    Remove or comment out:

    Element.hide(‘RB_loading’);

    Remove:

    <div id=”RB_loading”></div>
  • A Quick Guide to Noobwatcher

    curl -O http://svn.collab.net/repos/svn/trunk/tools/client-side/showchange.pl
    mv showchange.pl $HOME/bin
    svn co http://codebelay.com/noobwatcher
    mkdir watched_repositories
    cd watches_repositories
    cp $HOME/noobwatcher/trunk/noobwatcher.rb .
    svn co

    Create and edit a settings.yml file. Mine looksl like this:

    path: /Users/barce/nooblive/trunk
    repo: http://www.example.com/the_repo_I_am_watching
    diffs: /Users/barce/nooblive/diffs
    twitter_email: the_twitter_email_that_notifies_you@example.com
    twitter_password: the_password_to_the_twitter_email_that_notifies_you
    twitter_recipient: your_twitter_account
    sleepseconds: 60

    Start noobwatcher:

    ./noobwatcher.rb
  • Remove ^M characters and more with repl.bash

    Hey folks, this is a goody but quicky.

    First off, respect the character encoding of a file. I don’t know how many devs out there violate this rule, but if you’re like me and Joel On Software, you’ll agree that you should respect the character encoding of a file.

    If you happen to see that your file has gotten code page 1252 aka Windows-Latin 1 in it, then you’ll have a variety of random characters like ^M or ?~@~Y or ?~@~\ or ?~@~] .

    Well, I wrote a script that removes these guys and makes sure that the file format of Unix is respected. Here it is:

    #!/bin/bash
    #
    # By: barce[a t]codebelay.com
    # ——————-
    # this script replaces microsoft special chars with plain ol’ ascii
    #
    # usage: ./repl.bash filename
    #

    # replace ^M characters
    perl -pi -e ‘s/\x{0D}\x{0A}/\x{0A}/g’ $1

    # replace garbage with single-quotes
    # ?~@~Y
    perl -pi -e ‘s/\x{E2}\x{80}\x{99}/\x{27}/g’ $1
    perl -pi -e ‘s/\x{80}\x{99}/\x{27}/g’ $1
    perl -pi -e ‘s/\x{80}\x{9c}/\x{27}/g’ $1
    perl -pi -e ‘s/\x{80}\x{9d}/\x{27}/g’ $1

    # replace garbage with asterisk
    # ?~@?
    # e280 a2
    perl -pi -e ‘s/\x{E2}\x{80}\x{A2}/\x{2A}/g’ $1

    # replace garbage quotes with plain quotes
    # start: ?~@~\
    # close: ?~@~]
    # e2 809c
    perl -pi -e ‘s/\x{E2}\x{80}\x{9C}/\x{22}/g’ $1
    perl -pi -e ‘s/\x{E2}\x{80}\x{9D}/\x{22}/g’ $1

    # replace garbage hyphens with plain hyphens
    perl -pi -e ‘s/\x{E2}\x{80}\x{93}/\x{2D}/g’ $1

    # replace garbage with ellipsis
    perl -pi -e ‘s/\x{E2}\x{80}\x{A6}/\x{2E}\x{2E}\x{2E}/g’ $1

  • Getting Around the Politics of Subversion with git

    This is the nightmare scenario. You are working with a coder who overwrites your changes in subversion. You’ve told this coder once, twice, three times, “Hey, please don’t do that. Hey, let’s talk about your changes before you commit them.”

    But this coder for some reason thinks that he or she is the gift of the gods when it comes to coding, and continues to overwrite your changes.

    This is where git comes in. If I had learned about this feature of git and the idea of accepting or rejecting changes in git sooner, I would have avoided the whole nightmare of re-comitting code and lengthy merge debates.

    Most projects you work won’t involve the worst case above. Most of the time, there will be a great developing rule that says never commit bugs into subversion. But whenever you have to re-factor code and commit each line, branching and then later merging can be an issue in subversion, and it’s slow too.

    On a project that I’m working on now the client wants only good code in svn which is great, and so I’m using git with svn. I got this idea thanks to Jakob Heuser. Thanks, Jakob!!!!

    This is where git comes in. Here’s a quick cheat sheet and it assumes you are using GitHub:

    mkdir newlispoauth
    cd newlispoauth/
    git init
    touch README
    git add README
    git commit -m ‘first commit’
    git remote add origin git@github.com:barce/newlispoauth.git
    git push origin master

    Now we have to pull in changes from subversion:

    mate .git/config

    In the config file add something that looks like this:

    [svn-remote “newlispoauth/trunk”]
      url = http://codebelay.com/newlispoauth/trunk
      fetch = :refs/remotes/newlispoauth/trunk

    Now we’re gonna fetch the subversion repo:

    git-svn fetch newlispoauth/trunk
    git checkout -b local-svn/trunk newlispoauth/trunk
    git svn rebase
    git checkout master
    git merge local-svn/trunk
    git mergetool # if there are conflicts with the README file above
    git add README # if you had to make changes with the mergetool
    git commit
    git push origin master

    Now you are working with “master” and “local-svn/trunk”.

    “master” is for your changes to share with your team on git-hub
    “local-svn/trunk” is for you and where you push changes to subversion.

    You basically pull in changes from newlispoauth/trunk and do your work in local-svn/trunk.

    Let’s put the changes in master into “newlispoauth/trunk” and commit those changes to subversion:

    git checkout local-svn/trunk # you did commit your changes in origin right?
    git merge master
    git-svn dcommit
  • Sending Files with hping3

    This is a quick cheat sheet on how to use hping3 to send a text file. Thanks Gr@ve Rose for inspiring this.

    The target machine should be listening like so:

    hping3 192.168.0.108 –listen signature –safe –icmp

    The source machine should be set up like so:
    hping3 192.168.0.108 –listen signature –safe –icmp
    hping3 192.168.0.108 –icmp -d 100 -c 2 –sign signature –file ./test.txt

    -d specifies the data size
    -c specifies the number of pings to send. We just need 2 pings to send the test file below.

    test.txt just contains lolspeak:
    —- start —-
    oh hai
    we bustin pass dey bad fire wall
    yay!
    —- end —-

    I haven’t tested this out with binary files, but I’m pretty optimistic that a uuencoded file would get through, and could be re-assembled at the target server. Also, hping3 can be used to turn on a network service like sshd if it receives the correct “signature”.

  • Find Jobs Using RSS Feeds from Job Boards

    Tip #1: Do not take a break from your job hunt until you’ve found a job, and this means weekends.

    Some folks try to game the job hunt. These folks tell themselves, “If I apply on Saturday, I look desperate, but Sunday evening looks much better.” I say bullshit.

    As a creature with a hunter-gatherer past, you should be looking for work now, and you should have fun looking for it.

    Think of it this way. If you take today off, somebody else gets to be the first cover letter from Saturday in someone’s inbox.

    Tip #2: Scour the web for Job Boards (e.g. craigslist) and subscribe to as many RSS feeds as you can. Have the RSS feeds go to your mobile if you have to.

    I basically took all the RSS feeds from the Job Boards that I love like Authentic Jobs and put them into my RSS reader. My top priority is to read each feed and then if I get too much info, filter out the feeds or posts I don’t need using Thunderbird.

    Wish me luck!

  • Beware the Recruiter Bait and Switch: Get References!

    There’s a slimy bait and switch tactic that’s been pretty common this year, and it’s the recruiter bait and switch. They send you a letter that looks like this:

    Dear Victim,
    
    Nice to find you on linkedin. I'm contacting you as your work experience looks
    like a good fit for roles at AwesomeCompany.com .
    
    Cheers, Slimy Recruiter
    

    Then they tell you that the job that they were originally trying to fill is gone, but they have other jobs available at SlaveLabor.com.

    The sad thing is that if you dig around, you find out that these recruiters never had a relationship with AwesomeCompany.com and are really just working for SlaveLabor.com .

    Takeaway: Get references from your recruiter of people that have placed.

  • 3 Ways to Green Your Office

    These 3 steps can easily green your office:

    1) Restrict your paper usage. Ya, I still use notebook paper, but I didn’t use the printer to print out a single sheet of paper in September. September should be “No Printing Month”. 😀

    2) Buy carbon credits. Your servers, laptops, electronic gadgets, cars or buses carbon emissions can be offset through carbon credits. A site like myclimate might spend the money on algae in the sea for more oxygen.

    3) Go Solar! With the Solio Charger for your iPhone, or solar backpacks from Voltaic Systems, you don’t ever have to plug into the grid again… as far as computing goes.

  • Saving Time on Subversion Merging: svn merge Manually

    I just ran a benchmark on merging files using Eclipse which then calls subversion and running subversion manually on a 28MB repository.

    The results are interesting.

    svn merge destination_url@HEAD source_url@HEAD destination_folder

    took exactly 7 minutes

    Using a subversion merge in eclipse on the same repo and revision took 10 minutes.

    Take away: use svn merge on the command-line.

    Ya, I’d love to go back to using git.