Interesting How Things Work Out: Internet Freedom

Tim Johnson is a U.S. Democratic Party senator from South Dakota.

  1. He co-sponsored PIPA in the U.S.
  2. He is also the primary sponsor of the Johnson-Shelby Iran Sanctions, Accountability and Human Rights Act of 2012, which “Requires the Administration to devise a comprehensive strategy and report to Congress on how best to assist Iran’s citizens in freely and safely accessing the Internet, developing counter-censorship technologies, expanding access to ‘surrogate’ programming including VOA’s Persian News Network, and Radio FARDA inside Iran, and taking other similar measures.”

Interesting how things work out, eh?

[HT: Jason Ditz]

New Steve Jobs Successor Announced Today

In an inevitable move this morning, Apple announced that Rudy Giuliani would be the successor to CEO Steve Jobs.

Apple announced that Rudy had plenty of experience handling the “Big Apple”, so directing the future as CEO of the little apple should be child’s play. Rudy has stated repeatedly that he’s looking forward to “a breath of fresh air” in Northern California, and the lack of term limits.

When asked about whether this had any impact on the possibility of a “Perry-Giuliani” presidential ticket, Rudy refused to answer directly and merely muttered a mysterious phrase “Look iVicePresidential?”

Speculations are swirling as to how Rudy will show himself “tough on crime” in the Apple community, which most reliable sources agree is filled with thugs and vagabonds. When asked what he could do for Apple, Rudy stated that during his mayorial career, his record on New York’s crime rate was an example of “the most focused form of policing in history” and that he would “take the iPhone desktop device to new unimagined heights”. “Believe, me, I have a legacy beyond 9/11 and Apple recognizes that. Why else would they pick me?”

When asked critical questions at the press conference about his lack of expertise, knowledge of, or passion for the Apple product line, Giuliani responded vigorously: “My technological affiliation, my geek knowledge and the devotion to Apple products, I leave to Steve Wozniak to judge.”

When Steve Wozniak, the co-founder of Apple, was asked about Giuliani he had a vigorous belly-laugh and narrowed his eyes and said, “I have an opinion, but remember I’m still technically an employee and a shareholder.” He continued to laugh and then said “Let’s just say that Rudy will never be inducted into the National Inventors Hall of Fame like I have. And he’s more of a Blackberry type of guy.”

Rudy refused to comment on Wozniak’s belly-laugh and has neither confirmed nor denied whether he will be wearing a turtleneck.

Despite obvious differences, there are some interesting similarities between Rudolph William Louis “Rudy” Giuliani and Steven Paul “Steve” Jobs.  However, marketing analyst Coleen Card doubts whether Rudy can fill Steve’s turtleneck and present the sort of “cool” image that Apple needs.

Disassociated Press, August 26, 2011

