Wednesday, October 28, 2009

Clever Qrulrs Code

I'm proud of this, so I thought I'd share it...it's very simple, just calls out to two different web services to create a QR Code from a URL:


public Qrurls()
{
createBitlyURL("http://cmarnold2.iweb.bsu.edu");
createQRCode();

}

private void createBitlyURL(String longURL)
{
String URL = "http://api.bit.ly/shorten?version=2.0.1&longUrl=" + longURL + "&login=" + bitlyAPIUsername + "&apiKey=" + bitlyAPIKey;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream resStreamLocal = response.GetResponseStream();
string tempString = null;

if (null != response)
{
resStreamLocal = response.GetResponseStream();
StreamReader sr = new StreamReader(resStreamLocal);
string str;
while ((str = sr.ReadLine()) != null)
{
if (str.Contains("shortUrl"))
tempString = str;
else
continue;
}
response.Close();
}
else
{
throw new Exception("Something is wrong!");
}

if (tempString != null)
bitlyURL = tempString.Substring(tempString.IndexOf("http://bit.ly"), 20);
}

private void createQRCode()
{
String URL = "http://chart.apis.google.com/chart?cht=qr&chs=100x100&chl=" + bitlyURL;

WebClient wc = new WebClient();
byte[] data =
wc.DownloadData(URL);

PngBitmapDecoder decoder = new PngBitmapDecoder(new MemoryStream(data), BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
BitmapSource bitmapSource = decoder.Frames[0];

// Draw the Image
myImage = new System.Windows.Controls.Image();
myImage.Source = bitmapSource;
myImage.Stretch = Stretch.None;

}


It's being used in our Surface application for the iDMAa 2009 Conference. Obviously not the most complex code I've written by a long shot, but it didn't take much time and was extremely useful, since QR Codes are getting more common.

Monday, October 26, 2009

Just so you can all feel my pain...

My Surface project is becoming littered with code that looks like this:


presContent.Background = System.Windows.Media.Brushes.Transparent;
presContent.Foreground = System.Windows.Media.Brushes.White;


and this:


System.Windows.Controls.Image authorImage = new System.Windows.Controls.Image();


I spent around 10+ minutes just now making these "ambiguous references" unambiguous in this manner. There are a few major issues with this, besides the waste of time.

1) The "Intellisense" that everyone jizzes themselves over with Visual Studio is not very intelligent.

2) Why can't it tell that, when the variable is a System.whatever.fuckmicrosoft, that the constructor should also be of this type. What's the point of even having static typing if it can't tell that.

It's obvious these tools were very poorly designed with very little forethought...I shudder to think this was done with full knowledge and not on accident, but it's almost too prolific to not be otherwise. I only complain because it's making my life very very hard. This project has gotten rather large and the last thing I need to worry about is the jackass compiler complaining it can't tell which 10 word namespace this data type is actually in, and could I please write out all 10 words, which makes the "using" keyword ESPECIALLY useful.

In other news, we're at over 300 commits on the project, with 2 weeks left before shipping! :D

Tuesday, October 20, 2009

Struggles in Seminar

I'm taking a 600-level Art seminar class, mainly because I have experience with the Surface, and my boss is in charge of it, and the professor I'm doing my other Surface project with is teaching it. We're in week 9 and we haven't really started coding yet...this makes me extremely nervous, since I'm taking 2 other classes on top of doing a 699. The crux of our problems have been this stupid GUI design...how do you design a cool, interactive GUI for a piece of hardware that is relatively new, and all the other applications for it are photo viewers, for an art museum that doesn't just want a photo viewer, because the photos would just be showing the stuff they have hanging on their walls? Answer: very carefully (ba-boom-ching!)

But seriously, this Surface may be intended for "collaboration", but the reality is far from that. The problem of designing a deep, interesting interface for what essentially amounts to a huge table that sees your fingers is no trivial task...and it hasn't been studied for years like a traditional GUI. It's really difficult to communicate the nuances, but here goes:

1) The Surface is both smaller than you'd expect, has less RAM than you'd like, and is rectangle, which, not matter how collaborative your app is, will force certain people into a driving position and others into a watching position. The Surface can only comfortably be surrounded by, maybe, 6 people total, but that's not nearly enough room for everyone to have their own "interaction space". Plus, it gets really cluttered REALLY REALLY fast.

