Posts Tagged ‘python’



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

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…)

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.

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. :)

pathetic

Monday, March 10th, 2008

It’s sad how busy I’ve been. Part of it is that school is back in session, and I’m dealing with the intellectual whiplash of a week off and a snow day or two letting me think I could have a good time without too much worry. On top of that, it’s mid-terms, so the workload is a little heavier. By the by — who put spring break before mid-terms. Isn’t that a little counter-intuitive?

The other part is that Nerine’s car has been out of commission, so I’m driving her around as well as trying to get all my stuff done (as if I didn’t have enough driving to do already). Hell, I’m barely home as it is.

So, no real work with the python yet. Soon though, soon. I wanna get this data-miner written! I’m excited!

back to the grind (and occasionally, hiss)

Monday, March 3rd, 2008

Well, spring break (or whatever you call the last week of February) is finally over. Of course, I still cleverly have Mondays off (isn’t that everyone’s dream?), so I got to enjoy my day worry free! Until about 9:30 AM. At that point, I called Nerine back thinking her leaving 3 missed calls on my cell phone must be important. Turns out, her car died. Or was dying. Actually, by all appearances it runs fine, but I guess it was having problems. Still, I digress.

So, I quickly got all my stuff together and was going to head to her work to pick it up, and then to the dealership (leaving my car with her) to take it in. Well, turns out I didn’t have to do that as early as thought (which led to a fantastic row between us over the phone). So I went back and decided I finally should get cracking on some code I started writing back in January for a friend.

I spent that fantastic 2 hours writing maybe 3 lines of python. See, the Securities and Exchange Commission provides access to all of their information on filings in a searchable database. That’s fine and dandy if you want to see one filing at a time. But if you want to analyze trends, you need ALL the data. And to subscribe to their live feed of data… a mere $31,000 per year. They do provide an ftp site that allegedly makes all of this information available, but I haven’t figured out how to dig through all of the data yet. First… I need to get the sample data I want organized how I want it, then I’ll worry about getting all of it.

After I got the car to the dealer, I luckily had Nerine’s laptop (thankfully, running Ubuntu, so it’s already got python and ruby on it) with me, and they had free wifi. I was able to get a little more done there sitting in their waiting room. Of course, that’s before George called.

Apparently, the computers at work are again going willy-nilly, but this time it’s on the server. Never good news. And of course, George has the folks from the company who make the barcode reader dialed in — via PCAnywhere. Ahh, hell of hells. These are the situations that make IT people shriek: (because…)

  1. PCAnywhere is SO terribly insecure in the first place.
  2. What the hell are you having the guy who makes the barcode reader dial in for? This man doesn’t manage the data flow in a production environment. He sells a product that just sends and receives our data for us! Without specific knowledge of our deployment of his device, he can’t do anything but perhaps break it more!
  3. The system he’s dialed in to has the master customer accounts. While it’s unlikely he’s untrustworthy or stupid enough to steal this information, that doesn’t mean he can’t break it disastrously if something goes wrong.
  4. PCAnywhere is really insecure.
  5. I’m the one who did the configuration (and in the end, provided the 2-minute fix)… had I been called first, none of the system’s integrity would be compromised in the first place!

So, that was the end of my working in python for the day.

I’ve also managed to complete my test for my Business on the Internet class. Good news. I think I survived Then again, I’m hoping my grade is inversely proportional to the amount of bullshit involved in that class. That would make my GPA something like a 4.1.