My Philosophy of Podcasts

  1. Use a good player that fully supports podcasts. The last thing you want is a player that supposedly supports podcasts but then makes you do all the leg work (thus eliminating some of the major advantages of podcasts). A podcast, by definition has a feed, and the player should support subscribing to that feed in some fashion, and have some mechanisms to automatically download the episodes for you and present them to you in some fashion. It should also provide some mechanisms to present which shows have been listed to and delete or hide them. If you are on an Android phone, I highly recommend DoggCatcher (I know, weird name, but it is great).
  2. The beauty of podcasts is the way you can set your player/device to fetch them automatically and delete them when you are done. It’s hard to believe we had to go to the websites individually to manually download this stuff!
  3. Having too many podcasts can be frustrating, you can never keep up. Too few can can be annoying because there will be times when you would like to listen something and simply have no episodes of anything.
  4. Podcasts that advertise themselves as such, but then fail to provide an RSS feed annoy me to no end. Individual mp3 episodes (in my mind) are not a podcast! I can’t tell you how many times I encounter sites (made by people who should know better), who make it nearly impossible to find the podcast rss link.
  5. Podcasts that only feature an Itunes subscribe link are annoying too! Hello, not everyone has an apple device and not everyone uses itunes…
  6. “Is there any chance I’ll listen to an episode of this in the next month?” may be a good criteria to determine whether to subscribe.
  7. There are basically two types of podcasts, the ones you want to listen to every single minute of, and other ones that you let run and tune in and out on (or perhaps look at the title a just skip through them).
  8. A good balance between “an episode every day or week” and “an episode or two this year, perhaps” shows is good. Too many of the former and you will be overloaded and never able to keep up. Too few, and you’ll find yourself wanting to listen to something and not have anything.
  9. A good variety between emphasis on episodes among your podcast list is good (ie. both long and short, interviews and lectures, serious and funny, etc.)
  10.  Are you a podcaster and you want to improve your podcast? General tips that should work out to your advantages in most cases:
    1. Publish more than once a month but less than twice a week, and then make your shows longer if you need to.
    2. Try to make your shows an hour or less if you can.
    3. On your website, make the RSS feed clearly visible!
    4. Avoid annoying ranting, if you are just one person, at least interview someone once in a while!
    5. Balance continuity and discontinuity between shows.  No thread or too much of a thread between shows can become a problem.
    6. Each episode, while ideally sharing common themes and continuing various memes, should to some degree intelligible without listening to the previous show or all the shows up to date.
    7. If you make jokes and your show isn’t explicitly about humor, more likely than not your jokes will sound corny.
    8. Consider and evaluate the tone you use and the way you handle guests or people you talk about! An overly polemic or negative tone actually gets quite annoying when you listen to it over and over again.
    9. Try to get the best audio quality you can!
    10. Think carefully about the theme music, don’t make it too long.
    11. Episode show notes can be a real asset if they are done well.
    12. Constantly talking about money (unless of course you are NPR Planet Money :) ) gets old very quickly (and saying how you “hate doing this” or “we never do this” doesn’t make it more excusable). Hearing small one-man podcasts repeatedly talk about money gets really irritating. If you’re a big organization that actually has an infrastructure and a following outside of your podcast, this is more excusable, though depending on context it can still be annoying.  I think I must have dropped at least 4-5 podcasts because the constant jabbering about money or complaining about the lack of it just got so annoying and eliminated or reduced the usefuless of the podcast.  If you talk about money do it minimally, giving listeners the information they need in order to donate (without repeating it too often).  While one might pay for audio content, it is highly unlikely anyone wants to pay for audio content of you asking people to pay you for audio content. If you do ask for money, I suggest taking one of the following approaches:
      1. Put it on your website, but leave it out of the podcast.
      2. Make it a predictable, scripted, tasteful presentation of about 15-20 seconds a consistent place in the beginning or end of your show (if I get the sense that any time, I could get an extemperaneous speech lasting between 1 minute and 20, I will drop your show ASAP).
      3. Devote one show to talking about money and then drop the topic and do not bring it up in any other show until at least a year or two has passed.

A Fun Python/Ruby Exercise

1. I made a function to generate one million random integers between 0 and two million.

2. I wrote another function to do a bit map sort on this list of integers (slightly cheating by having my bit map sort function receive a parameter which represented the maximum value it might encounter–two million). The bit map sort was roughly based on one in a Jon Bentley book Programming Pearls.

3. (By the way, I implemented these two functions in both Python and Ruby).

4. I then ran the following benchmarks:
A. Ruby (1.92): My bit map sort on the random integers
B. Ruby (1.92): Ruby’s built-in sort on the random integers
C. Python (3.2): My bit map sort on the random integers
D. Python (3.2): Python’s built-in sort on the random integers

Here were the results:

A. Ruby (my bit map sort, with cheating via a max value): 1.66 seconds
B. Ruby (built-in sort): 1.68 seconds
C. Python (my bit map sort, with cheating via a max value): 2.91 seconds
D. Python (built-in sort): 3.19 seconds

There is a remarkable difference between Python and Ruby in terms of speed/overhead.

(Note: After I ran the initial benchmarks, by refactoring my bit map sort to fix an inefficiency in the bitmap initialization, I was able to bring the Ruby version down to an execution time of 1.38 seconds and the Python version down to 2.77 seconds. I’ve posted the source for the python version and the ruby version.)

