Friday, December 12, 2014

Incompatible magic value 1347093252 in class file

The error describes exactly which is problem: your class file does not start as all java class should, i.e. with 3405691582 (or in hexadecimal CAFEBABE). Instead, your class starts with 1347093252 (hexadecimal 504B0304) that, as indicated in the reference below, it the beginning of a zip/jar file.

How can it happen? Well in my case, I got this problem when I created a jar file to store some of my classes and I used the command:

jar cf my_package1.jar /path/to/classes/*

and clearly something went wrong.
How did I solve it? I slightly changed the command for the jar file in:

jar cf my_package1.jar /path/to/classes/*.class


And everything went OK.

Reference:
http://www.coderanch.com/t/411141/java/java/Imcompatible-Magic-Number

Wednesday, December 3, 2014

How to run 32 bit applications on a 64bit linux machine

Got the nasty "bad ELF interpreter" error message trying to run a 32bit command line application?
You probably miss some shared library!
How to solve it?

Run a check on the missing shared libraries using the command "ldd" (print shared library dependencies)

ldd <path_to_your_32bit_application>

then install the missing libraries. For example on CentOS/RedHat

yum provides <path_to_the_missing_library>

Done!

Example:

sudo yum provides /lib/libpthread.so.0


References:

http://stackoverflow.com/questions/8328250/centos-64-bit-bad-elf-interpreter

Sunday, November 23, 2014

Simple tips to make firefox opening new tabs quicker

Type in URL bar:

about:config

Click "I'll be careful, I promise" and then, look for:

  • network.http.pipelining 
when found it, double click on it to set the value to true

  • network.http.pipelining.maxrequests 
double click and set the value to 8
Other tips:
  • Clear cache and history
  • Disable add-ons you are not using.

Go Firefox! Go!

Sunday, July 13, 2014

XPLAIN : X11 for the rest of us



"... I still field plenty of questions from lots of people about this, and a lot of the time, it's extremely simple stuff: "What is X?" "How does it interact with my graphics card and mouse/keyboard?" "What do apps use X for?" "What is Wayland, and how does it fit into the picture?" "What problems did X have that made us want to write new display server technologies?"
These sort of questions were what inspired me to write "The Linux Graphics Stack" in the first place, but there's really never been a comprehensive, historical writeup of our display server technologies in general. So, I chose to spend my free time at Red Hat writing it. "

Enjoy it!

http://magcius.github.io/xplain/article/index.html

Tuesday, July 8, 2014

How to set SQL Developer UI to English

Are you using SQL Developer in German/French/etc but you don't like and you want it back to English?It easy to do this!
Close all sql developer instances, locate the file sqldeveloper.conf (it's in the bin folder of your sqldevloper installation folder), open it with your favorite editor (mine is Notepad++) and add to the end this line:

AddVMOption -Duser.language=en

Restart sqldevelper and go back to work! :)




Tuesday, June 24, 2014

Sorted list of the Oracle Reserved Words, Keywords, and Namespaces

Thinking it would have been useful to many of you, I made a list (alphabetically sorted) of ALL (a served keyword, BTW! ) Oracle database keywords... so you can just copy and paste!

The source of this list is the official Oracle's documentation and I used Notepad++ with TextFX  to sort the list!
Enjoy!





ABORT
ACCEPT
ACCESS
ADD
ADMIN
AFTER
ALL
ALLOCATE
ALTER
ANALYZE
AND
ANY
ARCHIVE
ARCHIVELOG
ARRAY
ARRAYLEN
AS
ASC
ASSERT
ASSIGN
AT
AUDIT
AUTHORIZATION
AVG
BACKUP
BASE_TABLE
BECOME
BEFORE
BEGIN
BETWEEN
BINARY_INTEGER
BLOCK
BODY
BOOLEAN
BY
CACHE
CANCEL
CASCADE
CASE
CHANGE
CHAR
CHARACTER
CHAR_BASE
CHECK
CHECKPOINT
CLOSE
CLUSTER
CLUSTERS
COBOL
COLAUTH
COLUMN
COLUMNS
COMMENT
COMMIT
COMPILE
COMPRESS
CONNECT
CONSTANT
CONSTRAINT
CONSTRAINTS
CONTENTS
CONTINUE
CONTROLFILE
COUNT
CRASH
CREATE
CURRENT
CURRVAL
CURSOR
CYCLE
DATABASE
DATAFILE
DATA_BASE
DATE
DBA
DEBUGOFF
DEBUGON
DEC
DECIMAL
DECLARE
DEFAULT
DEFINITION
DELAY
DELETE
DELTA
DESC
DIGITS
DISABLE
DISMOUNT
DISPOSE
DISTINCT
DO
DOUBLE
DROP
DUMP
EACH
ELSE
ELSIF
ENABLE
END
ENTRY
ESCAPE
EVENTS
EXCEPT
EXCEPTION
EXCEPTIONS
EXCEPTION_INIT
EXCLUSIVE
EXEC
EXECUTE
EXISTS
EXIT
EXPLAIN
EXTENT
EXTERNALLY
FALSE
FETCH
FILE
FLOAT
FLUSH
FOR
FORCE
FOREIGN
FORM
FORTRAN
FOUND
FREELIST
FREELISTS
FROM
FUNCTION
GEN
GENERIC
GO
GOTO
GRANT
GROUP
GROUPS
HAVING
IDENTIFIED
IF
IMMEDIATE
IN
INCLUDING
INCREMENT
INDEX
INDEXES
INDICATOR
INITIAL
INITRANS
INSERT
INSTANCE
INT
INTEGER
INTERSECT
INTO
IS
KEY
KP
L
LANGUAGE
LAYER
LEVEL
LIKE
LIMITED
LINK
LISTS
LOCK
LOGFILE
LONG
LOOP
MANAGE
MANUAL
MAX
MAXDATAFILES
MAXEXTENTS
MAXINSTANCES
MAXLOGFILES
MAXLOGHISTORY
MAXLOGMEMBERS
MAXTRANS
MAXVALUE
MIN
MINEXTENTS
MINUS
MINVALUE
MLSLABEL
MOD
MODE
MODIFY
MODULE
MOUNT
NA
NATURAL
NC
ND
NEW
NEXT
NEXTVAL
NL
NM
NOARCHIVELOG
NOAUDIT
NOCACHE
NOCOMPRESS
NOCYCLE
NOMAXVALUE
NOMINVALUE
NONE
NOORDER
NORESETLOGS
NORMAL
NOSORT
NOT
NOTFOUND
NOWAIT
NR
NS
NT
NULL
NUMBER
NUMBER_BASE
NUMERIC
NZ
O
OF
OFF
OFFLINE
OLD
ON
ONLINE
ONLY
OPEN
OPTIMAL
OPTION
OR
ORDER
OTHERS
OUT
OWN
PACKAGE
PARALLEL
PARTITION
PCTFREE
PCTINCREASE
PCTUSED
PLAN
PLI
POSITIVE
PRAGMA
PRECISION
PRIMARY
PRIOR
PRIVATE
PRIVILEGES
PROCEDURE
PROFILE
PUBLIC
QUOTA
RAISE
RANGE
RAW
READ
REAL
RECORD
RECOVER
REFERENCES
REFERENCING
RELEASE
REMR
RENAME
RESETLOGS
RESOURCE
RESTRICTED
RETURN
REUSE
REVERSE
REVOKE
ROLE
ROLES
ROLLBACK
ROW
ROWID
ROWLABEL
ROWNUM
ROWS
ROWTYPE
RUN
S
SAVEPOINT
SCHEMA
SCN
SECTION
SEGMENT
SELECT
SEPARATE
SEQUENCE
SESSION
SET
SHARE
SHARED
SIZE
SMALLINT
SNAPSHOT
SOME
SORT
SPACE
SQL
SQLBUF
SQLCODE
SQLERRM
SQLERROR
SQLSTATE
START
STATEMENT
STATEMENT_ID
STATISTICS
STDDEV
STOP
STORAGE
SUBTYPE
SUCCESSFUL
SUM
SWITCH
SYNONYM
SYSDATE
SYSTEM
TABAUTH
TABLE
TABLES
TABLESPACE
TASK
TEMPORARY
TERMINATE
THEN
THREAD
TIME
TO
TRACING
TRANSACTION
TRIGGER
TRIGGERS
TRUE
TRUNCATE
TTC
TYPE
UID
UNDER
UNION
UNIQUE
UNLIMITED
UNTIL
UPDATE
UPI
USE
USER
USING
VALIDATE
VALUES
VARCHAR
VARCHAR2
VARIANCE
VIEW
VIEWS
WHEN
WHENEVER
WHERE
WHILE
WITH
WORK
WRITE
XA
XOR

Sunday, June 15, 2014

How to indent quickly Java code in notepad++

If you copied some java code from a pdf into Notepad++ it's highly probable that the original code indentation is lost.
How to make the java code look pretty again?
In Eclipse there is the keystroke CRTL+SHIFT+F but in Notepad++ there no such a thing, fortunately Notepad++ has a lot of plugins  :)
 
Choose Plugins-> Plugin manager -> Show plugin manager and install the plugin TextFX.

Restart Notepad++ then, select your ugly code and choose TextFX-> TextFX Edit -> Reindent C++ Code.

That's it.
Since java and C++ have similar syntax the indentation works just fine :)


Monday, June 9, 2014

Huge collection of old operating systems and software [ideal for emulators]

Today on OSNEWS.COM, I have found this article Huge collection of old operating systems

This site calls itself 'the biggest free abandonware downloads collection in the universe'. No idea if that's true or not, but all I can say is that I spent a lot - a lot - of time today browsing through the incredibly extensive collection of old operating systems. From an alpha release of Windows 1.0 to NEXTSTEP, this site has it all.
Great for emulators.


A GREAT repository but probably also illegal! 

Tuesday, May 27, 2014

How to continue getting updates for Windows XP

To continue receiving updates, add the following code to your windows registry

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\WPA\PosReady]
"Installed"=dword:00000001

No idea how long the trick will work...


http://betanews.com/2014/05/26/how-to-continue-getting-free-security-updates-for-windows-xp-until-2019/

Sunday, May 11, 2014

How to build a GUI interface in Matlab [tutorial with pictures/screenshots!]

Hello Everybody and welcome to this new tutorials series explaining how to build your own GUI in Matlab, because sometimes it is damn useful!


Building  a GUI in matlab is very very easy, you just have to pay attention to a few little things, as I will explain you on the way.

This series is divided into several parts, each of them analyzes a feature (using buttons, loading data, clear a graphs etc).

Part I: the Hello World program!

In this part, we will create our GUI, a simple application that, when we press a button!, displays the message "Hello World!" in a textbox.


1) Launching the GUI editor.

From the matlab prompt:

>> guide [ENTER]

A window named "GUIDE Quick Start" will appear.


Choose "Blank GUI (default)" and choose a path/name where to save the matlab figure, for example, my_gui.fig
The figure (file with .fig extension) is a window containing all your buttons, graph and so on.
When you'll run your GUI application, you'll execute the fig's content in "run mode" as you will see in a while.



After pressing OK, two windows will appear: a blank GUI window (my_gui.fig) and my_gui.m file already full of code!



When you want to run your application "my_gui" you can either run the .m or the fig file.
Try it! Click the green button on the fig editor. (A Matlab message could appear, asking you either to add the current path to the Matlab path or to just change the path, choose Add to Path).

When you run the gui, you get just a blank window: this is your application and it's black because we haven't anything ... yet! But it's your first (blank) application! Congratulations!


2) Adding button and textboxes.
Move on the figure editor and start putting elements on it.
First: we need a button, a push button to  be precise.
Select on the left menu "the push button" and then "draw" the push button in the right corner of the figure.



Second: from the left menu, choose "static text" and add such a field in the middle of the window.
The final result should be something like this:



Save the window and note, how the corresponding .m file (my_gui.m) will be updated as well.

2) Customizing the gui
Now that we have a push button and text box, it's time to personalize them a little.

Push button
Select the push button you have inserted, right click on it and choose the menu entry called  "Property Inspector".
The window below will appear:



Here we want to modify two properties: string and tag.
The string field is the text that will appear on the button and it's for the user interaction and must have a meaningful content like "exit", "clear graph", "save" etc.
The tag field is the name that the GUI object (button, graph, text...) has within the application and MUST be without spaces and unique within the GUI. Within the program, you need this tag in order to refer to a certain element. For example, when you want to write in a particular text box, you need its tag!

NOTE: while you can be highly free to chose your own texts for the string field, I suggest you to be consistent in choosing the tag field. My convention is to define tags in the format
"Type element" + UNDERSCORE + "what this element does". For the Push button, I have chosen:

string: Display Text
tag: pushbutton_displaytext


NOTE: The string text is optional, the tag is not!


We do not need other modifications for the moment, so just save the window.

Static text
As you did with the push button, select the static text, choose "Property Inspector" and modify "string" and "tag"


string: [blank]
tag: text_textbox
Save the changes.



4) Adding some code.
Now we have to code the behavior of our program:

When we press the "Display Text" push button, the text "Hello World!" in the text box will appear.


To do that, we have to work on the my_gui.m file and use a matlab function called "set"

What we want to do, can be translated in the following steps:

(a) pressing the "Display Text" button
(b) inserting text into the "Text box"
(c) updating the window

When an element (in this case a push button) is pressed, Matlab calls a "callback function".
This is just one of the possible interactions you can have with a graphical elements, since you can, for example, also go over a button without pressing it.

To access the callback function associated to the pushbutton_displaytext, select the button, right click and then View Callback-> Callback

You'll end up in the my_gui.m file, just where the callback function for pushbutton is defined, i.e pushbutton_displaytext_Callback(hObject, eventdata, handles)

There, insert the two lines of code:

set(handles.text_textbox, 'String', 'Hello World!');
guidata(hObject, handles);


What these two lines mean?

set(handles.text_textbox, 'String', 'Hello World!');
The set function takes a GUI object (handles.text_textbox) and edit the field called String with the content Hello World! All our object identifiers are stored as elements of the handles structure. Everything you define in it, is visible TO all the other elements, if you want to set some data globally available for your application, these data (arrays, cells, strings etc) must be elements of the handles structure. THIS IS AN IMPORTANT POINT. 

guidata(hObject, handles);

In matlab, every graphics "object" (a figure) is represented by a "handle" variable. That's the hObject and represents our window, our figure when we run the application. In this "master" handle, all the other handles of our GUI are stored through the handles structure.
By using guidata(hObject, handles) we are updating the content of our program. That's why it is damn important to be there!
When working with GUI, forgetting to use the guidata(hObject, handles) instruction is the most common error!

Run the program.

Now your program is finished and you can run it!


When you press the "Display Text", some text will appear in the text box and .... remain there!



5) Making the application look better: a self test for you.

clear button
If you understood everything until this point, you should be able now to improve the my_gui program adding an extra feature: a clear text button. When you press it, the text in textbox is cleared.

Hint: clearing some text, is like to overwrite it with an empty ( '' in matlab) text.

This is the final view of my_gui program.



Other things you can play around.

Font size
You can change the text size, by accessing the field FontSize text_textbox "property inspector".
For example change it to 20


Background Color
I would like some pale blue as background color for the text box, and some red for the Display Text button. Green, otherwise, seems a suitable choice to the Clear Text button.







That's all for today!
See you next time!


Saturday, April 26, 2014

Enabling/Disabling startup services in linux


Redhat, CentOS

ADD a service (in this example vsftpd)
 
# chkconfig vsftpd --add
# chkconfig  vsftpd  on --level 2,3,5


REMOVE a service (in this example vsftpd)

# chkconfig  vsftpd  off 
# chkconfig vsftpd --del


The new process will be added to /etc/init.d and a softlink will be put in all the required /etc/rcX.d folders (X stands for the runlevel)

While to start and stop a service...

# service vsftpd start
# service vsftpd stop
 

All the info you are looking for are available here:
http://www.aboutlinux.info



Friday, April 25, 2014

Authentication in SSH/SFTP via private/public keys

SSH/SFTP  login with public/private keys between a linux machine (server) and a windows (client)

This is a small guide, for mostly personal use, that's why it is not very detailed.
Anyway, the content is derived from the two references below:


(1) http://www.howtoforge.com/ssh_key_based_logins_putty
(2) http://sshkeychain.sourceforge.net/

- Generate keys with PuttyGen
     2048 bit, SSH-2 RSA
    add a key comment like name@machine
    add a passphrase (this is optional and I haven't done it)
- Save  the keys in a safe place
    NOTE: You can also export the private key in other format (SSH, openSSH)
- Copy the public key on the server you want to login into
    in the file  ~/.ssh/authorized_key2
- MODIFY the access of ~/.ssh to be readable/writeable/executable ONLY by that user:
        "chmod 0700 ~/.ssh"
- MODIFY the access of ~/.ssh/autorized_key2 to be readable/writeable ONLY by that user:
        "chmod 0600 ~/.ssh/authorized_keys2"   
- Disable the login with password by modifying (e.g. with vi) the file  "/etc/ssh/sshd_config" as it follows:
   
    Protocol 2
    PasswordAuthentication no
    UsePAM no

   
NOTE: in /etc/ssh there is ssh_config and sshd_config choose the right one!

- Restart the SSH server
    /etc/init.d/sshd restart

That's it.

Monday, March 31, 2014

could not find or load main class [java]

If you got this error "could not find or load main class" trying to execute your freshly compiled java program you have a problem with your classpath variable that doesn't include your current folder.
Solution:

Open the Control Panel -> System -> Advanced System Settings -> Advanced [table] -> environment variables and then "edit" your CLASSPATH adding a dot "." at the end.

PS
You have to re-open your Windows console to make the change active.

From the Oracle documentation
"The default class path is the current directory. Setting the CLASSPATH variable or using the -classpath command-line option overrides that default, so if you want to include the current directory in the search path, you must include "." in the new settings."

Monday, March 24, 2014

Oracle Database 11g R2: installation hangs [on Windows]!

You are on Windows and Your oracle 11g installation freezes/blocks/stops after the requirements page?

Probably there is an easy solution:

log in as administrator. Even if you tried to install the oracle database11g as a user with admin rights, this is not enough! You have to log in as Amistrator, then it works (probably)!


Oracle 11g R2 client install. hangs on step 5 of 7 in VM with Win. 2008 R2

Friday, March 14, 2014

ASCII, UNICODE, UTF-8, UTF-16, ... character set, encoding ecc

Here I found THE resource on the subjects: character set and encoding.
It's a small and effective guide to the mysterious world of character sets, encodings, Unicode, all that stuff.

http://www.joelonsoftware.com/articles/Unicode.html

Wednesday, March 12, 2014

How to remove Oracle DB 11 and 12 in Windows


http://stackoverflow.com/questions/8450726/how-to-uninstall-completely-remove-oracle-11g-client

http://docs.oracle.com/cd/E16655_01/install.121/e17720/remove_oracle_sw.htm#LADBI7824

  • Uninstall all Oracle components using command line uninstaller located at ORACLE_HOME\deinstall\deinstall
  • Run regedit.exe and delete the HKEY_LOCAL_MACHINE/SOFTWARE/ORACLE key. This contains registry entires for all Oracle products.
  • Delete any references to Oracle services left behind in the following part of the registry: HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/Ora* It should be pretty obvious which ones relate to Oracle.
  • Reboot your machine.
  • Delete the "C:\Oracle" directory, or whatever directory is your ORACLE_BASE.
  • Delete the "C:\Program Files\Oracle" directory.
  • Empty the contents of your "C:\temp" directory.
  • Empty your recycle bin.

Monday, March 10, 2014

Fundamentals of Mercurial: the version control software

This two are the most important references to Mercurial, the easy to setup version control system

http://hginit.com/index.html
This tutorial will explain you the fundamental ideas. Just pay attention that
hg commit -m "MESSAGGE"-u USERNAME

A lot of resources are available here!
http://mercurial.selenic.com/wiki/Mercurial


This is the workflow, to use when working with other people (from http://hginit.com/index.html)
  1. If you haven’t done so in a while, get the latest version that everyone else is working off of:
    • hg pull
    • hg up
  2. Make some changes
  3. Commit them (locally)
  4. Repeat steps 2-3 until you’ve got some nice code that you’re willing to inflict on everyone else
  5. When you’re ready to share:
    • hg pull to get everyone else’s changes (if there are any)
    • hg merge to merge them into yours
    • test! to make sure the merge didn’t screw anything up
    • hg commit (the merge)
    • hg push

Friday, February 28, 2014

How to create a shortcut button to a specific folder in total commander

I love total commander, it is my favorite file manager and I really miss it on my mac :(
Since I use it very often I found useful  to define shortcuts for some of my working folders.
How did I do this?
It's easy.

In this example, I will add a button to the toolbar pointing to my foo folder present on my C: drive, so it's path will be C:\foo

1)  In TotalCommander, select the Button Bar... entry from the Configuration menu.
All the buttons available at the moment on the toolbar are displayed.  

2) Click Add

3)  Fill the fields Command and Parameters as shown below:

Command: CD
Parameters: C:\foo


Useless to say, if you want a shortcut to another folder, just change the field Parameters accordingly.

4) Select a nice icon for the field Icon file. You can choose one your own .ico file by clicking on the >> button.

That's it!

PS
You can change the position of your shortcut too.


Sunday, January 19, 2014

Bjarne Stroustrup's quotation on C/C++

C makes it easy for you to shoot yourself in the foot. C++ makes that harder, but when you do, it blows away your whole leg. -- Bjarne Stroustrup

Friday, January 17, 2014

Which version of RedHat are you running?

Which version of RedHat are you running?
Just open a terminal and type this command

cat /etc/redhat-release

That's it!

Wednesday, January 8, 2014

Not enough free disk space (but there is!) error

Are you trying to save a big file (bigger than 4GB) on your pretty empty and pretty capable USB stick but you get the error "Not enough free disk space"?
The problem is probably due to the fact that your USB is formatted as FAT32.
This file system simply cannot handle file bigger than 4GB.
The solution is to format your USB drive to NTFS, this is the file system used by Windows XP/VISTA/7/8.
In this way your USB drive will be fully writable/readable by Windows/Linux and Mac (with Paragorn installed) systems.

NOTE:
Formatting your USB drive WILL DELETE its content! So make a backup first!

Monday, January 6, 2014

What is the best online backup solution?

My favorite online backup solution is Dropbox.
Easy to use. Powerful. Available for all the major platforms. And it has nice icons too!
The only drawback is the available space. With a free account you start with 2 GB but with referrals among your friends you can reach 16 GB.

Sunday, January 5, 2014

JAVA: Difference between Integer.valueOf and Integer.parseInt

In Java, to convert a String into an integer you can use either

Integer.valueOf(String) 

or

Integer.parseInt(String). 

But what is the difference between them? Well 

Integer.valueOf(String) gives as result an Integer object.

Integer.parseInt(String) gives the primitive Java type int

How to display your bash history on OSX

To diplay (in a new TextEdit window) the last commands typed in your terminal, just open a new terminal, give the command cd to go into your home folder and type this command:

open .bash_history

By default,  the number of lines saved in your .bash_history file is set to 500.