The best place to *find* answers to programming/development questions, imo, however it's the *worst* place to *ask* questions (if your first question/comment doesn't get any up-rating/response, then u can't ask anymore questions--ridiculously unrealistic), but again, a great reference for *finding* answers.

My Music (Nickleus)

20120823

ubuntu nautilus error can't delete non-empty folder

i have a folder here:
/media/backup/me/path/to/folder/i/want/to/delete

but when i try to delete it in nautilus i get an error like:
error can't delete non-empty folder / the directory is not empty

(i don't remember the exact wording)

to fix this i forced a disk check at the next reboot:
sudo touch /forcefsck
sudo reboot

after the reboot and disk check, i tried deleting this folder:
/media/backup/me/path/

but got the same error. then i navigated all the way into this folder:
/media/backup/me/path/to/folder/i/want/to/delete

then showed hidden files (Ctrl+h)
then deleted the innermost folder and it deleted! then i stepped up to each consecutive parent folder and deleted them along the way until i got back up to:
/media/backup/me/path/

and i was able to delete that one as well =)

quick way to add a program link to the unity launcher sidebar in ubuntu 12.04

it is totally ridiculous that it is so difficult to add an application to the unity launcher or sidebar.

solutions i found today involve editing .desktop text files or install additional software like gnome-panel, but the simplest way to do it is this:
1. start the program manually
2. go to unity's launcher sidebar
3. there will be an icon for the program you just started (it might or might not have an image file, if not, it will just look like a question mark "?")
4. right click on the icon and choose Lock to launcher


source: http://ubuntuforums.org/showpost.php?p=11902734&postcount=2

how and where to manually install eclipse in ubuntu 12.04

some people say to install optional programs in /opt
some people say to install them in /usr/local

http://www.linuxjournal.com/magazine/pointcounterpoint-opt-vs-usrlocal
http://www.ubuntugeek.com/linux-or-ubuntu-directory-structure.html

i'll show you how to install them in /usr/local because applications there don't get overwritten by updates.

1. get eclipse, download it (e.g. Eclipse IDE for Java EE Developers, Linux 64-bit) and unpack it (nautilus > right click on file > extract here)
let's assume the unpacked folder is here:
/home/you/Downloads/eclipse

you is your user's home directory, a.k.a. ~/

2. move eclipse to /usr/local:

sudo mv ~/Downloads/eclipse /usr/local/

3. create a simlink for the eclipse executable in the /usr/local/bin folder:
sudo ln -s /usr/local/eclipse/eclipse /usr/local/bin/eclipse

we do this so that when we enter the run dialog (Alt+F2), we can just type eclipse and hit enter, to start eclipse

you can, additionally, add a link to the unity launcher if you prefer to start it that way.

20120821

subclipse (svn) asking for username password all the time in eclipse

one of our programmers had a problem in eclipse where every time she did anything related to svn, it would ask her for her username and password, even if she chose to "remember password". it wouldn't remember the password.

to fix this i simply deleted the subversion folder in the home folder:
/home/me/.subversion

now open a terminal and list the remote repository, e.g.:
svn list https://mycompany.no/repos/myrepo/trunk

accept permanently

if the wrong username comes up when subversion asks you to identify yourself just hit "Enter" and you can type in the correct user name.

20120816

My minimal plugin configuration a clean install of eclipse juno


When doing a clean install of Eclipse, I need at least the following plugins:

Subclipse (SVN)


Help > Install New Software > Website:
http://subclipse.tigris.org/update_1.6.x

click Add

Expand "Subclipse" and check the following "Required" plugins:
* Subclipse
* Subversion Client Adapter
* Subversion Native JavaHL Library Adapter