Thoughts on Beautiful Code

Here are some good programming thoughts from Beautiful Code (edited by Andy Oram and Greg Wilson, O’Reilly).

On Elegance vs. Performance Trade-offs

“[I]t’s much easier to make beautiful-but-slow code fast than it is to make fast-but-ugly code beautiful” – Rusty Harold (author, former professor)

Defining Beauty

“Code is typically considered beautiful if it does what it’s supposed to do with unique elegance and economy.” – Alberto Savoia (Google)

On Testing

“Generally speaking, the main purpose of tests is to instill, reinforce, or reconfirm our confidence that the code works properly and efficiently.” – Alberto Savoia (Google)

Differences Between Python/Gvim and Java/IntelliJ

Recently I’ve went from almost exclusively programming in Python with Gvim as my IDE to, while still using Python/Vim here and there, mainly developing with Java and IntelliJ at work.

When I’ve went  back and forth between Python/Vim and Java/IntelliJ in the last couple of weeks, I’ve noticed some interesting things happening.

Here are differences that have tripped me up:

  • When I switch over to the Python/Vim, I find myself not saving because I’m used to IntelliJ’s constant auto save and then I wonder why the most recent change isn’t saved.
  • Python’s lack of explicit type definition, while I understand the reasoning behind it and the advantages, seems way more dangerous than it did before (maybe that is a good thing and will make me a better Python programmer).
  • IntelliJ makes my Gvim setup, which I thought was nice, seem like junk. I really do like what JetBrains did with IntelliJ.  Vim seems like such a barren world without IntelliJ features like strong version control integration, strong project integration, crazy code competion (with even code completion integration in templating library markup!) and powerful commands like Ctl-B, Ctl-Shift-B, Ctl-Shift-N, Alt-Insert, etc. Refactoring and reworking code seems to often be more work than it should be even with the most advanced Vim setup.
  • The fact that I can just write a .py file without a class directly undergirding it feels weird after being immersed in Java.
  • It’s HARD to switch between Java and Python style naming conventions. This huge Python fan is starting to see the advantages of Java-style naming when it comes to bigger object hierarchies.

Here’s some things I *thought* would trip me up, but haven’t:

  • The semi colon to end a line thing versus no semicolon. Transitioning between these styles has presented  no difficulty. Since the change, I’ve never put a semi-colon in a Python program or vice versa.
  • Switching back and forth between the differences in compilation between Java and Python is pretty much a non-issue. Anyways, that sort of stuff should normally be abstracted away from the programmer by an IDE, build tasks, or other deploy processes.
  • It’s easy to continue to appreciate Python’s less verbose way of doing things!

I’m currently checking out PyCharm (JetBrain’s Python IDE which is fairly similar to IntelliJ).  Haven’t used it enough to review it, but I will soon. Maybe this is a way I can bridge the two worlds!  Just for the record, I’m by no means giving up on Vim. I still love the POWER and FLEXIBILITY of Vim.  I just want to use the right tool for the right job. And while you can do hard core development with Vim, I’m starting to think it may not be the most efficient tool for the job when compared with IntelliJ/PyCharm (depending, of course, on you are content using the community edition or springing some money for the fully featured product).

Some IntelliJ IDEA Notes

Getting adjusted to Java development within IntelliJ IDEA has been interesting. It’s a GREAT development environment.

I’m using Community Edition 10.0.3

Here are some quick notes of some commands and features I’ve found useful:

  • To enable or disable a plugin: File, Other Settings, Configure Plugins
  • Get a plugin from the repository (for example, get the Foo plugin): File, Settings, Plugins, [wait for it to download the full list], Available tab, right-click “Foo”, select “Download and Install”, and then press”Yes”
  • Change which SDK your project uses: Right click project, Open Module Settings, Project, select it in Project SDK section
  • Attach a jar file or jar directory to your project: Right click project, Open Module Settings, Dependencies Tab, Add, Library, and then either “Attach Classes” or “Attach Jar Directories”
  • Run your code (Keyboard Shortcut): Shift, F10
  • Go to Settings (Keyboard Shortcut): Ctl, Alt, S
  • Module Settings (Keyboard Shortcut): F4 (when in module)
  • Find usages of something (Keyboard Shortcut): Alt, F7 (while on it)
  • Collapse/Expand a method (Keyboard shortcut): Ctl, Numpad + and Ctl, Numpad -
  • Go to Type declaration (Keyboard shortcut): Ctl, Shift, B

