Archive for the ‘programming’ Category

Restore deleted folder in SVN after commit

Saturday, January 29th, 2011

If you delete a remote folder in SVN accidentally it gets tricky to restore it back. This can happen by commiting an unwanted deletion. So, basically, what you have to do is:

  • Create a working copy of the deleted folder’s parent. You can use -N parameter that indicates “No checkout”. This will prevent from actually downloading any code. Run:

svn co -N SVN_PARENT_URL .

  • Get a copy of the deleted folder from the revision before the deletion. Run:

svn copy SVN_PARENT_URL/DELETED_FOLDER_NAME@REV DELETED_FOLDER_NAME

  • Commit to HEAD. This will actually commit a new revision with the contents of the revision before the deletion. Therefore restoring the “original” folder. Run:

svn commit -m “Restoring” DELETED_FOLDER_NAME


Source: http://www.freshblurbs.com/svn-restore-deleted-folder-revision

.

Squirrel SQL: Universal SQL Client

Saturday, November 13th, 2010

Squirrel SQL (http://www.squirrelsql.org/) is an open-source software developed with Java to manage databases. This means:

  • you can control as many DBs as JDBC drivers exists out there (MySQL, Oracle, Postgresql, etc, etc.)
  • you can run it in Linux, MacOS, Windows, etc, etc.
  • it’s free.

graph Squirrel SQL: Universal SQL Client

Check complete features and screenshots here.

Apache Cassandra with Java

Thursday, May 6th, 2010

Excelent tutorial for Apache Cassandra by Ronald Mathies of Sodeso.

Edit: links are dead :(

Phase Relationships in the Standardization Process

Tuesday, April 13th, 2010

A bit sarcastic yet almost-always-true article written by James Gosling in 1990 (20 years ago), about politics in the software development industry.

http://nighthacks.com/roller/jag/resource/StandardsPhases.html

Enjoy!

How to remove .svn directories recursively

Saturday, April 10th, 2010

Just type this in your console:

rm -rf `find . -type d -name .svn`


Anemic Domain Models

Saturday, February 13th, 2010

A post by Martin Fowler that talks about a very common and used way of defining the domain layer and service layer in an application.

http://www.martinfowler.com/bliki/AnemicDomainModel.html

Some quality reading…

Tuesday, January 26th, 2010

http://techdistrict.kirkk.com/2009/11/03/turtles-and-architecture/

http://techdistrict.kirkk.com/2009/12/15/architecture-all-the-way-down/

Thanks, Jorge!

App installers for Java

Wednesday, November 11th, 2009

IzPack is a one-stop solution for packaging, distributing and deploying applications.

It is fully cross-platform and generates a single installer. As such, it is an alternative to native solutions such as platform-specific installers and package managers.

IzPack-generated installers only require a Java virtual machine to run.

Further on: http://izpack.org

5 days of Apache Wicket

Wednesday, October 28th, 2009

5 days of Wicket!

Source: http://www.mysticcoders.com/blog/2009/03/09/5-days-of-wicket/

2 amazing books I am reading rigth now

Saturday, October 3rd, 2009

These are 2 amazing books I am reading right now.

  • Head First Design Patterns
  • Wicket In Action

I post here the Amazon links, feel free to use them.


Cheers… 

Turn off Eclipse's tooltips

Monday, September 21st, 2009

Go to:

Window > Preferences > Java > Editors > Hovers

and disable Combined Hover.

Source: http://stackoverflow.com/questions/871732/turn-off-tooltips-in-eclipse-aptana

Remember Goto statement?

Thursday, September 3rd, 2009

One programmer in anger says to the second programmer:
- “Go to Hell!”

The second programmer replies, in obvious repulsion:
- “Ugh, you used goto!”

LOL

Non Relational DB: The (near?) future of databases.

Saturday, July 25th, 2009

Neo4j:

“Neo4j is a graph database. It is an embedded, disk-based, fully transactional Java persistence engine that stores data structured in graphs rather than in tables. A graph (mathematical lingo for a network) is a flexible data structure that allows a more agile and rapid style of development.
[...]
Neo4j has been in commercial development for 8 years and in production for over 5 years. It is a mature and robust graph database[...]
In addition, Neo4j includes the usual database features: ACID transactions, durable persistence, concurrency control, transaction recovery, and everything else you’d expect from an enterprise-strength database.[...]“

http://neo4j.org/

http://giladmanor.blogspot.com/2009/07/down-rabbits-hole-with-neo4j-part-1.html

mongoDB:

“MongoDB is a high-performance, open source, schema-free document-oriented database.[...]
When we describe MongoDB as “document oriented”, we mean it’s in the class of databases for which the primary storage unit is a collection – possibly structured – of data, most likely as key/value pairs.”

http://www.mongodb.org

Hypertable:

“Hypertable is an open source project based on published best practices and our own experience in solving large-scale data-intensive tasks. Our goal is to bring the benefits of new levels of both performance and scale to many data-driven businesses who are currently limited by previous-generation platforms.”

http://www.hypertable.org/

Dynamo:

“Unlike a relational database, Dynamo is a distributed storage system. Like a relational database it is stores information to be retrieved, but it does not break the data into tables. Instead all objects are stored and looked up via a key.”

http://www.allthingsdistributed.com/2007/10/amazons_dynamo.html
http://www.readwriteweb.com/archives/amazon_dynamo.php

Extra info:

http://www.computerworld.com/s/article/9135086/No_to_SQL_Anti_database_movement_gains_steam_?taxonomyId=173&pageNumber=1&taxonomyName=Databases

Subversion (SVN) with WebSVN, DAV and Apache2 under Ubuntu

Saturday, July 4th, 2009

Install Subversion:

Use the following command to install Subversion and the Apache2 module:

sudo apt-get install subversion libapache2-svn

Create a repository:

Use the following command to create a repository:

sudo svnadmin create /var/svn/new-project/

Add permission to the directory for the Apache user only:

chmod -R 775 /var/svn/new-project

chown -R www-data:www-data /var/svn/new-project

Configure Apache

Open /etc/apache2/mods-available/dav_svn.conf and add a new “virtual directory”:

<location /svn>
DAV svn

SVNParentPath /var/svn

AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/dav_svn.passwd

AuthzSVNAccessFile /etc/apache2/dav_svn.authz

Require valid-user

</location>

Create the users password file. Use the following command the first time only, the -c parameter will create AND override the file if it exists:

htpasswd2 -c /etc/apache2/dav_svn.passwd username

To add other users or change password use:

htpasswd2 -m /etc/apache2/dav_svn.passwd username

In /etc/apache2/dav_svn.authz, add the users permissions

[/]
me=rw

[new-project:/]
other.user=rw

Finally, restart Apache so that the changes take effect:

apache2ctl restart

Eclipse 3.4 Show and Hide Breadcrumbs

Thursday, June 18th, 2009

Eclipse 3.4 Ganymede comes with a very handy Breadcrumbs Navigator which creates a breadcrumb above the source code editor. To open it, right click on the Java Editor and choose “Show in Breadcrumb”. Or simply toggle this navigator with the toolbar button:

eclipse breadcrumb Eclipse 3.4 Show and Hide Breadcrumbs
For those of you who are unaware of what breadcrumbs do, it is navigation aid used in user interfaces. The term breadcrumbs comes from the trail of breadcrumbs left by Hansel and Gretal in the famous fairytale. It is a method for users to keep track of their locations in programs or documents.

Interesting way of defining Java exceptions

Thursday, May 28th, 2009
java.lang
ArithmeticException You are trying to use your computer to solve a mathematical problem that you cannot solve yourself. Read up on your arithmetics and try again.
ArrayIndexOutOfBoundsException See IndexOutOfBoundsException. The difference is that this exception refers to more than one finger.
ArrayStoreException You have used all your arrays and need to buy more from the array store.
ClassCastException You need to stay in the class or caste you were born into. Java will not accept dailits acting as kshatriyas or noblemen pretending to be working class. Note the spelling mistake (of caste) that was introduced in Java 1.0 and has not been corrected for backwards compatability reasons.
ClassNotFoundException You seem to have invented your own class. There are also caste systems that are not yet implemented in Java, most notibly the balinese caste system. For example, if you are a wesia, use the indian counterpart vaishya.
CloneNotSupportedException You are a clone. Find the original you, tell him what you want to do and then kill yourself.
IllegalAccessException You are a burgler that are running a Java program during a burglery. Please finish stealing the computer, leave the premises and try again.
IllegalArgumentException You have tried to protest against a previous exception.
IllegalMonitorStateException Please turn your computer screen back on.
IllegalStateException You come from a state that is not yet recognized by the UN, possibly Kurdistan or Palestine. Get a real citizenship, recompile your java code and try again.
IllegalThreadStateException One of the screws in your computer is threaded the wrong way. Please contact your hardware vendor.
IndexOutOfBoundsException You have put your index finger in an unacceptable place. Reposition it and try again.
InstantiationException Not everything can happen instantly. Please be more patient.
InterruptedException Tell your colleagues, room-mates etc. to leave you alone while you are working.
NegativeArraySizeException You have created an array with negative size. This can cause information to be lost and in the long run the Universe will be destroyed. Be happy that Java noticed what you were doing and DON’T DO IT AGAIN.
NoSuchFieldException You are trying to have a picknick on a field that does not exist. You can also get this exception if you try to visit an airfield that in fact does exist, but has been classified as top-secret. I’d give you examples, but then I’d have to kill you.
NoSuchMethodException Don’t use that method! Please, do things like we have always done.
NullPointerException You do not own a dog. Get one, for example a brittany spaniel, and try again.
NumberFormatException You are using outdated units of measurement, for example inches or pints. Convert to SI. There is a known bug that causes this exception to be thrown if you are very short or tall.
RuntimeException You cannot run fast enough, possibly due to obesity. Turn off your computer and go out and get some exercise.
SecurityException You have been deemed a threat to nationaly security. Please sit still and wait for the authorities to come and get you.
StringIndexOutOfBoundsException Your panties have shiften out of place. Adjust them and try again. You can also get this exception if you are not wearing any panties at all.
UnsupportedOperationException You are trying to have an operation that for some reason, ethical or otherwise, is not supported by Java. Examples of this include unneeded amputations, for example circumcisions. Please stop abusing your body and do not remove pieces of you child, damn it!

See more at: http://rymden.nu/exceptions.html

SVN back-up and restore

Friday, May 22nd, 2009

To back-up my SVN repository, I have the following script:


#!/bin/bash
SVNDIR=/var/svn
DATE=`date +%d-%m-%Y`
TARNAME=svn_dump_$DATE.bz2
cd $SVNDIR
rm -f *.svndump
rm -f *.bz2
for repo in $(ls -d */)
do
filename=`basename $repo | cut -d\. -f1`
svnadmin dump $repo > $SVNDIR/$filename.svndump
done
tar -cvz -f $SVNDIR/$TARNAME *.svndump
cp $TARNAME /home/yo/svn_dump

Basically, it iterates thru all my repositories in SVNDIR and dumps them (the back up process itself) with svadmin dump.... After that it tars and compress the *.svndump files in one single file TARNAME and then copies it to its final destination /home/yo/svn_dump from where I grab the tar.bz2 files and burn them in a DVD or whatever.

I also have a cron job as follows:

0 0 * * 7 /home/yo/bin/scripts/svndump.sh >/dev/null 2>&1

which runs the script above once a week.

To restore a svn dump file I have to:
1) Untar the tar.bz2 back up file.
2) With the result I run: svnadmin load /path/to/reponame < filename.svndump
3) Set the correct permissions to the restored repositories. This is needed if you restore the back-up in a different path or computer.

That's pretty much what I do. My source code is safe in several different places (I'm a little bit paranoid, I know...)

Using SVN with Subclipse

Saturday, May 2nd, 2009

If you want to know the basics of SVN with Subclipse there’s no need to add anymore than what this article already says.

http://www.saltycrane.com/blog/2007/03/how-to-setup-subclipse-project-to/

Was really helpful and clear to me.

Java with GUTs

Wednesday, April 15th, 2009

This is a great article on writing unit tests. It will give you a lot of background information and further reading links, as well as different points-of-view and opinions.

Part 1: http://www.javaworld.com/javaworld/jw-03-2009/jw-03-good-unit-tests-1.html
Part 2: http://www.javaworld.com/javaworld/jw-04-2009/jw-04-good-unit-tests-2.html

Enjoy it!

The 30 skills every IT person should have

Friday, January 23rd, 2009

Interesting article:

“…An IT manager’s guide on how to be better at what you do, no matter how experienced you are…”

http://www.infoworld.com/article/08/06/02/23FE-how-to-fire-IT-staff-skills-list_1.html