Setting up Java in Debian the right way

I’ve been using the OpenJDK, but I had some problems with it: Android Studio and PyCharm are tested with Oracle’s JDK, and as such there are known bugs and crashes with OpenJDK. To fix my instability issues I had to take the hint and switch to Oracle’s. Here’s the official doc for setting this up in Debian:

https://wiki.debian.org/JavaPackage

Following the explanations, I was able to convert Oracle’s tarball to a deb package using make-jpkg, and with the update-alternatives examples I could set the default version to use correctly. (Before this I was setting JAVA_HOME and PATH by hand, which is dirty, don’t do it.)

Overriding TMPDIR when you don’t have enough space on /tmp

Sometimes you might not have enough disk space on the /tmp directory but need it badly. For example when creating a deb package from a Java tarball in Debian using make-jpkg, there’s no command line parameter or any other apparent means to specify an alternative working directory for temporary files.

Check-mate? Luckily, no! I could force a different directory using the TMPDIR environment variable like this:

TMPDIR=/some/where make-jpkg  jdk-7u45-linux-x64.tar.gz

Solaris got goood (version 5.11)

Looking through my old drafts in this blog, posts I never published, I found this piece.


I recently installed the new OpenSolaris, version 5.11, released in 2008 December, I think. From the live CD. On my laptop. Earlier versions used to be quite painful, and I would definitely not consider putting on a laptop. (Ah, that’s a lie. I did actually install 5.10 on my ThinkPad X31…)

5.10 used to require a LOT of disk space. I remember failed installations on a virtual machine with a 10G virtual disk, running out of space. The new 5.11 system installed from the Live CD is only 2.4G now, much better!

But enough talking, let’s get to technical stuff. What compelled me to post this entry is the ease at which I could do things that used to be difficult, such as:

  1. Setup sudo. In the past I had to install sudo and visudo myself. Now, they are included in the system by default.
  2. Install vim. This used to be tricky too, now it’s installed by default, with all the modern features such as syntax highlighting. Oh joy.
  3. Setup sudoers. In the default configuration users in group “wheel” can execute all commands. Solaris doesn’t have a group called “wheel”, but it has a group called “staff” with GID 10, which is the usual GID for “wheel”. After making this change I was going to add my user to this group, but then, I found it was already member of this group, which makes perfect sense, as this is the first user I created during installation.

And so on and so on. These are little things, but it’s great to see real UNIX systems becoming free and so much more usable than in the past.


I don’t know why I didn’t post, back in 2009. I guess I wanted to write more cool things. I’m posting now, because it made me want to install OpenSolaris again :-)

Disabling access to Facebook

Here’s a little tip for the not-so-tech-savvy, because it’s important.

Facebook tracks the websites you visit even if you don’t click on Like buttons. When a Like button is loaded, it executes code on facebook.com, sending your IP address, the website you are on, among other things. There is a way to switch this off effectively, by telling your computer the wrong address of facebook.com, so that your browser and any other processes will never find Facebook, and thus will never send any information to Facebook. You can do this by overriding the address of facebook.com in the so-called hosts file on your computer.

Press the windows key + r to run this command:

notepad %systemroot%\system32\drivers\etc\hosts

This opens the hosts file on your system in notepad, a plain text editor. Append this line to end of the file:

127.0.0.1 facebook.com www.facebook.com connect.facebook.net

Once this is done, Facebook, and its Like buttons will stop working, because your browser will not find Facebook. If you want to re-enable Facebook, edit the file again and either remove this line, or prefix it with a # sign to make it ignored.

Adding udev rules for USB debugging Android devices

USB debugging of my Google Nexus 4 phone used to work just fine from my Debian desktop. Until someday it just stopped working. The symptoms looked like this:

$ adb logcat
- waiting for device -
^C
$ adb devices
List of devices attached 
???????????? no permissions

That is, adb logcat was just waiting forever even though my phone was connected, and adb devices was giving permission errors. There was no easy answer on stackoverflow, but lots of clumsy ones, suggesting to make the adb binary setuid, or adding udev rules with 0666 permissions. I really had to get to the bottom of this myself.

These are the steps to properly debug, understand and resolve the issue.

1. Find the bus and device id assigned by the kernel:

$ lsusb 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 002: ID 045e:0053 Microsoft Corp. Optical Mouse
Bus 004 Device 003: ID 0566:3002 Monterey International Corp. 
Bus 001 Device 008: ID 18d1:d002 Google Inc.

I bought my device from Google, so it’s probably the last one.

2. Check the permissions of the device file

$ ls -l /dev/bus/usb/001/008
crw-rw-r-T 1 root root 189, 8 Nov 10 18:34 /dev/bus/usb/001/008

The path comes from the output of lsusb: 001 is the Bus, and 008 is the Device.

The problem is clear: the file is owned by user root and group root, which I am neither. The elegant solution is to add a udev rule so that the device will belong to a reasonable group, like plugdev, of which I’m a member.

3. Create a udev rules file, let’s say: /etc/udev/rules.d/51-android.rules

SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="d002", MODE="0660", 
GROUP="plugdev", SYMLINK+="android%n"

