Recent blog entries for robhudson

MySQL tips

I've been studying recently for the MySQL certification test and have discovered a few tricks along the way. One of my favorites is the combination of using pager and vertical output.

To set your pager to use less:

mysql> pager less
PAGER set to less

Now when you perform a select which returns more rows than rows on your screen, the pager will allow you to paginate through the results.

To get MySQL to display results vertically instead of in columns horizontally, end your SQL with "\G" instead of with the semicolon (or "\g")...

mysql> SELECT * FROM mails WHERE LENGTH(txt) < 300 lIMIT 300,1\G
*************************** 1. row ***************************
  msg_nro: 3068
     date: 2000-03-01 23:29:50
time_zone: +0200
mail_from: Monty
    reply: monty@no.spam.com
  mail_to: "Thimble Smith" <tim@no.spam.com>
      sbj: UTF-8
      txt: >>>>> "Thimble" == Thimble Smith writes:

Thimble> Hi. I think this is a good idea. Is anyone familiar with UTF-8 Thimble> or Unicode? Otherwise, I'll put this on my TODO list and see what Thimble> happens.

Yes, please do that.

Regards, Monty file: inbox-jani-1 hash: 190402944 1 row in set (0.09 sec)

Hacking Unwanted Marketing

I just read a little article on things to do to annoy telemarketers and junk mail senders. Some were pretty funny and creative so I thought I'd share:

  • Return ads with bills: When a company sends you ads along with your monthly bill, send those same ads back with your check. Let them throw away their own junk.
  • Return unwanted applications: When a credit card company (or other company) sends you those "pre-approved" applications, they often include a return envelope with free postage. Those envelopes only cost them if they are used. So rip the application in half, and send it back to them, costing them money. While you're at it, why not include some extra junk mail and push the weight over an ounce to cost them more!
  • Hold, please... When a telemarketer calls and asks for person X, ask them to hold on. Don't hang up and set the phone down and walk away. When the phone makes those annoying beeps, you know the telemarketer has hung up and you probably wasted a good minute of their time.
VNC

I've got a Linux workstation as my primary box at work, and a Windows computer on my left side. So, I've got two keyboards and two mice and two monitors. I was looking for a way to switchbox my keyboard and mouse. Ended up finding x2vnc.

Now, I move my mouse to whatever edge I designate, and it starts sending my mouse and keyboard output to my windows computer (with a listening VNC session). Very slick and very useful.

QT & C++ Programming

I've been really wanting to learn C++/QT Programming and finally got around to playing with it. A few months ago, I wrote one console based program which was a conversion of a perl script from a friend that analyzed the folding@home output and gave statistics on the work unit times. I successfully converted it and got a refresher course in C++ at the same time.

Recently, I started playing with QT-designer, a GUI based GUI builder (RAD tool?). My first attempt took 2 numbers and added them together and spit out the result.

My 2nd attempt was much more interesting as seen by this screen shot. It is a batch sparge or no sparge homebrewing calculator. I found a spreadsheet that had the calculations layed out and just GUIfied it. It was a fun exercise and should actually be useful. There is some stuff I need to clean up (like having the program not segfault when you want t close it) but other than that it works well. Maybe I'll keep going and make a suite of homebrewing calcs. <g>

Unix-based Wireless Access Point
    I'm doing research this morning into how to set one of these things up. I just ordered 2 prism based wireless PCMCIA cards for about 30 USD each. I've got an ISA to PCMCIA adaptor. So I'm building my own WAP soon. I've got an old 486 I'm thinking of using and will probably go for FreeBSD as the OS, as I think the prism2 support there is a little better. This should be a fun little project and hopefully not too frustrating. Found lots of docs this morning on these, so it looks like I'm in good hands.

Note to self:

    in Perl: (.*?)
    in Vim:  \(.\{-}\)

Finishing up The Fellowship of the Ring and ordered Secrets and Lies: Digital Security in a Networked World by Bruce Schneier. Applied Cryptography would have been way over my head, and I enjoy reading about cryptography so I thought this would be a good holiday reader. Last year I read The Code Book by Simon Singh (after Cryptonomicon) about the same time of year. That was a fun book too.

Been playing with Tastybrew.com lately. I've finally got most of a working site for homebrewers. I recently added a diary entry similar to here. We'll see if homebrewers will use it as much as programmers. If they're any homebrewers here, check it out. Feedback is always welcome. :)

Wrote linux.com a while ago after finding this quote on their site (here):

    Code powering the Linux.com site is available under the GNU Public License. Please email dev at linux.com for more information.
I'll have to try again as I never got a response. It would be cool to see some of the tricks they use there, since I'm mostly coding websites in PHP and MySQL these days.

Grabbed Galeon 0.12.3 a bit ago after hearing lots of good things about it. I compiled it and ran with it about a day before 1.0 came out. It's pretty rock solid and blazingly fast.

Mulad: About the web/database interface to mp3s. Take a look at Andromeda. I haven't used it but did play with it a bit. It's an all in one php file (including the images, which are inlined arrays). Pretty cool stuff, and it looks really sharp with themes. I'd be interested in how it goes b/c I'm thinking of doing the same thing on my network.
Bad Joke

A friend and I were talking about compilers and such and I came up with this bad joke. I still tell it to people, though...

Q: What did the compiler say when it ran out of stack space?
A: I haven't got a char in the world.

Open Source in the classroom

sej I would love to see a class like you mentioned. I've recently had privy to see a closed-source package that is being sold commercially that was originally written by a newly graduated CS student. That software (C++) is horrible and uses things like a custom built string class, a home grown binary database library, etc. Some of the elements are probably pieces of code he had to write for a class, no doubt. While I don't question his skills as a programmer, I do think that using the string class that comes with C++ would have been a much better choice.

I'm sure if students had to take a class like this, they would 1) no more about the open source world and what's out there, and 2) understand that code re-use can save lots of time and headaches. I wish that curriculum was around when I was taking classes!

22 older entries...

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!