Shell

Shell History

The more things change, the more they stay the same.

$ history 1000 | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head
64 git
59 ./bin/rake
56 ls
53 vim
44 cd
30 gst
20 gp
17 cat
16 rake
13 glog
Development

Masking Credit Card Numbers with MySQL

So you need to export a list of credit card numbers and send it off someone, but don’t want all the digits shown. Sometimes it’s for post-processing, QA, or to solve a client dispute with an order. Whatever the case may be, here’s how to mask numbers in MySQL:

Masks everything but the first and last 4 digits:

SELECT
  CONCAT(
    SUBSTRING(c.card_number, 1, 4),
    REPEAT('X', CHAR_LENGTH(c.card_number) - 8),
    SUBSTRING(c.card_number, -4)
  ) AS masked_card
FROM
  table_name;

Or if you want just the last 4 digits and everything else masked:

SELECT
  CONCAT(
    REPEAT('X', CHAR_LENGTH(c.card_number) - 4),
    SUBSTRING(c.card_number, -4)
  ) AS masked_card
FROM
  table_name;

Replace table_name as appropriate. To find out more on these functions I’ve used, check the mysql docs on String Functions

Productivity

Using Keyboard Shortcuts to Mute Skype Calls on OSX

I’ve been a Skype user for over 5 years now. The service and call quality have always been great for single and conference style calls. One thing I’ve noticed about myself though is that I breathe into the headset at odd times, making everyone else feel like there’s serial killer or an angry giant on the other end. Skype solves these uncomfortable sounds for everyone else with the mute button. The downside is that there’s no shortcut for this. To mute you have to use the mouse, which is slower for me and louder when I click. My keyboard on the other hand is quick and really quiet.

Enter keyboard shortcuts. From System Preference pane, there’s a keyboard shortcuts panel you can add application shortcuts for any menu item. The only thing you need is the name of the menu item. In my case the menu item is Mute and UnMute, Skype just changes the menu item’s name depending on the state of the audio for the call.

System Shortcuts

Once you add the shortcut in, it’ll show up in the menubar.

Skype call bar

So now you can continue breathing loud, stuffing your mouth, continue listening to CNN, or whatever it is that might annoy people on the other end of the line.

Development

Agile Carolinas Andy Hunt Presentation

When I first moved out to Charlotte, I didn’t have much experience working in a corporate environment, and I went along with many of bad practices the company had. Around the same time I picked up The Pragmatic Programmer by Andy Hunt and tried to use the tips in the book. Sometimes I used the tips at the wrong time or misinterpreted principles, but for the most part it helped bring out many of the social and communicative aspects of being a programmer that I wasn’t very good at. Being able to detect a bad situation before things turn ugly can be a lifesaver. It also helped with preventing me for constantly working 50+ hrs a week and not benefitting from it.

Ruby Development

MySQL bindings with Ruby 1.9

I’ve started messing around with Rails 2.3.1 (aka RC2) and seeing how it works with Ruby 1.9. Aside from having to install all my gems for the new version of Ruby, the mysql bindings needed to be installed too. Here’s how I got it working:

Note: I’m using macports installations of ruby 1.9 and mysql

# Grab mysql-ruby

wget http://rubyforge.org/frs/download.php/51087/mysql-ruby-2.8.1.tar.gz

# Setup to use your mysql configuration files

ruby1.9 extconf.rb \
  --with-mysql-include=/opt/local/include/mysql5/mysql/ \
  --with-mysql-lib=/opt/local/lib/mysql5/mysql/ \
  --with-mysql-config=/opt/local/bin/mysql_config5

sudo make

# Run tests to make sure everything passes
ruby1.9 ./test.rb -- localhost

# And to finish it out
sudo make install
Shell

Shell History

I’ve been trying out Git lately. Can you tell?

$ history 1000 | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head
55 git
44 cd
42 ls
39 rake
35 ruby
34 sudo
26 ri
21 port
16 rm
13 irb
Development Ruby

First EnvyCasts Video is available

This week the railsenvy guys released their very first screencast. They’ve got weekly podcast, delivering news on the ruby/rails community. It’s pretty good. If you like banter and sound clips, you’ll enjoy it.

Their first screencast is titled Advanced Active Record, covering the following:

  • Loading large data sets
  • Using indexes
  • Caching
  • Named Scope
  • STI & Polymorphic Associations
  • Dirty Objects
Music

Cymbal Rush

Radiohead recently played at a pair of shows in France. On the second night, Thom played something off of The Eraser. Very nice to see it get played. Here it is:

Work Speeds

So internet is fully working at the office. I’d say that it is a little faster than before.

Caronet

SpeedTest

I stumbled upon speedtest today. Slick interface, even if all it does it test your bandwidth.

Here’s what I get at work:

Work

I’ll post home speeds later.

Playlists

New Music

Here’s a couple of CDs that I’ve been listening to this month.

  • Smashing Pumpkins - Zeitgeist
  • Interpol - Our Love to Admire
  • Tegan & Sara - The Con

Grab em from your local tracker.

Apps

iTerm

A must have app for shell fans. The default terminal for OS X is decent, but lacks tabs, bookmarks, and multiple profiles. iTerm includes all these missing features. I’ve been running iTerm since version .71 and finally upgraded to .95 today. It looks like a few bugs I’ve been waiting for to be fixed, i.e. better wrapping, have been. Checks it out.

Music

Radiohead Snippets

A new clip of audio has been posted on DeadAirSpace. Sounds like Down is the New Up, All I Need, Arpeggi, and Open Pick, and Bangers & Mash are making it to the new album.

Electronics

My Word!

