Friday, May 24, 2013

Convert an object array to a string array in Java


  • System.arraycopy(Object src, int srcPos, Object dest, int destPos, int length);
  • Arrays.asList(Object_Array).toArray(new String[Object_Array.length]);  
  • Java 1.6
        String[] stringArray = Arrays.copyOf(objectArray, objectArray.length, String[].class);

Refs

Friday, May 10, 2013

Find which process is using a file on Mac

Use this command
lsof | grep <filename>
or
lsof <filepath>
To ignore case, use
lsof | grep -i <filename>
Run it as root if the process is owned by root,
sudo lsof | grep -i <filename>
Refs

Getting the error "oasis-text.icns is in use" when installing LibreOffice on Mac


The full error message is

The operation can't be completed because the item "oasis-text.icns" is in use.

To fix it, just quit the SystemUIServer process in the Activity Monitor.

Wednesday, May 8, 2013

Install Force.com IDE on Eclipse 4.2 (Juno)

Cannot complete the install because one or more required items could not be found.
  Software being installed: Force.com IDE 27.0.0.201302151147 (com.salesforce.ide.feature.feature.group 27.0.0.201302151147)
  Missing requirement: Force.com IDE 27.0.0.201302151147 (com.salesforce.ide.feature.feature.group 27.0.0.201302151147) requires 'org.eclipse.update.ui 0.0.0' but it could not be found
Refs

Friday, June 15, 2012

Running Tomboy Note-Taking App on Mac


When running Tomboy 1.10.2 on Mac OS X Lion with Mono 2.10.9 installed, I got this error:-
Unhandled Exception: System.TypeInitializationException: An exception was thrown by the type initializer for IgeMacIntegration.IgeMacDock ---> System.EntryPointNotFoundException: ige_mac_dock_get_type
I found that the ige-mac-integration-sharp.dll library used by Tomboy is not compatible with libigemacintegration.dylib in Mono 2.10.9 (some external functions don't exist any more). I'm new to Mono and this library and I just wanted to get Tomboy to run on Mac and also wanted to keep the latest version of Mono so I did a dirty fix by doing the following:-

  • Build Tomboy.
git clone git://git.gnome.org/tomboy
xbuild Tomboy-mac.sln
./bundle-mac-app.sh
  • Copy libigemacintegration.0.0.0.dylib from Mono 2.6.x to Tomboy.app/Contents/MacOS and rename it to libigemacintegration.dylib

  • Transfer all notes from my Ubuntu machine to Mac.
cp /Volumes/tom-ubuntu/.local/share/tomboy/*.note /Users/tomtanti/Library/Application Support/Tomboy/
  • Run Tomboy for testing.
open Tomboy.app
  • Move Tomboy.app to Applications so that I can simply run it from there in the future.
Refs

Monday, February 6, 2012

Firefox 10 keeps crashing

After upgrading to Firefox 10, the new version kept crashing every time I opened it. Running it in safe mode (firefox -safe-mode) didn't help.



I ended up creating a new profile to fix this problem using the following command and switch:-
firefox -P
All plugins were gone and needed reinstalling. I could get some data back though from the old profile folder in
/home/tom/.mozilla/firefox/xxxx.default
Refs
http://ubuntuforums.org/showthread.php?p=11595179


Friday, January 13, 2012

Make Eclipse look better on Ubuntu

  • Compact the look and fix unreadable selected entry in content assist in some themes (e.g. Ambience) by creating a new text file called "gtkrc" (a stylesheet file for GTK apps) with the following content:- 
gtk-color-scheme = "selected_text_color:#000000"
style "compact"
{
  GtkButton::default_border={0,0,0,0}
  GtkButton::default_outside_border={0,0,0,0}
  GtkButtonBox::child_min_width=0
  GtkButtonBox::child_min_heigth=0
  GtkButtonBox::child_internal_pad_x=0
  GtkButtonBox::child_internal_pad_y=0
  GtkMenu::vertical-padding=1
  GtkMenuBar::internal_padding=1
  GtkMenuItem::horizontal_padding=4
  GtkToolbar::internal-padding=1
  GtkToolbar::space-size=1
  GtkOptionMenu::indicator_size=0
  GtkOptionMenu::indicator_spacing=0
  GtkPaned::handle_size=4
  GtkRange::trough_border=0
  GtkRange::stepper_spacing=0
  GtkScale::value_spacing=0
  GtkScrolledWindow::scrollbar_spacing=0
  GtkExpander::expander_size=10
  GtkExpander::expander_spacing=0
  GtkTreeView::vertical-separator=0
  GtkTreeView::horizontal-separator=0
  GtkTreeView::expander-size=12
  GtkTreeView::fixed-height-mode=TRUE
  GtkWidget::focus_padding=0

  font_name="Liberation Sans,Sans Regular 8"
  text[SELECTED] = @selected_text_color
}
class "GtkWidget" style "compact"
style "compact2"
{
  xthickness=1
  ythickness=1
}
class "GtkButton" style "compact2"
class "GtkToolbar" style "compact2"
class "GtkPaned" style "compact2" 
  • To use the above stylesheet with Eclipse (my version is Indigo - 3.7.1), run Eclipse like this:-
GTK2_RC_FILES=$GTK2_RC_FILES:/somewhere_1/gtkrc /somewhere_2/eclipse
  • Make tooltip readable by using #000000 as its foreground colour (tooltip_fg_color) and #f5f5b5 as background (tooltip_bg_color) in the following files:- 
/usr/share/themes/<your-current-theme>/gtk-3.0/settings.ini
/usr/share/themes/<your-current-theme>/gtk-3.0/gtk.css
/usr/share/themes/<your-current-theme>/gtk-2.0/gtkrc
  • Install Eclipse theme colour plugin and may want to try my TumCode theme which keeps the number of colours to the minimum.
     
  • Replace the default "Monospace" font with "Liberation Mono" and optionally reduce the font size to 8 or 9.
Windows -> Preferences -> General -> Appearance -> Colors and Fonts
(for Java Editor Text Font, Javadoc display font, Properties File Editor Text Font, etc.)

Here is how it looks after the above changes:-

Refs
http://blog.xam.dk/?p=70 
http://askubuntu.com/questions/70599/how-to-change-tooltip-background-color-in-unity
http://blog.valotas.com/2010/02/eclipse-on-linux-make-it-look-good.html