The best place to ask programming/development questions, imo. UPDATE: stackoverflow is 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 a great reference for finding answers.

My Music (Nickleus)

20120831

what i configure and install immediately after a new, clean install of ubuntu

the following is for ubuntu 12.04:
(UPDATE 20130523: updated now for ubuntu 13.04)

note: the first step in each point is done by hitting the super key (windows icon). the unity search bar will pop up at the top left, then just type the text, e.g. additional drivers

SYSTEM CONFIGURATION CUSTOMIZATION

* install amd video drivers (sony vaio vpcse)
additional drivers > select ati/amd proprietary fglrx graphics driver > activate

if you're configuring ubuntu 13.04, then just use the default video drivers, you don't need the proprietary ones

but if you want to find the video driver configuration it is here instead (ubuntu 13.04):
software & updates > additional drivers


* (OPTIONAL) disable tapping
mouse and touchpad > touchpad > (uncheck) enable mouse clicks with touchpad

* keyboard shortcuts
keyboard > shortcuts > Launchers >
launch web browser: ctrl+super+i
home folder: ctrl+alt+h

* terminal
Edit > Profiles > Default > Edit
scrolling >
scrollback: unlimited
scrollbar is: on the left side

* (OPTIONAL) copy over backup files from backup server/usb stick
after doing this, i move/merge the following folders into my Library folder:
Video
Music
Pictures
Documents

my Home folder looks like this:
Desktop
Downloads
Library
Public
stuff_to_backup.txt
workspaceJuno


Library has all my favorite/important documents/files in it and looks like this:
Library/
├── art
│   ├── halloween
│   ├── interiordecorating
│   ├── Music
│   ├── Pictures
│   ├── tattoo
│   └── Videos
├── Documents
│   └── work
├── fighting
│   ├── military
│   └── weapons
├── language
├── legal
├── media
│   └── advertising
├── money
├── Nickleus
│   ├── music
│   ├── my_art
│   ├── poetry
│   └── www
├── philosophy
│   ├── atheism
│   ├── superstition
├── politics
├── science
│   ├── animals
│   ├── astronomy
│   ├── chemistry
│   ├── cryptography
│   ├── curiosity_mars
│   ├── dinosaurs
│   ├── evolution
│   ├── health
│   ├── psychology
│   └── radiation_files
└── sexuality


there are a lot more sub folders, but the list would be too long here.

* disable system sound effects
Sound > sound effects > alert volume: mute

* firefox
make firefox start with previous open tabs:
edit > preferences >  general > startup > when firefox starts: show my windows and tabs from last time

close download window after download finished:
edit > preferences >  general > downloads > check close it when all downloads are finished