Here, idVendor and idProduct come from the output of lsusb: 18d1:d002. Do similarly for your own device. The rule specifies that a matching USB device should be created with permissions 0660, with group plugdev, and a symlink conveniently pointing to it.

Now that everything is ready, simply plug the device out and back in to confirm the result:

$ lsusb | grep oogle
Bus 001 Device 010: ID 18d1:d002 Google Inc. 
$ ls -l /dev/bus/usb/001/010
crw-rw-r-T 1 root plugdev 189, 9 Nov 10 18:37 /dev/bus/usb/001/010
$ ls -l /dev/android7
lrwxrwxrwx 1 root root 15 Nov 10 18:37 /dev/android7 -> bus/usb/001/010
$ adb devices
List of devices attached 
01d1e2510d9c6d28 device

PS: no need to restart udev, the changed rule should be picked up automatically.

Adding all unknown files in a Subversion checkout

Adding all unknown files in a working tree is usually very simple in other version control systems, for example:

git add .
bzr add

Not so simple in Subversion:

$ svn add .
svn: warning: '.' is already under version control

But if you add the --force flag, that will do!

Keep in mind that this is not the same as:

svn add * --force

That would add not only unknown files, but ignored files too, which is usually not you want. Make sure to specify directories explicitly, avoid using * with this command.

Released new version of Wine Notes on Android

The new version (1.1) of Wine Notes is now on Google Play.android

What’s new?

  • Fixed the broken EURO sign
  • Now you can select the currency
  • The last used currency becomes the default currency
  • Wine names you enter are now automatically “title-ized”
  • Changed to a bright theme in most dialog screens
  • Replaced the text buttons with image buttons in tag editor dialogs
  • Removed the pointless Quit menu option
  • Many minor usability and ergonomic improvements

Check it out, and I hope you’ll enjoy!

Feel free to tell me about problems and feature requests on GitHub: https://github.com/janosgyerik/WineNotes/issues

This app is still a work in progress, with many more features planned but not implemented yet. If a missing feature is important to you, feel free to drop me a line, and I’ll try to make it happen.

Added voting and other improvements on bashoneliners.com

I took my time, but finally here are a bunch of improvements I just released on bashoneliners.com, check it out!

Now you can upvote or downvote one-liners using the familiar interface of stackoverflow.com:

voting

And since now that there are votes, it’s natural to sort one-liners not only by date, but by votes too. So I changed the one-liner listing pages to switch between different ordering using a tabbed user interface:

tabbed-oneliners2

Speaking of tabs, the profile page was quite awful, with too much information cluttered on a single page. So I broke that into multiple pages, again using a tabbed user interface:

tabbed-profile

There are many other, smaller improvements since the last time. I’ll let you discover those by yourselves.

The voting feature is only the beginning. Just one of the essential steps for full-blown gamification. I’m pretty sure I won’t be able to do this all alone though, so I hope to find partners soon.

Finally, I revised all the texts on the site. Take a look, and note the strong emphasis on the educational aspect. The site is about high quality and well-explained bash one-liners. Not just any random ugly scripting hacks. I want all those one-liners there to be perfectly written, and nicely explained so everybody can understand them, and learn something useful.

If you have a scripting question, the best place to go is probably unix.stackexchange.com and stackoverflow.com. I love those sites. But you know what, they don’t encourage perfect answers. They don’t encourage combining multiple good answers into a single great answer. That’s the void I’d like to fill. That’s the direction I’d like this project to evolve into.

Released Computer Quiz on Android

androidI just released the first version of Computer Quiz. It’s a simple multiple choice quiz app for computer fans, professionals and geeks.

Questions are spread out over multiple categories and difficulty levels:

  • Hobbyist level: 100 questions
  • Professional level: 106 questions

There are different “game” modes, such as “score as you go”, “sudden death” and “score in the end”. You can change the number of questions per game in the settings menu.

The app doesn’t require any permissions at all, doesn’t use internet, doesn’t collect data about you and has no advertisements. I intend to keep it that way.

At the same time I also upgraded the Programming Quiz. Both apps have exactly the same features, but different database of questions, with some inevitable overlap. The questions in the Programming Quiz are designed specifically for professional and aspiring programmers, while the Computer Quiz can be interesting for casual computer fans too.

If you like these apps, please remember to rate, +1, tweet, or review them, and spread the word. Thank you!

You can report problems and feature requests on this page: https://github.com/janosgyerik/manyquiz/issues

How to enable developer options on Android Nexus 4

I spent a couple of long minutes looking for the developer menu on my shiny new Nexus 4. I was looking for the options normally called USB debugging and Stay awake, normally under Applications / Development. I could not find them anywhere on this otherwise beautiful piece. Strangely, the menu is disabled by default. You can enable by following these steps:

  • Open your phone settings—swipe down on the phone, click on the button in the top-right corner, click Settings
  • Click About phone, it’s at the bottom
  • Click on Build number, 7 times (!!!), it’s at the bottom

What the hell… Who would have known? After this the Developer options menu becomes available, right next About phone.

I found the tip here:

http://www.redmondpie.com/enable-developer-options-in-android-4.2-on-nexus-4-and-galaxy-nexus/