NetBSD Episode #3

  • I overcome the “shared memory segment” error I encountered earlier using postgre’s initdb by tweaking shared_buffers and max_connections in postgresql. This is just a staging install, so I could take those settings way down.
  • I then used pkg_add to install subversion, openjdk7
  • I set JAVA_HOME:
    • export JAVA_HOME=/usr/pkg/java/openjdk7/bin/
    • export JAVA_HOME

NetBSD Episode #2: Continuing On

Now I’ve continued, and done the following.

  • Used pkg_add to install ruby19-rails, wget, links, vsftpd, django, south, and postgresql
  • Copied /usr/pkg/share/examples/rc.d/vsftpd to /etc/rc.d/vsftpd
  • Copied /usr/pkg/share/examples/rc.d/pgsql to /etc/rc.d/pgsql
  • Added vsftpd=YES and pgsql=YES to /etc/rc.conf
  • Then I went to initialize the postgres with initdb, ie:
    • useradd -m postgres
    • passwd postgres
    • mkdir /usr/local/pgsql /usr/local/pgsql/var
    • chown -R postgres:users /usr/local/pgsql
    • su postgres
    • initdb -D /usr/local/pgsql/var

At this point, running initdb failed complaining it can’t create a “shared memory segment”. “This error usually means that PostgreSQL’s request for a shared memory segment exceeds available memory or swap space.

I ran out of time this morning and have not had an opportunity to address this yet.

NetBSD Episode #1: My New Staging Environment

Recently I deployed a new staging environment on my home computer. I decided to use NetBSD 5.1 (for the i386 architecture) running on Virtual Box on my desktop.

Some randomish notes:

  • I decided to use blowfish for the user passwords
  • I added a non-root user and I changed the hostname to “hayek” in /etc/rc.conf
  • I want SSHD started by default, so I put sshd=YES into /etc/rc.conf
  • In order to get NetBSD’s package system pkgsrc going, I had to enter the following into my shell
    • export PKG_PATH=”http://ftp.NetBSD.org/pub/pkgsrc/packages/NetBSD/i386/5.1/All”
    • export PKG_PATH
  • I then used pkg_add to install nginx and added a couple lines to /etc/newsyslong.conf as suggested by pkg_add
  • I then had to enable nginx in /etc/rc.conf and copy /usr/pkg/share/examples/rc.d/nginx to /etc/rc.d/nginx
  • I also used pkg_add to install python (2.7.1) vim, ruby (1.9.2p180), mysql-client, mysql-server (5.1.56)
  • Then I set the mysql root user password with /usr/pkg/bin/mysql_secure_installation (although it alternatively if I had more patience, I could have been set directly via mysqladmin)
  • I then had to enable mysql in /etc/rc.conf and copy /usr/pkg/share/examples/rc.d/mysql to /etc/rc.d/mysql
  • To be continued…

Anyways, this really isn’t anything out of the ordinary, just thought I’d share.

Apps I Really Appreciate

This is a start, I’m not promising this list is complete!

Networking

Text Editors

  • vim – Calling it a “text editor” is an understatement (in case you are interested, check out my vimrc file)

Graphics

  • Gimp – GNU Image Manipulation Program

Database Development

Languages / Platforms

Android Apps

  • DoggCatcher – excellent audio/podcast manager
  • Google Reader/Places/Maps/Talk
  • Dropbox
  • Amazon Kindle
  • SL4A / Python for Android (Python on the android!)
  • gh4a (Git Hub for the Android)
  • Droidstack (for the stack sites, like stackoverflow)
  • Urban Spoon
  • GasBuddy
  • Olivetree Bible Reader
  • ESV Bible App
  • The Weather Channel
  • iBirdLite
  • Traffic Jam (game)