New > SVN > Checkout projects from SVN > Create a new repository location
URL: https://example.com/repos/myProject/trunk/
(enter your project's SVN URL)
Finish


Jboss Tools JSF


Help > Eclipse Marketplace > search for "jboss jsf" > click "install" on "jboss tools (indigo)" > unselect everything, then select only "jboss tools jsf".

it will additionally install the following requirements:
* jboss tools common
* jboss tools java standard tools
* jboss tools visual page editor

then you have to enable JSF capabilities:
right click on your project > Configure > Enable JSF Capabilities
in Juno, it will open Project Facets properties. at least the following facets should be checked:
Dynamic Web Module
Java
JavaServer Faces

on my machine there was a red X at the bottom of the window with a link to additional configuration required. click on it.

my jee application has the following configuration:
context root: myProject
content: WebContent

myProject is the name of your project

click Next

Type: User Library

click the icon at the right for Manage Libraries
click New
call it JBoss Tools JSF 1.2
click Add External Jars
to find where the JBoss Tools JSF plugin installed JSF 1.2 jars we do this in a terminal:
sudo updatedb
locate jsf-api.jar

you'll see an entry that looks like this:
/home/me/workspaceJuno/.metadata/.plugins/org.jboss.tools.common.projecttemplates/templates/jsf-1.2-facelets/FaceletsKickStartWithRILibs/WebContent/WEB-INF/lib/jsf-api.jar

so in the Add External Jars dialogue, navigate to the parent folder lib, and add both these jars:
jsf-api.jar
jsf-impl.jar

in the dialogue Modify Faceted Project > JSF Implementation Library
check your new user library JBoss Tools JSF 1.2

uncheck Include libraries with this application (i.e. we don't want the jsf libraries to get copied to WEB-INF/lib at publish time--they're already in jboss, here: /path/to/jboss/server/default/deploy/jboss-web.deployer/jsf-libs/ )

uncheck Configure JSF servlet in deployment descriptor (we had already done it in our project, if you haven't, then leave this checked)

Note: jboss tools indigo is anticipated to work on juno

Note: i had to restart eclipse for the jsf capabilities to start working.

JRebel (optional, but very effective--fewer server restarts)


Help > Eclipse Marketplace > search for "JRebel" > install "JRebel for Eclipse"

after the install you'll be directed to the JRebel Config Center Activation page. click the Evaluate link. it will open a new browser tab/window where you can apply for a free/trial activation code. fill out the form then copy the generated key and paste it into the eclipse window where it says Paste your license code below.


Eclipse Web Developer Tools (optional, but very useful--format code with correct indentation, etc)


Help > Install New Software > Website:
The Eclipse Web Tools Platform (WTP) software repository - http://download.eclipse.org/webtools/repository/juno

Expand "Web Tools Platform (WTP) 3.4.0" and check "Eclipse Web Developer Tools"

on my machine i got the following message when installing this:
"Eclipse Web Developer Tools" is already installed, so an update will be performed instead.

20120809

eclipse subclipse svn: Couldn't perform atomic initialization

i tried committing something to svn today from eclipse and got the following error:
svn: Couldn't perform atomic initialization

the only way i could temporarily get around this was to open the project folder in a terminal and run cleanup and then update:
me@mylaptop:~/workspace/myProject $ svn cleanup
me@mylaptop:~/workspace/myProject $ svn up

it's weird, but running "up" actually committed the files i previously tried to commit inside eclipse.

20120806

java Pattern.compile regex with "greedy quantifier" "at least n but not more than m times" curley brackets {}


X{n,m} == "greedy quantifier"
X, at least n but not more than m times

http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html

http://en.wikipedia.org/wiki/Email_address
full implementation of email regex validation: http://code.iamcal.com/php/rfc822/full_regexp.txt
practical implementation: http://www.mkyong.com/regular-expressions/how-to-validate-email-address-with-regular-expression/

so here's what i came up with:
if (!Pattern.compile("[A-Za-z0-9\\._\\-]+\\@[A-Za-z0-9\\-]+(\\.[A-Za-z0-9\\-]+)*(\\.[A-Za-z]{2,})").matcher(mail).find()){
throw new ValidatorException(new FacesMessage("Invalid email."));
}
i ended up choosing "X, at least n but not more than m times".
here are examples of valid emails checked against my regexp above:
ric-k.g.mum-phrey@g-mail.com
rick.g.mumphrey@gmail.com
rick.g.mumphrey@gmail.co.uk