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)

20111222

How to enable remote debugging with Jboss and Eclipse on Ubuntu Linux


1. enable debugging in run.sh (e.g. /usr/jboss/bin/run.sh )

insert this code:

## uncomment this to enable debugging
JAVA_OPTS="$JAVA_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,address=1044,server=y,suspend=n"


right before this code:

# Display our environment
echo "========================================================================="
echo ""
echo "  JBoss Bootstrap Environment"
echo ""
echo "  JBOSS_HOME: $JBOSS_HOME"
echo ""
echo "  JAVA: $JAVA"
echo ""
echo "  JAVA_OPTS: $JAVA_OPTS"
echo ""
echo "  CLASSPATH: $JBOSS_CLASSPATH"
echo ""
echo "========================================================================="
echo ""


2. restart jboss

3. make sure jboss is listening on port 1044

on ibmserver, open a terminal window and run this code:
netstat -a|grep 1044

if a line like this turns up then you're ok:
tcp 0 0 *:1044 *:* LISTEN

4. create new Remote Java Application in eclipse (i.e. configure eclipse so it can debug and publish to a remote java application from your remote location and source code project)

in eclipse (e.g. helios):
run > debug configurations
right click remote java application > new

for name write e.g. myRemoteServer trunk

in the connect tab:
for project click the browse button and choose the root of your trunk eclipse project, e.g. myProjectTrunk

for host use the remote ip address, e.g. 192.168.1.238 (for trunk on myRemoteServer)

for port use the port you specified in run.sh, e.g. 1044

click the apply button, then the debug button

sources:
http://www.eclipsezone.com/eclipse/forums/t53459.html
http://community.jboss.org/thread/78131

20111128

richfaces rich hotkey backspace navigation disabling not working with oncomplete [SOLVED]

in my post richfaces rich hotkey backspace navigation disabling not working [SOLVED] i showed how to get the rich hotkey working by changing oncomplete to onclick, but what if you need oncomplete?

the hack i found to work was to set the focus to somewhere in the panel after the a4j:commandLink link was clicked.



<a4j:commandLink
value="#{detail.action}"
id="editlink"
ajaxSingle="true"
action="#{myBean.myAction}"
reRender="detailsPanel"
rendered="#{detail.actionEdit and myBean.isBuyer}"
oncomplete="if (#{facesContext.maximumSeverity==null}) #{rich:component('detailsPanel')}.show();#{rich:element('CDD_quatityInput')}.focus();">
<f:setPropertyActionListener
value="#{detail}"
target="#{myBean.currentDtlItem}" />
<f:setPropertyActionListener
value="#{row}"
target="#{myBean.currentRow}" />
</a4j:commandLink>
CDD_quatityInput is the id of an element in the panel i am showing when the link is clicked.

i saw an example today where the author also put "event.stopPropagation(); event.preventDefault();" into the handler attribute, but i havent seen the need for it yet.

20111124

richfaces rich hotkey backspace navigation disabling not working [SOLVED]



i was debugging a page where i used a rich hotkey tag to disable backspace from navigating backwards in the browser history, using this code:
<!-- disable backspace navigation in e.g. IE -->
<rich:hotKey key="backspace" handler="return false;" disableInInput="true" />

but every time i clicked on this link to show a panel, then pushed backspace (all on the same page of code as the rich hotkey tag), backspace would still navigate backwards as long as i didnt click on the new panel (set focus on the new panel). i figured out that the problem was the use of oncomplete (not my code):
<a4j:commandLink ajaxSingle="true" id="editlink" oncomplete="#{rich:component('editPanel')}.show()">

so i changed it to onclick and then it worked! =)

<a4j:commandLink ajaxSingle="true" id="editlink" onclick="#{rich:component('editPanel')}.show()">

if you still need to use oncomplete instead of onclick, then see my article richfaces rich hotkey backspace navigation disabling not working with oncomplete [SOLVED]

20111115

ubuntu 11.10 unity turns grey and touchpad mouse stops working/freezes [SOLVED]