Web Services/Apps

Django Models and Inheritance

One of the first stumbling blocks that I came across as I’ve been learning Django (a Python web framework) was when I tried to do some inheritance with my models in app/models.py.  It had to do with abstract super classes.

Intuitively, I assumed that Django would take super classes and figure out how they worked and ignore the abstract super (or base) classes persay and  generate the SQL for their sub (or derived) classes by properly negotiating the inheritance.

So I went ahead and did something like this:

class super_class(models.Model):

>>> field1 = models.BooleanField()

class sub_class(super_class)

>>>  field2 = models.BooleanField()

I was wrong. It generated the SQL tables for all of the classes, including the abstract super classes, which technically could be made to work, but is certainly not what I wanted.  While it isn’t very apparent in an example with just two models, it introduces too much complexity in the database design since it makes a table relationship for every inheritance.  We want tables for concrete super classes but not abstract ones.

So, on to my next intuition. I assumed that if I made my super class not inherit models.Model and made the sub class use multiple inheritance and inherit models.Model and the sub class, this would all work.  Seemed to make sense to me at least.  So, I did something like this:

class super_class():

>>> field1 = models.BooleanField()

class sub_class(model.Models, super_class)

>>>  field2 = models.BooleanField()

Again, I was wrong. While last time the result was convoluted and inefficient, this time the result was worse and clearly crippled. While the correct tables were displayed (ie. the super classes didn’t appear as a table), the fields from the Super Class (represented in my snippet represented by “field1″) were missing. I assumed that, perhaps, the model for the sub class would get “field 1″ even though the super class was not inheriting model.Models.  I was wrong and stuck.

With some assistance from Michal Petrucha over at django-users, I was able to learn that I was indeed missing something.

In order to make what I was doing, I had to set a property within a Meta class embedded in my super class. Like so:

class super_class(models.Model):

>>> field1 = models.BooleanField()

>>> class Meta:

>>> >>> abstract = True

class SubClass(SuperClass)

>>>  field2 = models.BooleanField()

With this little modification, everything works as expected. I have my abstract super classes and sub classes, and the relationship between them works as I would expect. Abstract super classes  propagate their properties to the SQL tables of their sub classes, but don’t actually show up as a table of their own.

Thank you Django-Users and especially Michal in helping me to further my Django understanding!

Ancient Code on GitHub

I rarely speak about technical/programming things on this blog, but you may see that changing a bit.  Sometimes I find I don’t need a blog as an outlook to talk about technical things, as has been the case for years, and so then I blog on other things. And at other times, it is sort of nice to talk about my technical interests!

I’ve joined GitHub and just making some really quick perusals of it. It’s a really neat community. The easiest way to describe it is by the motto “social coding”.

So far my contributions have been limited to Gists, so no repository hacking yet (although technically a gist has its own little repository). What I’ve posted are basically old Python code snippets that I found laying around on my usb hd from back in the day. That’s “old” with a capital O.  Nothing close to profound, elegant, or significant.   If there was such a category, it would probably be filed as Ancient Throw-Away Code Snippets That Nobody Will Care About.

Here they are:

gist: 866208 A Demonstration of how to use a wxPython “Notebook” with panels (WARNING: old code)

gist: 862171 An incomplete experiment with building calendar functionality with the Python icalendar module

gist: 862159 Old code generating txt list of contents of a collection of zip files — shows zipfile module

gist: 861061 Some throwaway code I used to demonstrate the IDEA cipher with the PyCrypto library

gist: 861057 Some throwaway code I used to demonstrate the RC5 cipher with the PyCrypto library

gist: 861053 Some throwaway code I used to demonstrate the DES3 cipher with the PyCrypto library

gist: 861040 Some throwaway code I used to demonstrate the DES cipher with the PyCrypto library

gist: 861037 Some throwaway code I used to demonstrate the blowfish cipher with the PyCrypto library

gist: 861036 Some throwaway code I used to demonstrate generating hashes with the PyCrypto library

gist: 861011 Python Anagram Fetcher (WARNING: obsolete code)

