GoogleMaps API multiple markers

•May 16, 2014 • Leave a Comment

I have a database with some records that among other details they also declare a local (Greek) street addresses. The requirement is to retrieve all these records from the database and display them with markers on a Google Map. Before everything, if you want to get an idea on how the API works see the following links:

- GoogleMaps API – Getting started
GoogleMaps API – Simple markers

The flow for my task has as follows:

- Connect to database
– Retrieve all the locations from DB
– Convert Greek characters to Latin for avoiding issues with the Web Service request [ code on code.loon.gr ]
– Use GoogleMaps API to retrieve GPS coordinates based on the given location
– Parse JSON response
– Use JavaScript to add the markers layers

Full code on GitHub.

 

Croogo : ελληνική μετάφραση

•May 9, 2014 • Leave a Comment

Μετάφραση στα ελληνικά του locate για το back-end του Croogo. Διαθέσιμο στο GitHub.

Στη δουλειά με ποδήλατο

•May 8, 2014 • Leave a Comment

Remote cPanel backup via FTP

•January 30, 2014 • Leave a Comment

Here is the scenario:

- Domain that needs to be backed up (public_html, mail, database).
– Only access available via cPanel and FTP.
– Need automated daily full backup.

Solution:

- Take full backup on server and compress its contents (cronjob on remote server)
– Download via FTP the compressed file to the local machine (cronjob on local machine).
– Delete compressed file.

There might be tools that do this, although I didn’t come across any while looking on the web. I implemented a simple solution based on bash scripts that gets the task done.

- backup.sh: Goes on the remote server to run as a cronjob.
ftp.sh: Runs locally (on the machine that will store the backup) as a cronjob.
.netrc: Defines the FTP account details (stored in /home/$user/.netrc)

Gmail SMTP relay with Postfix

•November 11, 2013 • 3 Comments

The following configuration has been performed in Debian but should apply in any Linux distro with Postfix installation. The task quite simple: use Gmail as SMTP relay for outgoing email traffic.

1) At first place I had to install the following packages and turn off sendmail:

apt-get install postfix mailutils libsasl2-2 ca-certificates libsasl2-modules
service sendmail stop

2) Then edit the configuration file at /etc/postfix/main.cf by adding the following options at the end of the file:

# Gmail SMTP relay
relayhost = [smtp.gmail.com]:587
smtp_use_tls=yes
smtp_sasl_auth_enable = yes 
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
smtp_sasl_security_options =

3) Create the authentication file at /etc/postfix/sasl_passwd and set the right permissions:

[smtp.gmail.com]:587    <username>@gmail.com:<password>
chmod 400 /etc/postfix/sasl_passwd

Make sure the file is owned by the user who runs the Postfix daemon.
4) Reload Postfix:

service postfix reload

5) Confirm the configuration is actually working by sending a test mail:

echo "Test mail from postfix" | mail -s "Test Postfix" pkritikakos@isbs.gr

The sender of the email should be the given Gmail account. Also, in the “Sent” folder of the Gmail account you should see the email you have sent with Postfix.

If your domain is using Gmail’s infrastructure for handling emails, you can replace @gmail.com with your domain and use the corresponding account details.

NOTE: This configuration will be sending any system message as “username@gmail.com” and therefore is not advised to be used in multi-user environment.

Java HTTP library

•November 5, 2013 • Leave a Comment

Being in need to issue POST requests from within a Java application, and wanting re-usable code, I created a very simple Java library for issuing POST and GET requests to a remote server.

POST source codeGET source code

Usage (POST example):

POST post = new POST();
post.postRequest("http://www.myservice.com/service", "param1=foo&param2=bar", "Mozilla/5.0");

In other words, the arguments are:

post.postRequest(SERVER_URL, PARAMETERS, AGENT);

The output can be manipulated as desired, depending on what you response you except you should use a corresponding element/object.

Java libary in Android project

•November 5, 2013 • Leave a Comment

If you have developed your Java library that you would like to use within your Android project, or you want to use an existing Java library, make sure that the library itself is compiled with Java 1.6 rather than 1.7. Have been always forgetting that and have wondering for a couple of days why am I getting “NoClassDefFoundError” error.

 
Follow

Get every new post delivered to your Inbox.