SonyEricsson announced some new cell phones today. I can’t wait for the K850i to come to the States. Includes a 5 megapixel cam, NetFront browser, and tri-band HSDPA, and quadband GSM plus EDGE.

Playlists

Mas Geetar

So perhaps something with more guitar; one not so much

  • Rise Against - Prayer of the Refugee
  • 10 Years - Through The Iris
  • Radiohead - Open Pick
  • Sugarcult - Los Angeles
  • At The Drive In - Napoleon Solo
  • Chevelle - Well Enough Alone
  • Nine Inch Nails - Me, I’m Not
Playlists

Cover Songs

They’re usually not as good as the original, but I like these ones.

  • Jimi Hendrix - All Along the Watchtower
  • Social Distortion - Ring of Fire
  • Chevelle - It’s No Good
  • Nirvana - Where Did You Sleep Last Night
  • Sonic Youth - Superstar
  • Jeff Buckley - Hallelujah
  • Midtown - Suzanne
  • Tegan & Sara - Dancing in the Dark
  • Cat Power - How Can I Tell You
  • The Postal Service - Against All Odds
  • Rufus Wainright - Across the Universe

A nice, divisible number. 11.

Update: KCRW has their own album of rare covers out as well

PHP

Old is the new

So they’ve released PHP 4.4.6. Why? Do that many people still use 4? I suppose the only case where this would happen would be with IT people trying to steer away from the witchcraft that is OO and believe maintenance upgrades somehow supercede future additions to the language. (Comic book guy voice) Please to explain.

And if you’re going to tell me 4 does have OO support, it blows.

Playlists

Funky.

  • Yeah Yeah Yeahs - Turn Into
  • Caleb Caudle - Uncle Benny
  • Thom Yorke - And it Rained All Night
  • Madvillain - All Caps
  • J Dilla - History
  • Madlib - Two Timer
Music

Avant Garde

I’ve always had a thing for music tracks backing cartoons. It probably started sometime when I went to Disneyland when I was little. I visited an easily forgotten shop going down Main street. Inside and around the maroon velvet curtain played old disney clips. My guess would be they were from the depression era. I was too young to know the word nostalgia, even now I wouldn’t use it to describe the feeling my ears were hearing, but there was something distinctive about the music being played in the background. Everything from Mickey whisteling, the patting of the horse’s hooves, to clicking of the projector seemed to work into the music perfectly.

Playlists

Winter Snow Music

It snowed in Charlotte this week. Pics up on flick r. Music Be l o w.

  • Ratatat - Nostrand
  • The Shins - Phantom Limb
  • Silversun Pickups - Lazy Eye
  • Incubus - Dig
  • Death Cab for Cutie - Blacking Out the Friction
  • Bloc Party - I Still Remember
  • Rilo Kiley - The Absence of God
  • Massive Attack - Protection
Apps

WriteRoom

Green text. Black background. Blink. Blink.

There’s nothing scarier than the blank page when writing. The fear of staring at an empty canvas without a shred of intuition as where or how to begin. I used to write on a daily basis about anything. Places I went, random thoughts throughout the day. Somehow I’ve become the couch potato of thought expression.

Lying sideways on the bed, I decide to write. Words being to form. Gotta get the sleepies out first. Stretch that creative muscle. A comma here, a clever word there. Combine two unrelated sentences into a single one. Oh yes, that’ll do. Blocks of green start to fill the once blank screen. Confidence ensues. I like cake.

But then you become tired and lose focus. Magic words no longer run through your fingertips. You read over what you’ve put down so far.

Cake? Rubbish. Delete.

Well that got us nowhere.

Although I don’t have much to say, I did start reading Rosenberg’s Dreaming in Code and must say it’s a pretty good so far. It’s not a technical book like something from O’Reilly or Apress, rather a look at a start-up from a nontechnical person’s point of view. From what I’ve read so far, me likie. I’ve never read a book that’s so eloquently woven a company and the process of programming together. I’m jealous.

Screenshots

Best Site 3vAr!!

So I was reading through a couple of articles on Raganwald’s blog, stumbling from link to link like I usually do, then something happened. Somehow I came across Java Developer’s Journal. I took a snap of the site and thought I’d post it here for all readers (mainly me) to see.

This site is just horrible. Adverts are everywhere. There’s even video advertisements playing right off the bat. They’re just as bad as those punch the monkey flash ads. There would be no way you could actually read an article from this magazine online. It’s like this gigantic disorganized mess of intarweb templated by a marketing monkey.

Thought I’d say more? Yeah, me too. I need to get back into this writing thing.

Music Playlists

Playlist

They gave me an iTunes card at work. Here’s what I brought.

Fall '06 Playlist

Strange, but I noticed after taking the screenshot that I’ve actually downloaded 81 (free/purchased) songs from the iTMS.

Research

Text Mining

I came across a topic modeling article on del.icio.us with some neat research the ICS department at UCI is doing. It makes me miss doing research.

Alho?

Reading, studying, working, and more. We’re alive, oh yes we are.

Projects

Movie Collector Demo

A demo is now available

Movies are getting expensive to watch in the theater. The last family trip set me back more than 50 bucks, not including soda and popcorn. So to counteract the high price we started buying DVDs. It’s significantly cheaper than going to the theater. For around $15 you can watch the same movie on your couch without breaking the back and have as many people that you’ve got floor space for. Now we buy about 1 DVD every other week.

Back when I lived close to relatives in San Diego, we borrowed DVDs from one another. Only trouble was that we never borrowed any and everyone else would borrow ours. Not a problem at first, but after a while the movies would forget to make their way back home. To help them find their way back, in my spare time I’ve came up with Movie Collector. It’s a small web app that’ll help you catalog your movie collection and let you know whom the movie is currently with. You can check out a longer description.