Sublime Text Color Scheme in Eclipse

If you don’t know about Sublime Text 2 you should click on that link right now. Sublime is by far my favorite GUI text editor (I still love you vi and nano), but when doing Android development it’s impossible to beat the convenience that the Android plugin for Eclipse provides. However, the default color scheme is Eclipse is nothing like that of Sublime’s. Thus, here’s how to get the Sublime color scheme (and a lot more) in Eclipse.

First, install the Eclipse Color Scheme Plugin. Then, in Eclipse, go Window > Preferences > General > Appearance > Color Theme and select the Sublime Text color scheme. If it isn’t already there, you can download it from the Eclipse Color Themes’ website.

And that’s it! Simple.

Ubuntu server 11.10 and Courier-IMAP

My weekend project was to set up an SMTP and IMAP server on my home server so I could finally have my own mail server and be free from the prying eyes of the large email hosts.

Most of this process was relatively simple thanks to this wonderful guide from the Ubuntu help site. However, I ran into one problem: the courier-IMAP server would not accept any connections with the default configuration. A quick look in the mail log revealed:

1
2
3
dovecot: master: Fatal: execv(/usr/lib/dovecot/imap-login) failed: No such file or directory
dovecot: master: Error: service(imap-login): child 7466 returned error 84 (exec() failed)
dovecot: master: Error: service(imap-login): command startup failed, throttling

Lo and behold, /usr/lib/dovecot/imap-login did not exist. Furthermore, locate imap-login returned nothing so I concluded that this binary was no where to be found on my system. However, apt-file search imap-login showed that the package dovecot-imapd provided imap-login. I went ahead to install it to find that courier-imap and dovecot-imapd conflict with one another and apt won’t allow them both to be installed. So, my hack-ish workaround, copy the binaries I needed out of the directory, uninstall dovecot-imap and reinstall courier-imap. For those who just want the “solution”:

1
2
3
4
5
sudo apt-get install dovecot-imapd
cp /usr/lib/dovecot/{imap,imap-login} ~/
sudo apt-get remove dovecot-imapd
sudo apt-get install courier-imap
sudo cp ~/{imap,imap-login} /usr/lib/dovecot/

Obviously, this is not an ideal solution. Most likely, courier will break with a future update since imap-login won’t be updated, but hopefully this dependency problem will be sorted by then.

Android 3.x and 4.x NumberPicker Example

I was working on a new, yet to be released, Android app that necessitated the need for the new NumberPicker widget introduced in Android 3.0. Unfortunately, there are almost no examples of its use floating around and the documentation in the Android API is extremely lacking. Thus, I spent a few hours of trial and error figuring out how it worked.

My goal: Use a NumberPicker to allow a user to select a multiple of 5 in the range 0-100.

First up: The XML.

1
2
3
4
<NumberPicker android:id="@+id/np"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:width="100dip"/>

The XML for our NumberPicker looks very similar to any other Android widget. By default the NumberPicker is set up for displaying two digit numbers, but our last number in this case, 100, is three digits. Hence, the leading 1 in 100 will be cutoff and only 00 is displayed in the NumberPicker. To remedy this, the width is set to 100dip which is wide enough to allow for three digit numbers.

Because of the lack of XML properties for the NumberPicker, we must do all of the configuration for it in code. Speaking of which…

Making the iRobot Create Command Module Play Nicely with Linux

As a club project, the ACM recently bought an iRobot Create. It comes with some software for programming in Windows, but, honestly, the GUI application that it comes with is junk. It barely works at all. Add that with the fact that it’s a Windows application meant that I was on the hunt for making this guy work under Linux.

Well, a quick Google session later and I come across this wonderful Instructable. However, I did have to jump through one more hoop to get it working than was in the guide. Thus, here’s my whole version of getting the iRobot Create’s command module to work in Linux.

Listserv Auto-Subscribe Form

In my never ending quest to make the Penn State ACM’s website as automated and as useful as possible, I wanted a page that allowed a user to enter his name and email and automatically be added to our listserv. With a little HTML, PHP, and a touch of the Drupal API (our website runs on Drupal), it was up and running in a little under an hour. Code incoming.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php

if (isset($_POST["name"])) {
   $name = $_POST["name"];
   $email = $_POST["email"];

   if(mail("listserv@lists.psu.edu", "Listserv Subscription",
            "SUBSCRIBE L-PSU-ACM " . $name, "From: " . $email)) {
      drupal_set_message("Subscribe confirmation sent to " . $email . ". Thanks for signing up!", "status");
   } else {
      drupal_set_message("Error sending subscribe request to " . $email .
                         ". Email webmaster@acm.psu.edu if problem persists.", "error");
   }
}

echo '
<form method="POST" action="">
   <b>Name:</b>
   <input type="text" class="form-text" name="name" size="60" value="" />
   <b>Email:</b>
   <input type="text" class="form-text" name="email" size="60" value="" />

   <input class="form-submit" type="submit" value="Submit"/>
</form>

';
?>

As you can see all it is an HTML form that calls the PHP mail function which sends an email to Penn State’s listserv server on behalf of the user requesting that he be added to our listserv. From there, the ListServ server sends a confirmation email to the user and all that need be done is to click a confirmation link. That’s it! Simple, no?

One note however. I would have preferred to have put the PHP in a separate file in order to keep the HTML and PHP away from one another, but I needed to use the drupal_set_message function meaning it had to be called from within a Drupal node. I’m sure there are ways to call it from outside a Drupal node, but given the scope of this project, this solution works just fine.