2) You have two options: design the GUI in a way that allows for each person to have their own, isolated interactions, or somehow try to design it in a way that everyone can interact together. Each approach has it's own problem; the isolated interactions can be much deeper, but it's not collaborative, while the collaborative design can only be so deep, otherwise one person can ruin it for everyone.

Honestly, I would just love to see a design that can have the cake and eat it too...be both deeply immersive for everyone involved while still being collaborative. I don't know if this is just due to my own brain being used to a specific way of doing things, but I feel like this is an impossible task for computers...they are necessarily a single-person experience. The fantastic thing about online games is that they can simulate a deep, collaborative experience, but you're still interacting with it through a single-user machine.

This brings up an interesting point though...in many multi-player games, collaboration is necessary to complete a task. Sure, two people aren't controlling the same character, but their collaboration facilitates the common goal...that collaboration is always extremely deep and nuanced. Unfortunately, I can't figure out a great way to apply this to the Surface without involving multiple terminals attached to it, or by making a ridiculously complex game. This thought has really intrigued me, though, so I may follow up later.

Wednesday, October 14, 2009

CCSC:MidWIC and Thoughts on Women in Computing

This past weekend I presented a poster at MidWIC, the Midwestern Women in Computing Conference. This was both an extremely frustrating and fairly interesting experience, and got me pondering the whole "women in computing" issue. I felt like the conference not only missed the point of why women are such a minority in CS, but actually brilliantly illustrated the problem: we were placed in a small, cramped building away from the main building with all the food and keynotes (where CCSC was taking place), presented posters more or less only to each other, were given lipstick in the swag bags, and had a social dance at the end of the first day...the organizers were obviously under the impression we were all 9 years old.

However, that brings up an interesting issue. Women are most certainly a minority in Computer Science, but how do you not only encourage more women to join, but also promote them in a way that doesn't come off as condescending? So much of this is a major cultural problem that isn't going to be solved overnight. And by intentionally trying to promote one group you're doing the very thing that no one really wants: singling out a group of people based on their gender rather than their common interest in computer science, and thereby creating a very delicate dilemma. I want women to be promoted, in a sense, but only in the sense that, if I were to go to a general computer science conference, where everyone is attending due to nothing more than a deep interest in computer science, I will be taken as seriously as everyone else and I'll find as many women being taken seriously as men. So at that point I'm not even being promoted as a woman anymore, just as someone who loves computer science and has some knowledge about it, and therein is the catch-22.

However, that leads to another question...should we even bother promoting women in CS to each other? We're already women in CS, it's too late to make us be any more "into" CS. The challenge is to get teenaged girls interested in Computer Science, and plant the idea in their heads to check it out when they get to college. That requires mentoring programs (as well as a massive cultural overhaul, but again, that will take years at best) where women not only show their younger counterparts that they can do CS, but that they can be as good at it as anyone else. This is a challenge, especially for less well-funded schools, but it's a massive step in the right direction.

None of this is original, I'm sure, but if nothing else it helped illustrate in my own mind the problems being faced right now.

Saturday, July 25, 2009

Slackware Day 2: Configuration and New Packages

So now I had a fresh Slackware install on my Eee...what next? The first task I accomplished was fixing a problem with the tutorial I followed: it only had you install packages from the first install CD, but I wanted packages from ALL the install CDs. Fortunately, this is easy sauce.

Go to any of the FTP Slackware mirrors and navigate to the slackware folder, which has all the software packages. Since the ones I had installed from the ISOs needed to be updated anyway, I just copied all of them into my local slackware folder. I then mounted the hard drive on my Slack system, and navigated to the package collection I wanted to install, and ran:

#installpkg *

This will install everything in the folder.

**
Important note: You'll notice MOST of the packages have the extension .txz. If you have an older version of pkgtools, Slackware won't know what to do with these. A good way to handle this is to download the .tgz packages of tar, gzip, pkgtool, and xz, install those using installpkg, and then install everything else.
**

Finally, not only do we have a great base system, but X is installed! I chose to not install the KDE or KDEI packages, my window manger of choice is xmonad, so I'll go through the steps to install that. :) However, if you installed the XAP packages, you should have at least fluxbox, blackbox, xfce4, and a few others, so you're more or less in business!

Before configuring X, make sure to add a user. All the previous actions needed to be done as root, but X has lots of user-specific configuration, so if you haven't done that already, get it out of the way.

Finally, to configure X:

#xorgsetup


That should be it! To choose your initial window manager, run:

