Archive for the ‘ Help ’ Category

Dual Monitor Aero Snap in Ubuntu

I think the coolest thing about Windows 7 is Aero Snap. It really helps you get more efficient use of your screen real estate without you have to manually resize your windows. The good people at OMG! Ubuntu posted a great tutorial on how to get Aero Snap in Ubuntu. I followed the tutorial and got my laptop snapping perfectly. I was not so lucky on my dual monitor desktop. So I have modified the script slightly to make it so it will now work on dual screen monitors. Most of this is exactly the same as the OMG! Ubuntu tutorial, so if you feel I didn't explain something clearly you should reference theirs.

Step 1 - Install Compiz Config

 
sudo apt-get install compizconfig-settings-manager wmctrl
 

Step 2 - Set up the commands

  • Open the Compiz Config manager (System -> preferences -> CompizConfig Settings Manager)
  • Select the "Commands" option
  • In "Command Line 0" past:
 
WIDTH=`xdpyinfo | grep 'dimensions:' | cut -f 2 -d ':' | cut -f 1 -d 'x'` && HALF=$(($WIDTH/4)) && wmctrl -r :ACTIVE: -b add,maximized_vert && wmctrl -r :ACTIVE: -e 0,0,0,$HALF,-1
 
  • In "Command Line 1" past:
 
WIDTH=`xdpyinfo | grep 'dimensions:' | cut -f 2 -d ':' | cut -f 1 -d 'x'` && HALF=$(($WIDTH/4)) && LOCATION=$(($WIDTH-$HALF)) && wmctrl -r :ACTIVE: -b add,maximized_vert && wmctrl -r :ACTIVE: -e 0,$LOCATION,0,$HALF,-1
 
  • In "Command Line 2" past:
 
wmctrl -r :ACTIVE: -b add,maximized_vert,maximized_horz
 

Step 3 - Enable the commands
Go to the 'Edge Bindings' tab and set the following:

  • Run Command 0 - Set to Left
  • Run Command 1 - Set to Right
  • Run Command 2 - Set to Top

Good luck, let me know if you have any questions.

in_addr to string(char*)

The other day I needed to turn a IPv4 address to a string in C. I figured some others would find it useful:

 
char* hexToCharIP(struct in_addr addrIP)
{
  char* ip;
  unsigned int intIP;
  memcpy(&intIP, &addrIP,sizeof(unsigned int));
  int a = (intIP >> 24) & 0xFF;
  int b = (intIP >> 16) & 0xFF;
  int c = (intIP >> <img src='http://www.coryhardman.com/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /> & 0xFF;
  int d = intIP & 0xFF;
  if((ip = (char*)malloc(16*sizeof(char))) == NULL)
  {
    return NULL;
  }
  sprintf(ip, "%d.%d.%d.%d", d,c,b,a);
  return ip;
}
 

Syncing Music to Nexus One in Ubuntu 10.04

Ubuntu 10.04 has really improved over previous versions of Ubuntu in the syncing to devices support. In particular support for syncing music to IPhones and ITouches. They have also added support to Rhythmbox to reconize when a Nexus One has been connected to the machine (this may also work on other Android devices, I've just not tested others).

When you plug your phone into your Ubuntu 10.04 box, on your Nexus One an alert will appear asking you if you'd like to enable USB storage. Once you have enabled this, the Ubuntu system will see the phone has a USB mass storage device. Now you should be able to download all of your pictures and in Rhythmbox the phone appear on the device list. You can just drag and drop your music like you would for a playlist.

Since Ubuntu is treating the phone as a mass storage device, Rhytmbox does not know by default where to upload the music. So it defaults to the root of the SD card. If you would like to not fill the root up with all of your music you can opt to put all of your music into a music folder. To do this, you need to upload one song to the Nexus One, then open up the device in a file manager. Create a new directory called "music" and move the one song you uploaded to that folder. Now Rhythmbox will be smart enough to know to upload to the "music" folder and all the media applications on the Nexus One will auto detect the music in the "music" folder.

If you are looking for a good music player I have become a big fan of DoubleTwist. Plus if you are on Windows or a Mac you can use the DoubleTwist desktop client to manage music on the phone.

OpenVPN in Windows 7

I often need to work remotely from work, luckily my work has a VPN server that allows me to get access to the companies internal resources. I have been using OpenVPN in Windows XP for a long time to do this, through the use of OpenVPN GUI. Well when I got a new laptop it came with Windows 7 installed. So one of the first things I did was set up my development environment which required me to get into some of the file shares inside of my companies network. I thought it wouldn't be a problem at all to do, I installed OpenVPN GUI and just copied over my configuration and key files. When I went to connect I got quite an interesting error:

Thu Jul 08 23:05:33 2010 ROUTE: route addition failed using CreateIpForwardEntry: One or more arguments are not correct.   [if_index=16]
It turns out to be very simple to fix. In Windows 7 and I believe in Vista you need to do a few extra steps to get OpenVPN GUI to work with Windows 7. First you need to go C:\Program Files\OpenVPN\Bin and make sure openvpn-gui.exe is always started as Administrator (in the compatibility menu of the file properties). Then you will need to edit your configuration file and add two lines after the line that describes your cipher:
route-method exe
route-delay 2
That should do it. Let me know if you have any questions.

Nexus One Support in Ubuntu 10.04

I recently purchased the Nexus One from Google. It is quite an amazing phone and I've been really happy with it. I've taken interest in developing for the Android platform now that I have one. Luckily Google has provided a very good resource for Android app development at http://developer.android.com/.

Today I was working on allowing me to upload my applications onto my Nexus One so that I could test the software on a real device. Well I ran into an issue after following Google's tutorial on how to do it located here. I run Ubuntu 10.04 on my main development machine and so I followed the instructs for how to do it for Linux. Well when I got to the end of the tutorial when it tells you to test your the setup with the following command:

adb devices

I got the following output:

List of devices attached
???????????? no permissions
It turns out that Google's instructions have not been updated so reflect how to get the Nexus One to work under Linux. Well after a bit of research I came across the following blog post that explained it. Basically the list of USB Vendor IDs does not have listed the proper value for the Nexus One. I had selected to use HTC's Vendor ID ("0bb4") being that the Nexus One is actually produced by HTC, however that is incorrect. Instead you need to use the Vendor ID of "18d1". So the following line should be in /etc/udev/rules.d/51-android.rules
SUBSYSTEM=="usb", SYSFS{idVendor}=="18d1", MODE="0666"
NOTE: Be sure not to capitalize the D in 18d1, doing this will cause this solution not to work.
Now that you have added that line to the file, you will simply need to restart udev. With the Nexus One unplugged from your system run this command:
sudo service udev restart
Now you can plug in your Nexus One and run:
adb devices
You should see something like this:
List of devices attached
???????????????? device
I hope this helps and post below if you need any further help.