gist: 860797 SermonAudioParser – A throwaway demo of using UniversalFeedParser to do some basic searches on the SermonAudio.com feed

gist: 866207 A sample Python StringValidator class (warning: OLD CODE)

The Predecessor to Twitter

In an otherwise generally unremarkable piece in the April 2010 issue of Usenix’s login; magazine (pp. 70-71) listing goofy fake protocols, Robert Ferrell has this gem:

Internet Chaff Relay: The short-lived predecessor to Twitter

Old(ish) Computing Memories (1993?-1999)

While the 90′s may seem like a long time ago for some, in the broader perspective, I came to the computing world quite late.

My first computer was a 486 system that my brother gave me some time in the early to mid 1990′s (most likely 1993 or 1994). It was running DOS, Win3.1, and OS/2.  My introduction to computer literacy was mainly driven by my desire to figure out how to run games on the system. I don’t remember all of the games, but two in particular were Spear of Destiny (a spin-off of of the shooter Wolfenstein) and NHL 93 (and EA Sports hockey game).  With this motivation to  learn about the computer, I quickly picked up new things.

On the grand scale of computing history, this was before e-mail caught up with postal mail in volume,  right around when Red Hat Linux was introduced, right around when  Mosaic released their web browser, and a few years before Apple had a product called “Mac OS”.

It wasn’t too long before I was introduced to the more social aspects of the computing subculture. A friend introduced me to the concept of Bulletin Board Systems (BBS) and I quickly became hooked to that too.  The best way to describe the BBS scene is perhaps as a localized Internet. A BBS was a little system that someone would run from their home and you could dial into it. A whole subculture developed. A BBS would usually have functionality to chat, post messages, upload/download files, play games, etc.

Again, I must stress that I was a later-comer on the BBS scene. When I entered it, the BBS scene was probably somewhere slightly past its prime and starting its decline  (or, according to some, already well into it’s decline). My first modem was technically a 2400 baud modem, but that device was so quirky that I never really did  much with it. So very soon I jumped up to a 14.4 modem, which seemed fast at the time but is really unbelievably slow.

I called a bunch of BBS systems, possibly around 100 or more.  Many friendships formed through this medium, although they were probably not completely deep. I was pretty much a regular on the scene until 1999, when the scene had already pretty much died out. Where there were once hundreds of BBS’ in the Windsor area, at that point  there were only 5 or 10. Though I never really ran a full-time BBS, I was quite involved in the scene. I ran a couple of part time BBS’ and was co-sysop (assistant  admin) of at least 3 boards. I was co-sysop of Champagne’s Island, Genesis, and Eternal Dreams. I called many a number of system and was thoroughly immersed in the underground BBS scene.

For those interested, here are some of the BBS’ I called besides the ones that have already been mentioned: The Dynamite BBS, Windsor Footnote, Windsor Download, Czar’s Land, The Beacon, Second Sinister, Windsor ITC, Body Count BBS, The Abyss, Limbo BBS, Purple Haze, The Outhouse, The Kombatant, and The Swamp.

Just as things in the BBS scene began to fade away, I ran a low-resolution (ANSI/ASCII) art group which had five releases (one of which was released in my absence after I disappeared from the scene). There are so many other memories, aspects to this, much of which is probably not very well preserved or accessible. For all the efforts to relive the past, such as the BBS Documentary,  there are still large black holes in the records. Much of this past, even from the early to mid 1990′s, has simply disappeared off the map,  so to speak.  It might be a good thing in some ways, and a bad thing in others ways.  Some of it here will return back here and there, but for the most part it is gone for good. It seems enough hard drives have died or been erased and memories forgotten in order for much of this socio-cultural history to disappear. And anything that is unearthed will be a small sliver of the whole narrative of what went on.

While “cyberspace” certainly has evolved since then, many things for the better, there’s clearly something different now, and, I think, something lost.   But as a whole, I don’t think I’d go backwards if I could. Technological change changes us, and nostalgia aside, we are not the same sort of people that enjoyed in the BBS scene back in the 80′s and 90′s.