all of the sudden, mid session, my interface went grey and the theme vanished so everything looked like an old theme and the mousepad mouse cursor wouldnt move, but i could still type and use the keyboard. to fix this i opened a terminal and ran these commands:
sudo modprobe -r psmouse
sudo modprobe psmouse

source: http://ubuntuforums.org/archive/index.php/t-77612.html

20111108

f:loadBundle not working in jboss 7, can't see properties label text [SOLVED]

i made a simple jsf page to test using a properties file labels_no.properties.
here was the code i had:

<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
template="/WEB-INF/templates/default.xhtml">
<f:loadBundle basename="com.mycompany.labels_no" var="label"/>
<ui:define name="content">
<h:form id="reg">
           <h:panelGroup id="messagePanel" layout="block">
                <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
            </h:panelGroup>
            <h:form>
                <h:panelGrid columns="2">
                    <h:outputLabel value="#{label.userFirstName}" for="userFirstName" />
...
 and in the eclipes preview window i could see the label and it's value, but in a browser the label was missing. i figured out that the f:loadBundle tag was just in the wrong place, so i moved it inside the ui:define tag (the next line under it) and the label appeared! =)

see also:
http://download.oracle.com/javaee/5/javaserverfaces/1.2/docs/tlddocs/f/loadBundle.html
http://www.roseindia.net/jsf/jsf1.2/jsf-properties.shtml

20111102

jboss quickstarts kitchensink arquillian junit remote test not working [SOLVED]

i ran the managed test and it worked, but when i tried the remote test i got this error:
java.lang.IllegalStateException: Cannot obtain MBeanServerConnection to: service:jmx:rmi:///jndi/rmi://127.0.0.1:1090/jmxrmi
the reason is that i needed to start the local server first, THEN run the unit test.

ref: http://stackoverflow.com/questions/7341308/cannot-run-arquillian-tests/7718339#7718339

ubuntu 11.10 unity left side bar gone [SOLVED]

i upgraded to ubuntu 11.10 a while ago instead of a fresh clean install and then i (regretfully) changed some settings and then the left bar in unity disappeared. to get it back i had to do the following:
* in a terminal run:
ccsm
* search for unity
* enable Ubuntu Unity Plugin
* choose Ignore Conflicts (if you're asked about it)

20111025

java pet store jee example application

http://java.net/projects/petstore
it seems a lot of links to the petstore app take you to a 404 page, so i thought i'd post the direct link here =)

20111017

how to run opera web browser in ubuntu 11.10 unity

when i do the keyboard shortcut alt+F2 and type: opera
the only thing that comes up as a suggestion is opera-widget-manager

i found out that if i simply type: oper
then the opera icon comes up as well. i can either click on the big, red circle opera icon or just hit enter =)

weird bug.

20111008

how to organize a collaborative literary project

1. go to http://docs.google.com

2. click the Create button and choose Collection and give it a new name, e.g. My Collaborative Book Project

3. right click the name of the new collection in the menu on the left and choose Create New > Document. Call it something like INDEX or Ideas/Themes/Subjects to cover. Use this document to write all your ideas, one on each line, with a little description about the idea, then create a new document for each of them, and make each of those idea lines a link to its own document.

4. share your project (collection) with your collaborators. right click the name of the new collection in the menu on the left and choose Share > Share. Type in their email addresses then choose Done.

20111007

buildbot install error: twisted/runner/portmap.c:10:20: fatal error: Python.h: No such file or directory compilation terminated


i tried installing buildbot on ubuntu while following this tutorial:
http://buildbot.net/buildbot/docs/current/tutorial/firstrun.html

[
FYI:
in ubuntu, there's no package called virtualenv. you need to install the python-virtualenv package:
sudo apt-get install python-virtualenv
]

while trying to install buildbot i got the following error:
Downloading http://pypi.python.org/packages/source/T/Twisted/Twisted-11.0.0.tar.bz2#md5=d7f94a1609a1b8f3b8c8d0146d4cfe54
Processing Twisted-11.0.0.tar.bz2
Running Twisted-11.0.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-4wBTit/Twisted-11.0.0/egg-dist-tmp-odVQeg
twisted/runner/portmap.c:10:20: fatal error: Python.h: No such file or directorycompilation terminated.error: Setup script exited with error: command 'gcc' failed with exit status 1
to fix this i had to install the python-dev package:
sudo apt-get install python-dev

