Skip to content

A useful calendar in Conky

Since I got a new desktop a month or so ago, I’ve been running Ubuntu as my main operating system, and am using Conky for a nice heads-up-display. There are a lot of articles on the web about both Ubuntu and Conky, but one thing I couldn’t find a good, accurate how-to on was getting a calendar that highlighted the current date. While getting the calendar is easy using the cal command, actually getting the date highlighted is somewhat hard, and all of the articles I found suggested methods that broke in various situations. However, I managed to get it all worked out, and have a beautiful calendar that looks like this:

After the jump, I’ll give you the code and explain how it all works. Continue reading ›

Tagged , , , , , , , , , ,

iWork Autosave

So I had the wonderful experience this weekend of losing over 1,200 words of work on a paper because I forgot to save it regularly. I was really, really sad about that and really bummed that Pages, my word processor of choice (I love the formatting tools), doesn’t support either autosaving or document recovery. However, my preference for Pages is strong enough that I didn’t jump ship to an auto-saving editor. Instead I went out and found WorkSaver. WorkSaver
Worksaver simply sits in your menubar and, at a definable interval will save every iWork document you have open, provided that it’s already been saved once. This means that when I’m writing I don’t have to even worry about saving my document after creating it and choosing where to save it. Of course, it’s a shame that you have to manually save the file when you create it, but it’s a lot better than losing all your work. I can highly recommend WorkSaver if you use iWork simply for the peace of mind it provides. Of course, it’s not perfect for everybody, but when I’d rather focus on writing a paper than on making sure my computer doesn’t decide to make it all go away, WorkSaver is just what I need.

Tagged , , , , , , ,

Perl Snippets

I’ve been getting into a mood lately that makes me fiddle around with fun Perl stuff, but sadly school’s picking up to the point that writing anything up isn’t going to happen. However, I have a couple short scripts that I’m just dying to share.

Just Another Perl Hacker

I figured that it was about time in my hacking career (read: I was bored enough) that I should make a japh script. After a couple attempts I came up with this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/perl
while(<DATA>){
 	for (map{ord($_)-33}split ''){
		$__++;
		$_||(print(chr($__+19))&&($__=0));
	}
}
 
print "\n";
 
