» Archive for the 'Uncategorized' Category

Buffered text in dvtm

Friday, September 10th, 2010 by Niki

I love dvtm. I do a lot of development over ssh these days and having an application handle multiple terminals is practically a necessity. At first I was using gnu screen, however I found it a little cumbersome to use for my purposes. gnu screen doesn’t have many layout options – you are either looking at one terminal or several terminals arranged in a single stack. Switching between these is annoying as well. dvtm on the other hand has several different layouts and makes it easy to switch between them.

Gnu screen, however, does have several features that dvtm does not. For example, with screen you can detach from the controlling terminal and reattach later. Fortunately dtach takes care of that and it’s easy to run dvtm inside dtach. Another great feature of gnu screen is that it reflows text – when you resize the terminal screen will automatically word wrap the text. dvtm doesn’t do this and I haven’t found any unix shell that does this either. What’s worse is that dvtm will cut off the text when a terminal is made smaller and that text is gone – even if you later restore that terminal to its original size.

Reflowing is a fairly non-trivial thing to do so I opted for the next best thing – making sure that dvtm doesn’t permanently cut off the text. This actually turned out to be fairly easy – dvtm keeps a character array for each row in each terminal. This array is realloced every time a terminal is resized. When a terminal decreases in size, the arrays are realloced so they are smaller. I simply changed the behavior so that they arrays are only realloced when a terminal increases in size such that it’s larger than the previous largest. This means that dvtm’s memory usage is potentially greater, but it also means that it makes fewer memory allocations.

You can find my patch on the dvtm project page.

dwm and dvtm patches

Wednesday, June 2nd, 2010 by Niki

A new version of dwm has been released so I have updated the Fibonacci spiral patch. I’m still working on the movestack patch. The updated dwm patch can be found here. I have also created a Fibonacci layout patch for dvtm – the dynamic virtual terminal manager. The dvtm patch can be found here.

Signing Android applications

Saturday, May 15th, 2010 by Niki

In order to install an Android Application onto the emulator or the phone you must first cryptographically sign it. When you do a debug build (using “ant debug”) ant will automatically sign the binary with an auto-generated debug key.

This key is set to expire 365 days after it was auto-generated (the first time you did a debug build). If a debug build fails due to an expired key, you simply need to delete the current debug key and a new one will be auto-generated. To do this, navigate to where the debug key is located and delete it. On Linux and Mac OS X this is ~/.android and the key is the file “debug.keystore”.

Signing your application with a debug key is fine for testing purposes but for release the application should be signed with a unique key that you have generated just for that purpose. If you plan on release the application on the Android Market then the key should also contain correct identifying information (your name or company) and should expire no earlier than October 22, 2033.

To generate a key you need to have the keytool application that come with Java. You need to specify the key-store (the file name), the alias for the key, which algorithm to use (we want RSA) and how long it should be valid for. Let’s create a key stored in the file “release.keystore” with the alias “release” that will be valid for 10,000 days:

niki@redblacktree:~/.android$ keytool -genkey -v -key-store release.keystore -alias release -keyalg RSA -validity 10000

Keytool will then ask you a bunch of questions:

Enter keystore password:
Re-enter new password:
What is your first and last name?
[Unknown]: Niki Yoshiuchi
What is the name of your organizational unit?
[Unknown]: aplusbi
What is the name of your organization?
[Unknown]: aplusbi
What is the name of your City or Locality?
[Unknown]: New York
What is the name of your State or Province?
[Unknown]: NY
What is the two-letter country code for this unit?
[Unknown]: US
Is CN=Niki Yoshiuchi, OU=aplusbi, O=aplusbi, L=New York, ST=NY, C=US correct?
[no]: y

Generating 1,024 bit RSA key pair and self-signed certificate (SHA1withRSA) with a validity of 10,000 days
for: CN=Niki Yoshiuchi, OU=aplusbi, O=aplusbi, L=New York, ST=NY, C=US
Enter key password for
(RETURN if same as keystore password):
[Storing release.keystore]

And you’re done! You’ll notice that I ran keytool out of the ~/.android directory so that release.keystore is located in the same place as debug.keystore.

Now onto signing applications. Let’s go back to our Hello Android project and do a release build:

niki@redblacktree:~/projects/android/hello$ ant release

Once this has finished there should be a new apk located in the bin directory called “HelloAndroid-unsigned.apk”. We need to sign it with the key we created earlier using jarsigner:

niki@redblacktree:~/projects/android/hello$ jarsigner -keystore ~/.android/release.keystore HelloAndroid-unsigned.apk release

And now “HelloAndroid-unsigned.apk” has been signed. It can now be installed using adb.

The pocketknife paradox

Saturday, April 18th, 2009 by Niki

A few months ago I was having a discussion with a few friends of mine and the subject of social awkwardness as it applies to telephone conversations arose. I am in many ways a stereotypical nerd and I am no stranger to social awkwardness. I have grown out of the worst of it, but telephone calls are still difficult for me.

One of my friends could not believe that anyone could have trouble making a phone call or talking to someone on the phone. At the time he worked in tech support and answered phones for a living. It came very naturally to him and he had trouble believing that he had some special skill that made him good at his job.

Eventually I came to realize how his attitude mirrored my own, albeit about entirely different subjects. I often have trouble understanding how some people are unable to understand basic logic or simple math. It’s frustrating to encounter an otherwise intelligent person who barely understand a concept as simple as say, division. There are certain skills that I possess that are “innate” (I don’t know if it’s genetic or environmental but it doesn’t matter either way) and that I take for granted. These skills are so simple for me that I have to fight the temptation to write off as stupid people who have difficulty with the same tasks.

I call this the “pocketknife paradox” – I have a lock-back pocketknife that I typically carry on me. I have observed that somewhere around half (and I believe it to be greater than half) of the people that I have lent it to are unable to figure out how to close it. The mechanism to lock the knife in the open position is so intuitive to me that I forget that many people don’t observe things the same way I do.