Archive for the ‘coding’ Category



i miss you, world!

Saturday, February 21st, 2009

aha! I’m lame. Haven’t updated in.. yes… 2 months and 6 days. I believe that officially puts me in the world of “suck”. Redbrain from #linuxoutlaws (@freenode) actually said to me almost a month ago: “Hey, nice blog man, keep it up!” and I said to myself “Man, I really should update that”. But I didn’t. There are no real excuses, but I’ll make some anyways, namely:

  1. STL, I love you, but I hate you. Templates, You guys can suck a fatty too. You’re so useful, but just such a pain in my patoot. Of course, I treat you well when we’re writing together on our own… but the pain you cause me when you’ve run off with someone less responsible than me is excruciating. Where’s the love?
  2. Haskell … oh boy Haskell. When I discovered the ease of Python after being raised in the world of C/C++, Python was the Orinoco Flow of my programming world! Light and airy, I swear as I checked my indentation that first time that around the world hippies were swaying and holding hands rejoicing about something or other. But Haskell.. you dirty rascal.. you’re my Korpiklaani. You’re a wild beast that’s angry and ready to be let loose on anything that needs a quirky methodology, and yet at the same time, you’re catchy, and enjoyable, and oddly enough, make perfect sense. I don’t know what it is about Haskell (or Korpiklaani, for that matter)… it’s clunky syntax and functional modus operandi are bewildering, but I like the way it works. So much of Project Euler, if done in Haskell, are one-liners, and the flow of them actually makes sense. Haskell seems like doing surgery with a chainsaw, and miraculously, the patient not only is cured, but has grown organs for breathing underwater and x-ray vision. It’s just got that kind of whiz-bang.
  3. Left 4 Dead. I haven’t had much time to play, but boy oh boy. If you haven’t seen this game somehow.. let me sum it up for you: Post-apocolypse + Zombies + shotguns + multiplayer first-person-shooter = love.

And that, boils and ghouls, has been what my last two months has been all about. Let’s see if I can make it around to actually post again before I’m 70.

swamped

Monday, December 15th, 2008

Boy, oh boy! I have just been swamped recently between work, school, and actually trying to get to the gym once in a while. Glad I could make it in to post before the month since my last post rolled over. I already feel like a jackass not updating.

Work is going well. The students have their finals this week, which means the next two weeks I basically get to do nothing. For the next 4 or 5 days though, it will be sheer madness. Students seem to want to wait until the last minute when they’re desparately behind to ask for help, by which point they’ve frustrated themselves so thoroughly, they expect me to step in an just do it for them (to which I respond by giving them a big ol’ ticket for a free trip on the FAILboat). I’m also amazed sometimes by how much people want to (yes WANT) to not catch on, and continue to make excuses as to why they can’t do something instead of just learning to do it. It makes me wonder if in the past (or even currently) I have done the same things. I’d like to think not.

School, while intriguing and challenging, has been eating up a good hunk of time. I’m OK with that. In my programming classes over the past few weeks, I’ve had the pleasure of re-implementing the unix tools “cat” and “grep” in c/c++ and the FreeBSD passwd diff’ing security check in bash. It’s kind of neat to dissect and re-implement the tools I’ve been using for so long. While they seem like trivial exercises, it teaches alot about why software engineers design software they way they do. Who would have thought there were so many ways to put the contents of a file to STDOUT? Now the question is, whose way is faster, better, and more concise, and why is that? I know when I’m doing work for production, a lot of times these questions don’t receive alot of attention. “Oh, it compiles? Ship it!” It’s nice to see some time spent discussing the science behind our science. ;)

Fun stuff.

Since the recent laconica updates, lopost is indeed broken. I have not had the time to fix it. Sad but true. I’ll probably rework it over the semester break. Chances are I’ll have to take a look at the way gwibber does it, as my code was based on the original python at the laconi.ca trac, which no longer works.

I’ve also been asked to help out with the SQL security libraries for Photon CRM, although all of that is still in the planning stages. I’ve started writing some documentation (as in anything that doesn’t exist yet, document first, implement second), but we’ll see how much time I end up having for actually writing the code.

lopost python script

Friday, October 10th, 2008

Last post I talked about the laconica services and using linuxoutlaws.net. Well, I really enjoy it, but I wanted to be able to post without actually visitng the site. My first thoughts were to write something in perl so I could use it as an irssi plugin. I ended up just writing a stand-alone script in python and creating an alias in irssi to call it. It ended up being quite easy to add all the features I wanted, and I’m pretty pleased about that. I’ll be putting up the code, and I’ll keep it updated if I do more work on it.

Update: Code posted @ lopost

few and far between, and project euler #15

Wednesday, September 24th, 2008

I feel crappy that I haven’t been updating, but I’ve got 12 hour work days. There’s that twinge of guilt about unattended blogs, but I’ll be in the back of a class supervising a lecture (like I am now, actually) and just think: “now’s not the time!”