then rerun the last install command:
easy_install buildbot

src: http://alexsleat.co.uk/2011/01/01/fatal-error-python-h-no-such-file-or-directory/

how to find your facebook wall posts/status updates rss feed url for use in blogger/blogspot blog

1. log into facebook.com

2. go here: http://www.facebook.com/notifications

3. find the text link at the top called RSS and right click on it and copy the URL. it will look something like this:
http://www.facebook.com/feeds/notifications.php?id=xxxxxxxxx&viewer=xxxxxxxxx&key=xxxxxxxxxxxxxxxx&format=rss20

where "xxx..." represents your account's personal IDs and key values,

4. paste that URL into a text editor and replace the text "notifications.php" with "status.php", so it looks like this:
http://www.facebook.com/feeds/status.php?id=xxxxxxxxx&viewer=xxxxxxxxx&key=xxxxxxxxxxxxxxxx&format=rss20

rss20 can also be changed to atom10 for an atom feed

5. paste the new URL into e.g. blogger's rss feed widget

20111006

extra secure password identification

this would make it a little more difficult to crack a password:
require the user to enter the password, click enter, authenticate the password, then have the user repeat the operation one more time, if both times match then you're let in. it would at least double the amount of time it would take to crack a password.

20110719

latin tts (text to speech)

install espeak on ubuntu
sudo apt-get install espeak

then run this (substitute the text with your own):
espeak -v latin "in hoc signo vinces"

20110611

ubuntu 11.04 sound problems and solutions (hdmi + normal audio)

when i hooked my laptop up to my tv using an hdmi cable the sound was totally crappy. i read (i cant remember where, sorry) that to fix it you need to disable the normal audio interface:
System > Preferences > Sound > Hardware
choose Internal Audio
profile: Off

it worked perfectly. when i was does and renabled Internal Audio, i couldnt hear any sound with normal audio, like youtube in chrome or playing local files with vlc. to fix this i read No sound at all.
all i had to do was this:
rm -r ~/.pulse ~/.pulse-cookie

20110530

how to import/overwrite mysql database to a remote server using the command line

i installed tikiwiki on a domain i have hosted on domeneshop.no and they recommended not to use phpmyadmin, but mysql workbench instead. i wanted to import an old tikiwiki i had started 2 years ago. i used like an hour trying to setup mysql-workbench and kept getting the error:
ERROR 1046 (3D000) at line 22: No database selected
when all i really needed to do was open a terminal and run this:
mysql --host=myhost.example.com --user=myUser5 -p --default-character-set=utf8 myDbSchemaName < "/home/nick/sqlFileToImport.sql"

20110523

how to install printer and scanner drivers on ubuntu 64-bit for brother DCP-9270CDN

(updated for ubuntu linux 12.04)


INSTALL PRINTER DRIVERS

download drivers from Brother website (drivers are i386 even for amd64/64-bit):
LPR driver     deb     1.1.1-5     756 KB     2011.Jan.28
cupswrapper driver     deb     1.1.1-5     12 KB     2011.Jan.28

navigate to the location where you downloaded the deb files, e.g. ~/Downloads:
cd
cd Downloads
sudo dpkg -i --force-all dcp9270cdnlpr-1.1.1-5.i386.deb
returns:
Selecting previously unselected package dcp9270cdnlpr:i386.
(Reading database ... 178504 files and directories currently installed.)
Unpacking dcp9270cdnlpr:i386 (from dcp9270cdnlpr-1.1.1-5.i386.deb) ...
Setting up dcp9270cdnlpr:i386 (1.1.1-5) ...
mkdir: cannot create directory `/var/spool/lpd/dcp9270cdn': No such file or directory
chown: cannot access `/var/spool/lpd/dcp9270cdn': No such file or directory
chgrp: cannot access `/var/spool/lpd/dcp9270cdn': No such file or directory
chmod: cannot access `/var/spool/lpd/dcp9270cdn': No such file or directory