$xwmconfig


Running startx should drop you into whatever you chose! Further, more fine-tuned X configuration is usually done in the /etc/X11/xorg.conf; configuration for your personal X session (as a user) is done in .xinitrc.

Bonus task: Installing Xmonad
Xmonad is my favorite wm, especially on my netbook. It's fast, clean, minimal, and relies very heavily on the keyboard. Another good one is ratpoison, but I use xmonad for my day-to-day :)

To install, go to the Xmonad site, downloads, and slackware. All the packages you need to install xmonad on your system are right there (there's not many of them!). Download them all into a folder (I called mine xmonad), navigate into the folder, and run

#installpkg *


After that has finished, open up .xinitrc (it should have been created after you ran xwmsetup).
Where it says:

exec /usr/bin/startflux

or something similar, replace it with:

exec xmonad


Done! Exit out, start X again, and enjoy Xmonad :)

That's pretty much the extent of my Slackware-installation posts, I've managed to get the full system running quite a bit faster than my first time. Any subsequent posts will more than likely deal with getting wireless up and running, though compared to the first time I tried, it should be significantly easier...the 2.6 kernel has the best wireless drivers built-in already! I hope people find this helpful, or even a little interesting...thanks for reading!

Friday, July 24, 2009

Slackware Day 1: Installation

Of course, the first step before doing ANYTHING is to back up my laptop...don't want to lose anything important!

While waiting for the files to back up, I needed to create a boot disk on my USB (Eee's don't have a disk drive :P). According to the step-by-step I referenced in the last post, I needed to perform a dd to get the usbboot.img I downloaded from the Slackware site onto my flash drive.

I got the device ID for the flash drive by running the command:

sudo fdisk -l


This is crucial...the last time I assumed I knew what the device ID was, I borked my entire system (side note: if you find yourself thinking "this is taking a really long time", you borked your system). Fdisk says that my USB is /dev/sdb1, so my dd command would be:

dd if=usbboot.img of=/dev/sdb1 bs=512


That resulted in:

54504+0 records in
54504+0 records out
27906048 bytes (28 MB) copied, 1.26218 s, 22.1 MB/s


Perfect!

**
Important edit: this will only install the very basic packages. My next post discusses how to get *all* the packages later, including updates, but at this step it would be easier to not bother with the ISOs at all, and go to any of the ftp sites offering slack packages. There should be a slackware folder in slackware-current with all the package groups; download them into your slackware folder. This way, you get everything, and it's all up-to-date.
**
Next step: getting an ISO of the install disk 1, mounting, and copying the slackware/ directory to another USB drive. I installed gmountiso (recommended by The Ubuntu Geek, a fantastic Ubuntu help-page), mounted the ISO, and copied the /slackware folder (with all the packages) onto an external hard drive.

Finally, booting and installing! Following the instructions on the website, I managed to get the system and packages installed without a hitch. I didn't manage to get LILO installed immediately, but I was able to boot successfully into my new system using the following commands in the GRUB prompt:

grub> root (hd0,0)
grub> kernel (hd0,0)/boot/vmlinuz root=/dev/hda1
grub> boot


And now for the real work, next time: configuration and installing new packages!

Wednesday, July 22, 2009

And Moving Back to Slackware...

I change Linux distros more often than I change underware. It's always for different reasons, but the result is always the same...I get to spend time setting up a brand new system, working out all the little hiccups, until it's running smooth as silk. Today is Part 1 of my decent into madness: The Migration Back To Slackware.

Slackware was my very first Linux distro. Before I even really understood was Linux even was. I ruined about 10 CDs trying to get the iso images to burn correctly because I was using Windows, and that shit is hard! Finally...Slackware was mine. I spent the next few years or so just learning how to manipulate the most basic functionality, culminating in my finest achievement, learning how to successfully compile my own kernel. But really, the furthest I got was building a usable desktop environment. Sure, this is a success in and of itself, but it left huge gaps in my knowledge that other, gentler Linux distros slowly filled. When my friend recommended Arch to me, I was very excited, since it's basically Slackware with package management. Package management eventually became my friend after I worked with Debian (which probably directly influenced my move to Ubuntu as my primary desktop).

Recently, though, I've been dreaming of Slackware again. I think it's finally time to come back to my first toy distro, and see how much I've REALLY learned after all these years.

Resources to start:
How To Install Slackware On The Eee
The Main Slackware Page