But yes, I’m still around, and I haven’t forgotten my meag… erm, “highly exclusive” readership. So, how’s my week been?

Ok. Been working on fixing my damned pointers. I have one that keeps faulting when I delete it and I don’t know why. So, as angry as computers make me, I was glad this morning.

Why? I did a project euler problem (#15) without a lick of programming. The question was in a 20×20 grid, how many combinations of paths are there from one corner to the other. Welllllll permutations tell us it’s the factorial of 2 times of the size of your grid, all over the factorial of the number of possible choices multiplied by factorial of the the number of columns. In easier terms, that’s

(2n)! / ¹n! * ²n!

And since our grid is 20×20… well. You figure it out.

Hope to be back soon enough!

project euler #9

Friday, September 5th, 2008

Many of you know I’ve been sucked into the world of Project Euler. I love problem-solving with computers, and I love math, despite not being great at problem-solving with computers and being even worse at mathematics.
As of yet, most of my solutions have been brute-force attempts which get the answer quite ahem thoroughly, if not the most efficiently.
Well, project euler #9 involves calculating pythagorean triplets, and I’d left it for a while deciding it would involve a pain-in-the-ass buttload of calculating and would take about 20 minutes to run. However, I’ve been listening to The Teaching Company’s The Joy of Thinking, and they presented ways of calculating the pythagorean triplets that I’d never really thought of.
Anyways, this morning I was waiting around for a while between errands, and a napkin and 4 lines of python inspired me. All I had to do was reduce the fact that:
2mn+(m*m - n*n)+(m*m+n*n) = 1000
to
m(m+n)=500 and run through m and n with n < m. BAM!

[nate@pepper python]$ time ./peuler9.py
sum = 1000
product = *****

real 0m0.012s
user 0m0.010s
sys 0m0.000s

Yes, I removed the actual answer so as not to be a spoiler. However, I will include my full source code, as I’m amazed at how simple it was, and maybe you’ll enjoy it too.
(source code after the jump…)
(more…)

drupalizing

Saturday, June 28th, 2008

Well, slowly but surely I’m learning the innards of building drupal modules. I’ve started learning from “the drupal book“, and it’s a big dive in. It also appears I don’t remember as much PHP/MYSQL as a I used to know, so it may be time to go back and re-read O’Reilly’s Learning PHP. Soon enough though, I’m sure I’ll be a drupal ninja.

Class-wise, My Human Relations class wraps up Tuesday with our big final presentation. Should be interesting enough. Three more weeks of physics, and I’ll officially be a full-time drupal developer for a while. Scary!

Guess I had better keep hitting those books.

quick and dirty motion

Friday, May 23rd, 2008

Well, I wrote a quick & dirty motion module in python that represents single-vector motions in physics. I did it mosty to do my homework for me. I may expand on it though to include more dimensions… at which point I’ll probably release it to the wild and hope someone has fun with it.

Also, it’s funny how when at work I hit ctrl+alt+right to switch to the next desktop, only to be sadly reminded that it does not exist on windows.

i made a plugin

Monday, April 14th, 2008

Well, aside from getting ready for finals (ugh!), I had the inspiration of a group on Gnome Look to make a plug-in for the Gimp. The group “No Ubuntu Wallpapers” is based around the idea that there are way too many people just slapping the logo of their favorite linux distribution on a sexy picture and posting it as art. So, half tongue-in-cheeked, I made a plug-in that does exactly that!

Written in python for the Gimp’s Python-Fu scripting language, it takes an image (potentially of a sexy and scantily clad woman) and changes it to the colors and logo of popular linux distributions.

Here’s some examples.

Example 1

Example 2

Example 3

If you want to snag it, it’s available for download here.

i’m a contributer!

Wednesday, March 26th, 2008

Well folks, I’ve officially posted my first ever public contribution to the linux desktop community. I made a badass conkyrc that I was quite proud of. So I uploaded it to gnome-look.org. So now no one can say I never did anything for the community! (Aside from giving away linux CDs almost every day, and helping people with their installs, and… well yea)

If you want it, go check it out here.

my conkyrc

if the python’s a-rockin, don’t come a-knockin’

Wednesday, March 12th, 2008

Update on the SEC parser. I’ve started rewriting it with xml.sax instead of xml.dom.minidom. I realized that since I’m already processing 100 pages at a time (despite the fact that it’s fast as balls already) it may as well be fast. And despite the fact that I’m writing more code to actually do what I need it to do, considering SAX is so much simpler, the code is easier to read and alot more fun to write. It’s straightforward, which is how I feel python should be damnit. Plus, it may make a big difference when I start multi-threading it to pull a whole month’s worth of the SEC’s database. That’s a lot of 4/a forms to read through. :)