Sunday, December 11, 2011

Java SimpleDateFormatter string formats

SimpleDateFormat is a concrete class for formatting and parsing dates in a locale-sensitive manner. It allows for formatting (date -> text), parsing (text -> date), and normalization.

Date and time formats are specified by date and time pattern strings. Within date and time pattern strings, unquoted letters from 'A' to 'Z' and from 'a' to 'z' are interpreted as pattern letters representing the components of a date or time string. Text can be quoted using single quotes (') to avoid interpretation. "''" represents a single quote. All other characters are not interpreted; they're simply copied into the output string during formatting or matched against the input string during parsing.

Saturday, December 3, 2011

Rest services guide for Drupal 7



You will need to download the latest version of SYPC and Mimeparse:
wget http://spyc.googlecode.com/svn/trunk/spyc.php -O  servers/rest_server/lib/spyc.php

Once downloaded you need to add spyc.php to the rest_server/lib folder which exists under
the location you have installed services in.

LogIn
POST http://<My drupal website>/<Path to endpoint>/user/login
Request Payload:

{

    "username": "<username>",
    "password": "<password>"

}



LogOut
POST http://<My drupal website>/<Path to endpoint>/user/logout
Request Payload:

{
    "username": "<username>",
    "password": "<password>"
}



Tuesday, July 12, 2011

Syntax Highlighting on Blogger

The easiest way to paste code into blogger with nice syntax highlighting:

  1. Go to http://gist.github.com
  2. Past the code you want to post
  3. Copy the embed tag
  4. Go back to blogger, and select "Edit Html"
  5. Paste the embed tag into your post

In this post you can see some example of code highlighting: http://ddelizia.blogspot.com/2011/07/geocoding-address-with-google-maps-api.html

Geocoding an address with Google Maps API in Java

Geocoding is the process of finding associated geographic coordinates (often expressed as latitude and longitude) from other geographic data, such as street addresses, or zip codes (postal codes). With geographic coordinates the features can be mapped and entered into Geographic Information Systems, or the coordinates can be embedded into media such as digital photographs via geotagging.
I made a simple method that giving an address it returns a list of with the corresponding formatted address, latitue, longitide, separated by ";".

Thursday, February 24, 2011

How to enable/disable root account on Ubuntu

If you want to enable root account (which is not recommended) enter the following command:
sudo passwd root
This will prompt for a new root password and once you confirm it, you can start using the root account to login.
If you want to disable root account in ubuntu you need to lock the root account by using the following command
sudo passwd -l root
If you want to work on a root console you’d better use the following command
sudo -i

Wednesday, February 23, 2011

Hot to Start/Stop/Restart Tomcat on Ubuntu Server (10.10)


During the installation of Ubuntu you can choose to install and configure automaticaly Tomcat 6. Here are the commands to start/stop/restart the server:

Start:
sudo /etc/init.d/tomcat6 start

Stop:
sudo /etc/init.d/tomcat6 stop

Restart:
sudo /etc/init.d/tomcat6 restart

Tuesday, February 22, 2011

How to install BOTS EDI on Ubuntu Server 10.10 with MySQL Database

Bots is complete software for EDI (Electronic Data Interchange): translate and communicate.
All major edi data formats are supported: edifact, x12, tradacoms, xml.
Here some tips for the installation process on ubuntu server using mysql instead of sqlite as database
Fisrst of all we need to install the following packages:
sudo apt-get install python-cherrypy3 python-django python-mysqldb python-sqlalchemy
Let's create a new user and db schema for BOTS:
mysql -h localhost -u root -p
CREATE DATABASE botsdb CHARACTER SET 'utf8';
CREATE USER 'bots'@'localhost' IDENTIFIED BY 'botsbots';
GRANT ALL PRIVILEGES ON botsdb.* TO 'bots'@'localhost';
Download the program and uncompress it, then check if you have installed python (normally should be already installed), if not go to synaptic and search python select it and install it (the dependencis will be installed automatcatly)
tar -xzvf bots-2.0.2.tar.gz
django-admin syncdb --pythonpath='/home/danilo/bots-2.0.2/bots' --settings='bots.config.settings'

sudo python setup.py install
defde

Monday, February 21, 2011

How to share a folder on virtual box with Windows Host and Ubuntu Guest

Start Ubuntu on Virtual Box then follow these steps:
  1. On the virtual box menu go to Device > Shared Folder
  2. Add a new shared folder
  3. Select the windows path to the folder you want to share and then give a name to the folder (f.i. MY_WINDOWS).
  4. Select "Permanent" to permanently share this folder.
  5. Now is the time to mount this shared windows folder on a ubuntu folder. So lets create a folder in our home directory and lets name it WINDOWS_FOLDER
  6. from the command line:
    sudo mkdir /home/danilo/WINDOWS_FOLDER
  7. So now that we created the folder on Ubuntu lets mount on it the windows folder:
    sudo mount.vboxsf MY_WINDOWS /home/danilo/WINDOWS_FOLDER 
  8. Done!
Now you can write/read to/from this folder

If you want to mount this folder when ubuntu start open a terminal and write:

sudo nano -w /etc/rc.local
Add this line to the file:
mount.vboxsf MY_WINDOWS /home/danilo/WINDOWS_FOLDER

<press ctrl-x to save>

Ciao