Posts Tagged ‘software’

The Iran problem and theocracies

June 28, 2009

One of the larger pieces of news over the last few weeks was the Iranian election. Or what passes for an election anyway. As I’m sure everybody has heard by now, Mahmoud Ahmadinejad, was allegedly re-elected and Mir Hossein Mousavi, was apparently not. As Mousavi seemed to have a lot of popular support this shocked many Iranians who took to the streets to voice their disapproval. The regime, led by Supreme Leader issued stern warnings and eventually cracked down on dissent with violence. This was accompanied by an attempt to control information. Not allowing journalists to properly cover events, and attempting to control and censor the internet connections to and out of Iran. Typical of a theocratic mindset. We see the same thing on a very small scale on some religious blogs. Post a sound rebuttal to some argument and it is deleted, at least at some sites. Can’t let people see that. Fortunately, the educated populace of Iran managed to skirt around some of these issues and get videos posted to youtube and so forth.

But what about the internet censorship? Apparently two companies are involved in developing the technology to help the religious leaders of Iran monitor and possibly block internet access, Nokia, and Siemens. From the article:

in confronting the political turmoil that has consumed the country this past week, the Iranian government appears to be engaging in a practice often called deep packet inspection, which enables authorities to not only block communication but to monitor it to gather information about individuals, as well as alter it for disinformation purposes, according to these experts.

The monitoring capability was provided, at least in part, by a joint venture of Siemens AG, the German conglomerate, and Nokia Corp., the Finnish cellphone company, in the second half of 2008, Ben Roome, a spokesman for the joint venture, confirmed.

How does it work?

Deep packet inspection involves inserting equipment into a flow of online data, from emails and Internet phone calls to images and messages on social-networking sites such as Facebook and Twitter. Every digitized packet of online data is deconstructed, examined for keywords and reconstructed within milliseconds. In Iran’s case, this is done for the entire country at a single choke point, according to networking engineers familiar with the country’s system. It couldn’t be determined whether the equipment from Nokia Siemens Networks is used specifically for deep packet inspection.

.

Big Brother is alive and well in Iran. From a technology standpoint, it is kind of cool how it works, but ultimately is fundamentally at odds to a healthy democracy. Interestingly, the President of Iran has little real power. The ultimate power rests with the undemocratically selected Supreme Leader. From the Wiki:

However, certain executive powers, such as command of the armed forces and declaration of war and peace, remain in the hands of the Supreme Leader.[5] Furthermore the Supreme Leader may even dismiss the president and prevent the legitimation of any law (appointed by assembly) by the institutions under his control, the Guardian Council and the Expediency Council.

So, that’s the real problem. A shining example of how religion mixed with politics leads to a mindset critical of openness, and insidiously controlling of all. Iran needs a velvet revolution. I doubt that will happen though as this is not a threat to national identity and does not interfere with local religious practices. But it should inspire all of us to vigorously support the American United for Separation of Church and State organization.

Advertisements

Python fun

June 8, 2009

Earlier I had mentioned how much fun coding in python is. So I recently needed to do a few standard deviation calculations by inputting numbers the first time, and reading other numbers, one line at a time from a file. I could do this by plugging in numbers in some calculating device, use excel, or … But instead I figured I’d write a few lines of code and have an excuse to try out Eric, a Python IDE. It seems to support ruby as well, and the save as option suggests support for editing Java, javascript, tex, sql, etc. etc. Overall, I found using Eric to be a pleasure. It’s got all the usual stuff, setting breakpoints, stepping through code, project management, and even built-in support for source control (Subversion and cvs). Of course, the very name Eric, is in keeping with the Python theme, being named after Eric Idle of Monty Python fame. Further keeping with the fame, there exists a code refactoring menu item labeled Bicycle Repairman.

So, here’s a little taste of some code I scribbled out in about 5-10 minutes in Python.


def standardDeviation(mean, numberArray):
""" Calculate the standard deviation
Expects the mean to have already been calculated
"""
sumOfSquares = 0.0
for num in numberArray:
sumOfSquares = sumOfSquares + num *num

rootMeanSquare = sumOfSquares/len(numberArray)
return math.sqrt(rootMeanSquare – mean*mean )

def readInput():
print “Enter a white space seperated series of numbers”
numbers = raw_input(“==>”)
return [int(n) for n in numbers.split()]

def readData(theFile):
try:
myfile = open(theFile, ‘r’)
except:
print “Could not open file”
numlist = []
for line in myfile:
try:
numlist.append(int(line))
except:
print “Invalid input in file”

myfile.close()
return numlist

