Friday, December 16, 2011

Not the camel

I keep forgetting it's NOT the "camel" Perl book I have. It's the llama.

The Camel book is a thousand pages long - the Llama book covers syntax and control structures.

I'll pick up the Camel book after the holidays (hopefully I'll have some Amazon gift cards or something).

Tuesday, December 13, 2011

Looking back at the security camera program

The Python+OpenCV program I wrote last summer is pretty handy.

http://chrislearnsc.blogspot.com/2011/03/added-timing.html

I use a modified version of that to take a picture every time I boot my laptop.

If I can find a way to get webcam images without using OpenCV I'd like to flesh the program out a bit and maybe add more options (command line or GUI with PyGTK). It's necessary to get away from OpenCV because it's serious overkill for just grabbing webcam images. Also, it's horrifying to install - it took me weeks to get it to work on my laptop and if it ever broke I wouldn't know where to start. I think that there are handy ways of grabbing webcam frames in Linux, but I don't know about OS X or Windows.

Monday, December 12, 2011

Perl

I stumbled across a Perl book I have sitting around (the camel book).

So far I haven't run into a problem that readily called for Perl, and honestly I wonder what kind of people use it on a day-to-day basis. I did a search for reasons to learn Perl, but most reasons have to do with parsing large text files.

I don't have any large text files.

Wednesday, December 7, 2011

Don't work harder, work smarter

10 minutes of code saved me an hour of copying and pasting repetitive lines in a script.


EDIT: Oof, bad newbie - no treat. Forgot to close the file. Leaving it up as a shameful reminder.

Monday, December 5, 2011

Project Euler 13 WIP

I meant to have this finished by now but I got distracted. I already know how to finish it, but I don't yet know when I will be able to. Here's what I have so far.


Here's data.h:



What's left to do is pad the storage array so that the remainders can add up and I'll be able to reconstruct the sum in this artificial manor. The printf() where it dumps everything out was my sanity check before I went any further.

Wednesday, November 30, 2011

Updates

I went through and tagged most of my Project Euler related posts. The final code, code that was related (like preliminary prime finder code), any rigorous pre-code discussion was tagged. I didn't tag a lot of the work-in-progress code since it's just unfinished final code that isn't all that useful to review.

The wife wanted me scarce while she studied so I went up to the office and knocked out a lot of Project Euler 13. I should have final code this week. It's a really interesting problem because it deals with adding numbers that can't be stored in even a 128-bit integer, and as a result it's forced me to really hash out what it means to add large numbers in a methodical fashion, which I worked out on paper first.

While going through and tagging my posts I realized that I only started the PE problems in February of this year. I'll probably get through a few more so that would make around 14 problems done this year. That doesn't seem like a lot but it's 14 more than I could have done when I first started learning C so I'll take it as a win.

Tuesday, November 29, 2011

Note to self on overriding dealloc in Obj-C

I went through the chapter in Obj-C:TBNRG about ARC and retain cycles and got to the end with my head spinning. I understand what's going on but following which instances of what class own who is dizzying. The Objective-C style of having two files per class (one header file one implementation file) makes it hard to follow since you can't see everything at once. Well... maybe having everything in one big file isn't the way to go either.

Anyways, I intend on going through it again for good measure.

Something that had been bothering me is that in the classes you make for the example you override the dealloc method so that you can toss a print statement in to say when it's being deallocated (in an effort to show what actions on the data cause it to deallocate automatically). I realized that the implication would be that the data isn't actually getting deallocated! So, to the internets I go and I find that The Big Nerd Ranch has a forum for its books, wherein I find this:

http://forums.bignerdranch.com/viewtopic.php?f=151&t=3223

Basically: the magic of ARC saves you by somehow knowing to call the dealloc of the parent class (or the parent's parent class which inherits NSObject I think in the example). I don't like magic, but I'll roll with it for now.