Friday 9 March 2012

Java Multipart Upload Code (Android Friendly)



This is a quick function to do a multipart upload of a file in android (and Java in general). It is adapted from Adrian Smith's code here: http://www.17od.com/2010/02/18/multipart-form-upload-on-android/.

 The differences are:
  1. This function will not try to read the file into a string (which imposes size restrictions).
  2. You can pass the content type of the file upon execution
  3. It returns whether or not it was successful and the HTTP response code.
  4. It does not read the response to the upload (if you want to add it back in, the code is in Adrian Smith's page above).

Thursday 5 January 2012

Setting up a second monitor as the primary one in Gnome 3 (Ubuntu 11.10))

Gnome 3 (at least under Ubuntu 11.10) seems to have been shipped with a number of features missing. For example:

  1. No easy way to change the screensaver (follow this: http://www.makeuseof.com/tag/change-screensaver-ubuntu-1110/).
  2. No out-of-the-box way to change the system fonts (you have to use gnome-tweak-tool)
  3. No out-of-the-box way to change the theme settings (follow this: http://www.omgubuntu.co.uk/2011/10/how-to-install-gnome-shell-themes-in-ubuntu-11-10/)
For me, the most annoying one is the lack of a user-friendly way to set any second/external monitor as your primary one (i.e. where the Gnome bar/task bar will appear). 

You can set the orientation of the monitors in the settings, and how you want them aligned but that's about it. Here is a screenshot of the Display settings dialogue: 



Long story short, open a terminal and enter the following:

$xrandr --output VGA-0 --primary

Root is not needed. 
If you don't know how your external port is called (VGA-0 in my case), you can press Tab after the "--output" to see the list of interfaces X recognises. Simply replace VGA-0 with what you see fit.