(Having just done the preview, I’ve noticed that the WordPress formatters did not keep my indentations. Those of you who already know Python know what I’m talking about. For the rest, just keep in mind that every block of code, for example, everything after a def and contained within in it, should be indented with respect to the def label. Simply trying to tab or add spaces doesn’t seem to work right on this editor. I’ve got about 2 seconds before needing to drive to work so later on, if I get time, I’ll see if I can make it look right.)

The def label indicates the start of a function. The readData function opens up a file and we’re prepared to print a warning if the file doesn’t exist. We append each number to an array called numlist. Reading the file was trivial. The line “for line in file” does the trick. Each line is stored in the variable line each step through the loop. Not shown here is the fact that later on I use this numbers to calculate a mean and pass the results to the standardDeviation function.

Later on, if I get time and am motivated, I can prettify this up quite a bit. I could encapsulate a lot of this in a full blown python class and provide more statistical calculation functionality, throw in TK to get some graphics and charting capability, and generally create a nice little statistics package. Of course, a lot of that functionality already exists elsewhere, but its always fun to roll your own to see if you can find a different take on things.

Waving at Google, etc.

June 4, 2009

After yet another unplanned hiatus from blogging (too crazed of a schedule), let’s see if I can get back on track. A few items going on in the news these days. Sadly, of course, the California Supreme Court decided to keep California backwards by denying marriage equality to a subset of people.

On a more positive note, Newsweek recently acknowledged that Oprah has been supporting charlatans, frauds, and, at best, highly questionable and possibly dangerous techniques. I’m sure if she thinks positively about it, the criticism will just go away, as that is her secret after all.

But in the best news (well, putting on my developer’s hat anyway), Google was just talking about the
Google Wave, an instant messaging, emailing, photo album building, document creating, bug tracking (one of the gadget extensions anyway), ad infinitum, shiny new tool with an API for developers to write applications for. The only thing it doesn’t seem to do is brew beer yet, but I’m sure somebody will be working on that. The actual launch date is still a bit out, and perhaps they did this to steal a little wind from Microsoft, which certainly isn’t a bad thing. A very cool tool tool; check it out.

Python for fun

May 1, 2009
Pining for the fjords

Pining for the fjords

A while back I had posted something about Paul Graham’s essay on good hacking environments. As an aside, one of the observations he made (with which I don’t necessarily agree) is that there will be a tendency to find better hackers coding Python than coding Java. I do more Java myself these days, but find I really like Python as well. So let’s talk about Python for a bit. This has become relevant for me because I want to get started on one of the coding projects that has been sitting on my queue at home. After pondering things for a while, I’ve decided to go Python (I already have several Java projects lined up). Python code is pretty, web friendly, object oriented (though you can write it like it isn’t if you really want), and has a lot of useful libraries.

The coolest thing about the language, of course, is that the creator, Guido van Rossum, named it after Monty Python, a little British comedy group that was responsible for finding things like the holy graile, the meaning of life, and starting a religion after a boy called Brian who grew up to be a man called Brian. One of the funky things about the language of Python is that all blocks must be indented. It is part of the syntax as it were. That took me some getting used to, but since pretty code should be nicely indented anyway, that’s not really that intrusive. There are editors that will assist with that, such as emacs (also xemacs), which will run under Windows as well. Python also has its own ide as well, called Eric, which coincidentally is also the name of one of the Monty Python members. Although Python is almost trivially on every Linux system (though you may need to select the software; I did for SuSE) you can have it Windows too.

One of the fun things about Python is its support for imaginary (complex) numbers (square root of -1, for well defined rules of multiplication). Stick a j on a number to make it imaginary. For example, in Python you can write a complex number such as a = 3.0 + j5.0 . Then establish that a.real is 3.0 and a.imag is 5.0. With that comes a lot of manipulations, etc. You can do the same thing in Java, but you would need to find a library for it, or write it yourself.

So what else does Python give you? One of the powerful web application servers out there is Zope, written in Python. I have not played with this yet, but am reasonably confident that if you are writing Python apps, you could easily leverage what Zope offers. You can do graphics using the TK (toolkit) interface arising out of TCL/TK by using TKInter, and I’ve recently found out about vpython, another library that allows you to do 3d graphics and animation. Apparently a lot of colleges are using this to have inexperienced (from a coding point of view) students write their own physics demos. I expect I’ll play with this a bit going forward.

What does code in Python look like? Here’s an example of some really simple throwaway code I did several years ago. This sends email to a specified address (maintained in a separate configuration file called mailconfig.py).

import smtplib, string, sys, time, mailconfig, os
mailserver = mailconfig.smtpservername

interestingStuff = sys.argv[1]