setup sync (i haven't done this before so it might be a different choice next time, like Pair a Device):
edit > preferences > sync > set up firefox sync

configure searching and selecting text:
edit > preferences > advanced > general > accessibility
check always use the cursor keys to navigate within pages
check search for text when i start typing

* increase bash history size
cd
nano -w .bashrc

change this:
HISTSIZE=1000
HISTFILESIZE=2000


to this:
HISTSIZE=99999999
HISTFILESIZE=99999999


update bash with the newly edited bashrc file:
source .bashrc

* configure unity launcher
appearance > behavior
auto-hide the launcher: ON
reveal location: top left corner

* turn off auto-dim
brightness and lock > brightness > uncheck dim screen to save power

* clock
click the clock in the system tray (top right) > time and date settings > clock
check weekday
check date and month
check 24-hour time
check seconds
check include week numbers

* disable ayatana (virtual) scrollbar
to get the normal scrollbars back, run this in a terminal:
gsettings set org.gnome.desktop.interface ubuntu-overlay-scrollbars false



INSTALL PROGRAMS

* first, make sure your sources list is updated
sudo apt-get update

* nautilus right click "open in terminal"
sudo apt-get install nautilus-open-terminal

(note: you have to log out then log in again to get it to work)

* install geany text editor
sudo apt-get install geany

make it the default text editor:
sudo apt-get install gksu
gksudo gedit /usr/share/applications/defaults.list


search+replace to change all instances of gedit to geany, i.e.:

application/x-perl=geany.desktop
...
text/plain=geany.desktop
...

text/x-chdr=geany.desktop
text/x-csrc=geany.desktop
text/x-dtd=geany.desktop
text/x-java=geany.desktop
text/mathml=geany.desktop
text/x-python=geany.desktop
text/x-sql=geany.desktop


(thanks to the post "HowTo Change Default GNOME Text Editor or Any Other Default Program" for the tip)

why Geany? native regular expressions (regex) support

* install vlc
sudo apt-get install vlc

make it the default video player:
details > default applications > video > vlc media player
set music to vlc media player too, while you're there

* install java
jdk (i'm a developer):
sudo apt-get install openjdk-6-jdk

firefox plugin:
sudo apt-get install icedtea6-plugin

* filezilla
sudo apt-get install filezilla

if you want to import your list of sites you usually use, then the file you need to get from your old ubuntu version is:
~/.filezilla/sitemanager.xml


* archive support
sudo apt-get install p7zip-rar

it will install both 7zip and a rar module

* art
sudo apt-get install inkscape gimp gimp-data-extras

* (OPTIONAL) audio editing/music production
sudo apt-get install audacity lmms ams caps cmt fil-plugins invada-studio-plugins-ladspa rev-plugins swh-plugins tap-plugins calf-plugins alsa-utils

i had no sound after my install so i had to start alsamixer in a terminal then set Auto-Mute to Disabled

then i restarted pulseaudio and i got sound back:
sudo killall pulseaudio

* (OPTIONAL) additional browsers
opera
sudo add-apt-repository "deb http://deb.opera.com/opera/ stable non-free"
wget -qO - http://deb.opera.com/archive.key | sudo apt-key add -
sudo apt-get update
sudo apt-get install opera

once i got a weird error during "update":
W: Failed to fetch http://deb.opera.com/opera/dists/stable/Release  Unable to find expected entry 'non-free/source/Sources' in Release file (Wrong sources.list entry or malformed file)
E: Some index files failed to download. They have been ignored, or old ones used instead.


to fix this i had to manually edit the sources.list file:
sudo nano -w /etc/apt/sources.list

and comment out the following line:
# deb-src http://deb.opera.com/opera/ stable non-free

then run a new update and install again:
sudo apt-get update
sudo apt-get install opera

UPDATE 20130523:
for ubuntu 13.04, i got the following warnings:
INFO:softwarecenter.db.pkginfo_impl.aptcache:aptcache.open()
WARNING:softwarecenter.db.update:The file: '/usr/share/app-install/desktop/sonic-visualiser:x-sonicvisualiser-layer.desktop' could not be read correctly. The application associated with this file will not be included in the software catalog. Please consider raising a bug report for this issue with the maintainer of that application
WARNING:softwarecenter.db.update:The file: '/usr/share/app-install/desktop/workrave:workrave.desktop' could not be read correctly. The application associated with this file will not be included in the software catalog. Please consider raising a bug report for this issue with the maintainer of that application

Software catalog update was successful.
Processing triggers for hicolor-icon-theme ...
Setting up opera (12.15.1748) ...
update-alternatives: using /usr/bin/opera to provide /usr/bin/x-www-browser (x-www-browser) in auto mode
...

update-alternatives: using /usr/bin/opera to provide /usr/bin/gnome-www-browser (gnome-www-browser) in auto mode
Updating software catalog...this may take a moment.

...
Software catalog update was successful.

but opera got installed and i could run it, so it wasn't a problem.


* (OPTIONAL) fonts
i maintain a folder full of fonts i like in Downloads/nicks-fonts.
sudo cp -r ~/Downloads/nicks-fonts /usr/share/fonts/truetype/

* (OPTIONAL) torrent
become a leecher (no uploading)
transmission > edit > preferences > speed > speed limits > check upload and set value to 0

* (OPTIONAL) firefox delicious add-on

* skype
sudo add-apt-repository "deb http://archive.canonical.com/ $(lsb_release -sc) partner"
sudo apt-get update && sudo apt-get install skype

* setup network printer and scanner

* (OPTIONAL) install Download Flash and Video firefox plugin

more tips here (it's easier for me to just tag things using delicious browser plugin:
os+ubuntu+postinstall+configuration

20120823

how to download cnn flash video

i found this video interview by CNN of Ballard about Romney:
http://ldsliving.com/story/69899-video-cnn-interviews-elder-ballard-romney-about-the-mormon-faith

to download that video you need to install this plugin in firefox (Download Flash and Video):
https://addons.mozilla.org/en-US/firefox/addon/download-flash-and-video/

start playing the video in the browser then click the icon in the browser toolbar and choose the .flv video at the bottom.

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