You are currently browsing the monthly archive for June 2009.

Working on a project to potentially building a piece of art to put up in my room next year. The idea is this one: with the help of a friend who is better at hardware than myself, some ICs, my Arduino, and lots of patience and soldering, I want to build a 30 inch by 30 inch board with 100 discrete 3 inch by 3 inch “pixels” which are lit by a single RGB LED, that would look something like this, if the LEDs were set to display red, green, blue, repeating:

Each pixel diffuses the light from the LED so that it appears that the whole pixel is lit.

Each pixel diffuses the light from the LED so that it appears that the whole pixel is lit.

Since each LED can display any mix of red, green, and blue, any color is possible within each pixel, so designs can be displayed. It will maintain a USB connection to the computer (although extra power will probably be needed as the Arduino/USB won’t supply enough for 100 bright LEDs) so the computer can run more complex algorithms than the ICs could normally handle, and maybe even be able to display simple visualizations that follow music, fades and sweeps, and any color that I desire to set a certain mood to my room.

Other ideas include Conway’s Game of Life. The board could be mounted on a piece of foam board or plywood, with the elctronics hidden beneath, and the LEDs shining through either translucent acrylic or some sort of cloth, most likely.

Anyway.. mostly I have to keep it cost effective. Ordering LEDs from eBay, I can get 100 RGB LEDs for about $35, which beats DigiKey’s $150-ish for 100, but I still have to find integrated circuits and learn how to do it. Wish me luck :)

(Any suggestions are more than welcome)

Sometimes. And telling when it’s stupid is important to being a good coder, in my opinion.

Maybe I’m wrong. I don’t have a degree yet. But I know that when I write a Python script that I want to rotate the screen on my tablet, I’m not worrying about extensibility or modularity, I just want a small procedural script that does this, this, and this, and then finishes. The faster the better, both in writing the script and in the script’s execution.

So, in beginning work on JORSnix, I decided I’d get my tablet working perfectly first, as a system to model it on. Part of this made rewriting my tablet.rb script that rotated my tablet between landscape and portrait mode in Python. I spent about 20 minutes on it, not counting the time I spent learning that the os module was deprecated and thus learning how to use the subprocess module.

Anyway, the finished product is this:


#!/usr/bin/python
from subprocess import *
import re

p1 = Popen(["xrandr"],stdout=PIPE)
p2 = Popen(["grep", "current"], stdin=p1.stdout, stdout=PIPE)
output = p2.communicate()[0]

current = output[output.find("current "):output.find(", max")]
pattern = re.compile('[0-9]+')

resolution = pattern.findall(current)

if resolution[0] > resolution[1] : #landscape
        Popen("./xrotate"+" 3", shell=True)
        Popen("cellwriter &",shell=True)
        Popen("easystroke &",shell=True)
else : #portrait
        Popen("./xrotate"+" 0", shell=True)
        Popen("pkill cellwriter && pkill easystroke", shell=True)

As you can see, it's pretty simple and straightforward. It's no piece of art, but it does what it needs to do. No more, no less. And it will work on any single-monitored tablet, no matter the resolution, for swapping the screen from portrait to landscape and back.

If it needs to be turned into a couple functions so I can use it in a class, that would work. But that's not what the plan is, at least not yet. But I was told by a friend on IRC that it was unreadable, and wrong simply because my code isn't "modular and extensible" without first examining why it would need to be extended upon. He gave this as the "correct version:"

getting pregnant


#!/usr/bin/python
from subprocess import Popen,PIPE
def bash(c):
	if c.startswith('cd '):
		chdir(''.join(list(c)[3:]))
	else:
		return Popen(c, shell=True, stdout=PIPE).stdout.read().strip()

class Display():
	def getCurrentResolution(self):
		res = bash("xrandr")
		res = res[res.find("current ")+8:res.find(", max")].replace(' ','')
		return (res[:res.find('x')],res[res.find('x')+1:])

	def rotate(self):
		res = getCurrentResolution()
		if res[0] > res[1]: # Landscape Mode
			self.xrotate(3);
			bash('cellwriter &')
			bash('easystroke &')
		else:               # Portrait Mode
			self.xrotate(0)
			bash('killall cellwriter')
			bash('killall easystroke')

	def xrotate(self, mode):
		# unknownmosquito can fill it in from here

class Wacom(Display):
	def getStylusMode(self):
		return bash('xsetwacom get stylus Mode')

display = Wacom()
display.rotate()

Besides going into the fact that the "better version" would no longer use regular expressions (and thus would be less resilient to oddly shaped displays), it aliases Popen to bash for "readability." Overall, being accused of using procedural programming for a systems script in a language like Python (which allows you to do this for a reason), and to have this given to me as a "correction," just rubs me the wrong way.

Especially when I'm told that it needs to be done like this to make it more "readable."
Object Oriented Programming is wonderful. Unless using it is just wasting time.

Note: If it becomes necessary to integrate this script into a larger part, obviously it will get OOP'd. But for now, it'll remain a script.

The thing that blows my mind is that Capitalism, as it existed in it’s as-pure-as-it’s-ever-been state from the late 1700s until the mid 1900s in the United States, as it has existed nowhere else and as it exists still to the fullest extent here, although we’ve come a long way from anything resembling capitalism since Teddy Roosevelt, is ridiculed as being a failure by some blogs that I stumble upon, saying:

Capitalism is rightly credited with having unleashed enormous forces of productivity and technology. But it has also reduced much of the world to ruin and squalor. After four centuries of triumph as the dominant mode of global development, capitalism has furnished for itself a world in which one out of two human beings lives on $2 per day or less, and more than one in three still lacks access to a toilet. Most children in the world never complete their education, and most will live out their lives without dependable medical care. As the world economic crisis deepens, already deplorable conditions in the Third World will only deteriorate further.

I would like to be the first to point out that what this country has done to become rich has not “reduced much of the world to ruin and squalor,” but has merely left the “ruin and squalor” that was the status quo during the time and made something for ourselves. Due to trade, we dragged Europe (kicking and screaming) and eventually Japan and to some extent China out of their squalor as well; the rest of the world has yet to catch up. We aren’t holding them down. In many cases, it is corrupt individuals in their governments that make situations in the Third World unhelpable to a large extent by any external force. In short: they have to get out of a lot of it themselves. Yes we can, and we do, help, through charity.

But my point is that 200 years ago, no one had access to a toilet. Formal education was for the super rich only, and only for men. When people were poor, they starved. Anywhere in the world. The difference? Now the countries that have embraced capitalism have wealth.

Rich guilt be damned. We have what we have through the sweat of our own brows, and at no cost to others who condemn our way of life. If you’re feeling guilty, give some money to the Red Cross or something.

There is not finite wealth. We are not richer because the Third World is poorer. We are just richer.

Sildenafil Citrate

I’m starting a new project. What is JORSnix, you ask? It’s Linux for Tablet PCs. Windows has the monopoly on Tablet PCs, and that sucks, because besides that, Linux is wonderful for students. And so are tablets.

For those of you who don’t follow my blog, I own a Lenovo X61 Tablet. It’s my pride and joy, and I take it everywhere. It weighs under four pounds, has excellent battery life (or.. well.. used to..), and of course it’s also a tablet, so I can take notes in class on it.

So what is JORSnix going to be? It’s going to be based on Ubuntu, and loosely modelled around their release schedule. If they do something that screws up tablet support for a release, we’ll notify our users and skip it.

In short: we’re going to make it easy for you to use your tablet efficiently with Linux. That’s the goal, anyway.

We plan on packaging a lightweight system with Gnome (maybe one of the *box WMs later), Xournal, CellWriter, EasyStroke, and wacom-tools. We’ll make all of the buttons work and make your laptop usable in Tablet Mode without a keyboard.

But for now, we’re just going to support Lenovo X61 Tablets because that’s all we have, but hopefully it will work on other tablets with little tweaking. Both HP and Fujitsu use similar Wacom backends, so if I don’t do anything too Lenovo-specific, it’ll be OK. Anyway. This is the birth of something good. If you read this and you’re willing to test, especially if you have a different tablet than me, please, please contact me.

Short post; I just wanted to share this with the internets because I couldn’t find the information out there.

I just bought a BBP Laptop Bag for my tablet from http://www.bbpbags.com/clearance.html.

I got the Extra Small Hamptons Bag, and as you can see, it’s on clearance as of this writing for $35. The important info is that the X61 Tablet fits in the bag with the extended battery. It’s a tight fit, and the first time I put it in I had trouble zipping it up, but it’s just perfect so that after the initial fabric stretch it’s not any problem, and I don’t have to worry about the computer bumping around inside the bag (as I did with my old bag).

So far I’m really satisfied with the build of the bag, and the fact that my laptop fits perfectly is a big bonus. Of course, they are on clearance, so grab one while you still can, X61 Tablet owners! (I bet the X200 & X200 Tablet fit also, as the X61 non-tablet also probably fits, as the snug fit is in the height, not the width, of the computer)

Ironically I’m going to post again so soon after my “I’m not posting during the summer” post, but I got a bug and designed a single-page portfolio for my friend Luis. I thought to myself, “There should be a simple introduction to his work that he shouldn’t be afraid to put on a business card.” And he seemed to like it until it was almost done, and then started asking for things like tabs with more content.. but I feel like his blog is for that. So I finished it as I saw fit and told him he may do with it what he pleases. It is his domain, after all.

But for now, it is quite a masterpiece, if I do say so myself. I am very proud of it, and I find it very aesthetically pleasing, and straight and to the point.

Here is a permanent screen capture, in case he decides it just isn’t for him:

kutsuphoto

The thumbnails are rollovers; when you mouse over, the shading and text are removed so you can see the (still cropped) original image. As of this writing the links don’t even go anywhere, besides the Twitter, email, and blog links at the top, but I suspect if Luis decides to keep the design, he will add links for his work. It is organized the way he wanted it, and it’s his color scheme.

Please keep it, Luis! :(

For my few steady readers, I just want you to know that I’m taking a break from my blog for the summer, for the most part. There might be some exceptions to this rule (such as this writing), but for the most part I am spending much needed quality time with my girlfriend before the long haul of long distance relationship-ing during the school year, and gearing up to starting at a new University.

A new school year, a new school! :)

A new school year, a new school! :)

See everyone in the fall!