fd = os.popen('hostname')
myhostret = fd.readlines()[0].split('\n')

From = mailconfig.sender
To = mailconfig.recipient
Subj = 'Some Alert!'

date = time.ctime(time.time())
text = ('From: %s\nTo: %s\nDate: %s\nSubject: %s\n\n'
% (From, To, date, Subj))

text = text + "Something interesting happened on " + myhostret[0] + " for " + interestingStuff

text = text + "\n\n" + mailconfig.signature

print 'Connecting...'
server = smtplib.SMTP(mailserver)
failed = server.sendmail(From, To, text)
server.quit()

Of course, one can add to this and make it as complicated as one wants. The import at the beginning just specifies some libraries like the stmplib that the Python interpreter needs to do its work. Python can look even more simple. All you need to do is run the interpreter and type in equations to use it as a calculator (that’s what I often do for quick calculations…either that or Lisp).

So, go ahead, if you are not a software developer, try your hand at some simple Python code. I am of the opinion that everyone should know a little coding, just like everyone knows how to hammer a nail in a piece of wood. Not everybody is going to build fancy furniture and houses, but should be able to do a few simple things here and there. Python is a great language to get started playing around and pick up a few things. I promise it won’t kill your parrot.

New OS

March 29, 2009

Sort of off topic from anything I’ve written here, but, hey, I think it was kind of fun. I spent yesterday afternoon installing the openSuSE 11.1 Linux distribution on a new system I bought recently. So, I can now give a brief review so far.

Seems like a pretty stable distro so far. The installation went very smoothly. I had to spend a little time mucking about with the partitioning, since the interface is significantly different than what I’m used to with SuSE (10.2 and going back earlier). But I managed to create the / mount, swap, and stick everything else into logical volumes (/home, /usr, /opt, /{and so on}) for ease of expansion later. Once that was done, everything went as smooth as liquid helium. The sound card (82801G ICH7 family high definition audio controller) worked perfectly. My last sound card worked as well, but I do remember the days when sound cards on Linux was kind of hit and miss.

One of my pet peeves in software design is poor user interface design. There were a few glitches in this area. I opted to use a static IP address (for some future DNS set up, and didn’t want to fool around with callbacks, being kind of lazy) instead of a DHCP (obtaining a dynamic IP). In spite of a perfectly valid IP I entered, it kept complaining that it was invalid. Turns out I had an extra space before the address. How difficult could it be to trim out extra spaces? This is what we do in our code all the time. The most tedious part was getting online updates near the end of the installation. We have a cable network connection to “the cloud” and this just took forever. Which is o.k., I’ve got things to read while this is going on. But, when one connection fails it would throw up a dialog asking to retry, ignore, or skip. I’d usually hit retry and everything would be fine. It would also give a little beep when pressing the “Retry” button. In fact, it would have been more useful to have the beep when throwing up the dialog. I don’t need audio confirmation that I pressed a button; I have visual confirmation of that. The updates take so long that I need an audio cue that the dialog came up. There were many instances where I’d look up from my reading and chance to see the dialog.

It is still painful to grab all software to install (all the optional packages and such). In the old days, after selecting all, you wouldn’t actually get everything but would still need to go and select individual packages. I didn’t actually see a select all option this time, but had to go in from the beginning and select everything individually. I do tend to want to get everything out there, all kernel source, all development tools, etc., etc., so I’m not sure how much of an issue this would be for the average user. But I will say that compared to previous releases, there was much less in the way of having to slog through dependency hell this time. They seem to have fixed this up pretty nicely.

With KDE 4.1, the task bar disappeared when moving to multiple desktops. After researching this for a while and finding no clear answer applicable to what I was doing, I found rebooting fixed the problem. Probably restarting the windows manager would have been sufficient, but oh well. KDE 4.1 does seem pretty sexy (yes, I opted for KDE instead of gnome, although I went ahead and installed all the gnome software). Infinitely configurable as well, there’s a whole lot to play with here.

But all in all, those complaints are pretty minor compared to the big changes that seems to have gone into this distro. The NIC (network card) drivers worked great. On the old SuSE 10.2, my NIC card would not work unless I have a noapic parameter to the kernel on boot. Took a lot of headaches to figure that out. With 11.1, the network connection came right up with no headaches at all. It came with a lot of cool apps and server additions. I’ll have to spend more time playing around with it to see everything they got, but so far, responsive and solid. If you want to try a Linux distribution, you wouldn’t make a bad choice to go with this one.

After backing things up and moving things around, I’ll replace the old SuSE 10.2 with Ubuntu to play with and see how that goes. I keep hearing good things about Ubuntu and guess I should see what the fuss is about.