__END__
                   /|                        |\
      !            ; :                        : :
                  | Y,                      ,P |
     !             |  Yb.        __        ,dP  |
                  l\  YMMb,_ _,/  \,_ _,dMMP  /f
  !                 j;  `YMMP'  `--'  `YMMP'  ;j
                   : \   YP`-._    _.-'YP   / ;
  !            !      \ `\,  _,\_    _/,_  ,/' /
                     `,_,   \`o>  <o'/   ,_,!'
                         `\            /'
                           |  _    _  |
      !                     / 88b  d88 \
                           \ `8P  Y8' /``-.
             !               `\,    ,/      \
                             _`----'        \
                  !        _.'/ '          `, \
                        .'_,'_..._          \ ;
       !               .',/.dMMMMMMb. |      /  \
                    .'./.MMMMMMMMMMM ; !    /    ;
                   / /.MMMMMMMMMMMMM/     /     ;
                  | ;dMMMMMMMMMMM!P/'   ,/'   !    ;
                  |/dMMMMMMMMMP'     .'          |
   !               ;dMMMMMMMMM|     _/            |
                 ;dMMMMMMMMMMb_|_!| /;            ;\,
                 dMMMMMMMMMMMM`M`M`;.---..      '   `\,
                :M!MMMMMMMMMMMMMMMP/'     `\            \
               /|MMMMMMMMMMMMMMP/          \    _!_      `.
  !            / |MMMMMMMMMMMMMM|            |.-'  `-._    \         .'\
             ;!  ;MMMMMMMMMMMMMM|            :         `-._ `-.     /  _\
             |   ;!MMMMMMMMMMMMM;            |             `-. `-.._.'/
              \   `\YMMMMM!MMMP/'\           |                `~~----'
               `-._, ``YMMMP'_.-'\         ! ;_
                 |      /         `-.,_./     7
                _/    `\,    !        /      _/
             ,-' ,  ,   /         _.'      /
            (_(_(__(__.'       !,-'        /
                              (__(__(_(_/'

Download.

I’ll let you go ahead and figure it out on your own. It’s not super-hard, but it’s fun.

Mandelbrot

In another fit of boredom I decided that it was finally time to create a mandelbrot set renderer. I originally tried to make one of these in basic, long before I had the math to do so. I was proud that I got the real axis to render, and figured it was time to complexify it. To keep things simple I decided to make it render an ASCII-art version of the set that would fit in a terminal window. The output looks like this:

                        ...............................:::::oo@@@@o::::..........
                      ...............................::::::O@@@@@@@@o:::::.......
                     .............................::::::::oO@@@@@@@@o::::::::....
                   ...........................::::OOO8ooO@O88@@@@@@8@O8o::::Oo:..
                  .......................:::::::::o8@@@@@@@@@@@@@@@@@@@@OO@@@@::.
                 ...................:::::::::::::oOO@@@@@@@@@@@@@@@@@@@@@@@@@o:::
                ................:::::::::::::::o@@@@@@@@@@@@@@@@@@@@@@@@@@@@Oo:::
               ..............::::@oo::oOoo:::ooo@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@8o:
               ...........:::::::oO@@@O@@8@OooO8@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@O::
              ..........:::::::::oO@@@@@@@@@@88@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@::
              ........:::::::8ooO8@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@o::
              .:::::::::::::oO@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@o:::
              @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@Oo::::
              .:::::::::::::oO@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@o:::
              ........:::::::8ooO8@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@o::
              ..........:::::::::oO@@@@@@@@@@88@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@::
               ...........:::::::oO@@@O@@8@OooO8@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@O::
               ..............::::@oo::oOoo:::ooo@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@8o:
                ................:::::::::::::::o@@@@@@@@@@@@@@@@@@@@@@@@@@@@Oo:::
                 ...................:::::::::::::oOO@@@@@@@@@@@@@@@@@@@@@@@@@o:::
                  .......................:::::::::o8@@@@@@@@@@@@@@@@@@@@OO@@@@::.
                   ...........................::::OOO8ooO@O88@@@@@@8@O8o::::Oo:..
                     .............................::::::::oO@@@@@@@@o::::::::....
                      ...............................::::::O@@@@@@@@o:::::.......
                        ...............................:::::oo@@@@o::::..........

The code’s far from polished and not what I like to publish, but it’s a fun thing to look at and offers you some neat abilities to poke things around and fix some pesky problems that just need clear thinking applied to them. It’s available here.

Tagged , , , , , , , , , ,

Make a Money/Card Clip

So the other day I finally got tired with my (awesome) wallet and decided to make something new. I ended up choosing a money clip. Not only would it be a nice, high quality, metal object living in my pocket, instead of a crummy, dirty wallet, but a money clip is good looking, classy and minimalistic way of keeping a hold of my money and cards. Looking around my room I didn’t really get any inspiration, until I saw an old metal fork lying in a box. I cut the head off with my dremel and a fiberglass cutting wheel. A little bit of sanding and bending resulted in a, super-useful money clip. I’ve been using it for the past few days and it’s been serving me really well, looking good, and altogether holding up like a quality product.

If there’s interest, I’ll put up more information / pictures and maybe put some of these bad boys up for sale.

Tagged , , , , ,

GPSd under OS X

So I recently picked up a cheap GPS module on Amazon. It was about $30 with shipping, and I got a neat little dongle which connects over USB to my computer and communicates with software. It didn’t come with support for OS X (although interestingly enough it shipped with Mac OS 8 and 9 drivers), but it promised to send generic NMEA-0183, so I wasn’t too worried.

When it showed up, some quick software probing revealed that it houses a usb to serial adaptor (a Prolific PL-2303, which I’ll get to in a bit) and a gps module that’s configured to send NMEA strings through the virtual serial port. This sort of information is compatible with a host of software, but most of it is commericial, and only available at a considerable price.

Luckily, there’s a wonderful open source project called gpsd which provides support for a wide raft of devices and protocols, and talks to an even wider assortment of software. Primarily, I wanted to be able to get my gps to talk to the network scanner Kismac, and Randall Munroe’s cyborg.py script. Both of these were built to take information from gpsd, so I was in business. However, gpsd, which is designed to play nicely with Linux, takes some coaxing under OS X. This is meant to describe how I got it all running. Continue reading ›

Tagged , , , , , ,

Genetic Algorithms in Perl

Inspired by recent genetic algorithms floating around, I decided to try my hand at implementing one in perl. I’d thought for a long time that it would be quite difficult, but really it’s quite easy. My biggest hangup was dealing with data structures, but once I did that, it turns out that all you really need is a few functions:

  • A fitness function, that determines which individuals are most fit to reproduce
  • A mutate function, that will add random chance into each generation
  • A breed function that allows the best individuals to reproduce.

I ended up implementing a very simple algorithm, but it’s fairly fast and very generic – it can be easily adapted to just about any task. Sadly, I have no fascinating application just yet, but if I stumble across one, I’ll be sure to post about it.

After the jump, I’ll put up some of the code I used and a link to the script, all for your viewing pleasure.
Continue reading ›

Tagged , , , , ,

Synchronized Presidential Debates

I just ran across what is probably one of the cleverest and scariest analyses of the presidential debates I’ve seen this year. It’s ridiculous to see just how similar everything they say is. It’s kinda a shame that the debates were such a place for the candidates to simply spew their canned points to the television-watching world. Anyway:
[brightcove vid=1885473979&exp3=1126121768&surl=http://c.brightcove.com/services&pubid=1126366244&w=417&h=360]

(Via BoingBoing)

Tagged , , , , ,

Fast and Simple Stock Quotes Using Perl

One of the things that makes perl so powerful and fascinating is the huge number of modules that are available online, especially through the CPAN repository. Today I stumbled upon one called Finance::Quote, which does one thing, very simply: it retrieves stock (or mutual fund) quotes. You feed it a ticker symbol and it gives back a hash with all sorts of information, but most importantly, the price. I’m going to show how to use this to create a command line tool that will grab an up-to-the minute stock quote for any ticker symbol you give it.

Continue reading ›

Tagged , , , , , , , , ,

Tobias Wolff is a God among men

I was sitting and re-reading Tobias Wolff short stories the other day, and ran across this little quote, which tore my heart out, twisted my head around and made me totally fall in love with his writing again:

In the solemnity of her attention he heard himself saying things he had said to no one else, confessing hopes so implausible he had barely confessed them to himself. He was often surprised by his own honesty. But he stopped short of telling Mary Ann what was most on his mind, and what he believed she already knew, because of the chance that she didn’t know or wasn’t ready to admit she did. Once he said it, everything would change, for all of them, and he wasn’t prepared to risk this.

Tobias Wolff – “Two Boys and a Girl”

Tagged , ,

Getting Songs Off of Your iPod

In the last couple weeks, at least four people have asked me how to get music off of their iPods. The answer I gave all of them was Senuti (iTunes spelled backwards). It’s great! It does exactly what you need: takes songs from your iPod and puts them into iTunes, and it’s super easy to do. Once you have disk use enabled:

To copy songs back to your computer, all you have to do is select the songs and click the transfer button in the upper left hand corner of the application.

The songs will be copied to the your computer. They will be added to iTunes if you enabled the preference to automatically add them to iTunes.

It’s just that easy.

Of course, Senuti isn’t just a one trick pony, it can do other useful things as well, such as copying songs to a folder, or showing you what songs you already have in your iTunes library, and allowing you to hide them, so that you only transfer new songs.

So next time you feel like IM’ing me about how to get songs off of your iPod, remember Senuti, and save my sanity just a little bit.

Tagged , , , , , , ,