(you can disregard the warnings)

sudo dpkg -i --force-all dcp9270cdncupswrapper-1.1.1-5.i386.deb
returns:
Selecting previously unselected package dcp9270cdncupswrapper:i386.
(Reading database ... 178536 files and directories currently installed.)
Unpacking dcp9270cdncupswrapper:i386 (from dcp9270cdncupswrapper-1.1.1-5.i386.deb) ...
Setting up dcp9270cdncupswrapper:i386 (1.1.1-5) ...
cups stop/waiting
cups start/running, process 28182


dpkg -l|grep Brother

returns:
ii  dcp9270cdncupswrapper:i386 1.1.1-5 Brother CUPS Laser Printer Definitions
ii  dcp9270cdnlpr:i386 1.1.1-5 Brother lpr Laser Printer Definitions
ii  printer-driver-ptouch 1.3-3ubuntu0.1 printer driver Brother P-touch label printers




CONFIGURE THE PRINTER

go here: http://localhost:631/printers
click the link: DCP9270CDN
dropdown box: Administration > Printers > Manage Printers
click DCP9270CDN > in the second dropdown list to the right at the top ("Administration" is selected by default), choose Modify Printer

a popup box will ask you for your username and password--this is your normal ubuntu username and password

##OLD##
choose radio button: LPD/LPR Host or Printerclick continue
set lpd to: lpd://XXX.XXX.XXX.XXX/binary_p1
(replace the XXX's with the ip address for your network printer)
####

to find the printer's IP address and active services and enabled protocols, go to the printer and select the following:
menu > print report > network configuration

now, back in your browser ( http://localhost:631/printers ) choose the radio button for Other Network Printers > AppSocket/HP JetDirect.
(
why AppSocket?
"The AppSocket protocol ... is the simplest, fastest, and generally the most reliable network protocol used for printers."
http://localhost:631/help/network.html#SOCKET
)



click continue
connection:
socket://192.168.1.242
click continue
click continue

upload the PPD file. to find where it is, run this in a terminal: 
locate ppd|grep Brother








i got the following output:
/usr/local/Brother/Printer/dcp9270cdn/cupswrapper/dcp9270cdn.ppd

click Browse to select the PPD file
click Modify Printer



INSTALL SCANNER DRIVERS (OPTIONAL)
Scanner Driver download page
find the section for DCP-9270CDN (search for it on the page) and download the following:

brscan4 64bit     deb     0.4.1-1     72 KB     2012.Jun.05
scan-key-tool 64bit     deb     0.2.3-0     51 KB     2012.Mar.22


(install drivers for scanning from Brother website)

navigate to the location where you downloaded the deb files, e.g. ~/Downloads:
cd
cd Downloads
sudo apt-get install sane-utils
sudo dpkg -i --force-all brscan4-0.4.1-1.amd64.deb

returns:
Selecting previously unselected package brscan4.
(Reading database ... 178540 files and directories currently installed.)
Unpacking brscan4 (from brscan4-0.4.1-1.amd64.deb) ...
Setting up brscan4 (0.4.1-1) ...
This software is based in part on the work of the Independent JPEG Group.


dpkg -l|grep Brother

returns:
ii  brscan4 0.4.1-1 Brother Scanner Driver
ii  dcp9270cdncupswrapper:i386 1.1.1-5 Brother CUPS Laser Printer Definitions
ii  dcp9270cdnlpr:i386 1.1.1-5 Brother lpr Laser Printer Definitions
ii  printer-driver-ptouch 1.3-3ubuntu0.1 printer driver Brother P-touch label printers


brsaneconfig4 -a name=SCANNER model=DCP-9270CDN ip=XXX.XXX.XXX.XXX
(the ip flag is apart of the brsaneconfig4 line. replace XXX... with your printer's IP address)

brsaneconfig4 -q|grep SCANNER
returns:
0 SCANNER             "DCP-9270CDN"       I:XXX.XXX.XXX.XXX

sudo dpkg -i --force-all brscan-skey-0.2.3-0.amd64.deb
returns:
Selecting previously unselected package brscan-skey.
(Reading database ... 178568 files and directories currently installed.)
Unpacking brscan-skey (from brscan-skey-0.2.3-0.amd64.deb) ...
Setting up brscan-skey (0.2.3-0) ...


dpkg -l|grep Brother

returns:
ii  brscan-skey 0.2.3-0 Brother Linux scanner S-KEY tool
ii  brscan4 0.4.1-1 Brother Scanner Driver
ii  dcp9270cdncupswrapper:i386 1.1.1-5 Brother CUPS Laser Printer Definitions
ii  dcp9270cdnlpr:i386 1.1.1-5 Brother lpr Laser Printer Definitions
ii  printer-driver-ptouch 1.3-3ubuntu0.1 printer driver Brother P-touch label printers


start the scanner tool:
brscan-skey

check to see if the scanner is "Active":
brscan-skey -l
returns:
SCANNER           : brother4:net1;dev0  : XXX.XXX.XXX.XXX        Active

to scan, put the document on the scanner, press Scan button on the scanner > Scan to PC > Image > choose your user (e.g. "nick"), press "Start".

gimp will open automatically on your computer with the scanned image open as an image. i found that i had to close gimp completely after each successive scan otherwise i would get an error.

20110505

ocr - tesseract vs oscroscript (ocropus) - how to convert image to text

both tesseract and ocropus are developed by google, but for some reason ocropus misses the first line of the paragraph. see for yourself:

tesseract output:
The book is the synthesis of, on one hand, the no-nonsense
mathematical trader (sdf-styled “practmcnct of uncettaintfl who
spent his life trying to resist being fooled by randomness and mult the
emotions associated with uncertainty and, on the other, the aesthetically
obsessed, litcr:itun:·l0ving human being willing to be fooled by any form
of noruense that is polished, refined, original, and tasteful. I um not
capable of avoiding being the fool of randomness; what l can do is
confine it to where it brings some aesthetic gratification.
ocropus output:
mathematical trader (sdf-styled “practmcnct of uncettaintfl who spent his life trying to resist being fooled by randomness and mult the emotions associated with uncertainty and, on the other, the aesthetically obsessed, litcr:itun:·l0ving human being willing to be fooled by any form of noruense that is polished, refined, original, and tasteful. I um not capable of avoiding being the fool of randomness; what l can do is confine it to where it brings some aesthetic gratification.
compare the original (orig) image with the monochrome image. i had to convert it to monochrome to get a decent output.

this is how i did it in gimp:
1. first i enlarged the image so i could see more clearly the individual letters
2. colors > levels > edit settings as curves
i dragged the diagonal line down to the right just a little bit to make the letters a little more full looking (decrease the cloudy anti-aliasing effect)
3. image > mode > indexed > use black and white (1 bit) palette
turns it monochrome

now you have a png you can use to get a decent result with using ocroscript:
ocroscript recognize surface02.png > surface02.html

tesseract needs a tif file so you have 1 more step to get the better result with tesseract (the first line, which ocroscript doesnt manage to get):

4. layer > transparency > remove alpha channel
now save as *.tif and run this:
tesseract surface02.tif surface0.txt


moving my vbulletin forum here

the vbulletin version i'm using on The Royal Nick Humphrey Global World IT Forum, Home Edition is getting old now and i dont want to pay for a new one/upgrade.

last week my post table got corrupted, "coincidentally" right after i put a link in my signature to my website with lesser-known information, in norwegian, about the mormon church, that they dont want you or their members to know about. my website is called mormonerne. i suspect that someone from the church has tried to shut my site down, but i cant prove it. the exmormon site has had a lot of attacks so it's not unlikely, but it got me to thinking about security in general--it might be good to move my forum to a place like blogger, owned by google, where it would be harder for a hacker to do damage. so EAT THAT mormon hacker trash (if it was a mormon) lol =)

so all my new posts and IT tutorials will be posted here from now on.