Author Archives: Berend de Jong

Convert eml email to outlook pst

outlook

Did you ever want to import messages in the EML format to outlook and could not find an easy way to do this? This post describes the step to take, and the software to use, to make such a conversion easy.

You can add these EML files to your PST file with the help of OutlookFreeware.com Utilities. It lets you select the EML files to store and the destination location in Outlook. Works very good and its completely free (only needs registration).

Goto http://www.outlookfreeware.com/en/products/all/OutlookMessagesImportEML/ to get a copy. You will also need the “OutlookFreeware.com Runtime“.

Share

Subversion and commands

This subversion tutorial describes the common subversion commands to maintain your repository.Subversion tutorial and commands

Setup a new repository on your diskstation (see this article for instructions to install Subversion onto your DiskStation):

  1. Goto your DiskStation box with the SVN server and create the repository:
    /opt/bin/svnadmin create myrepo
  2. Edit the passwd file in /volume1/svn/myrepo/conf/passwd; add a line below [users]:
    myrepousr=myrepopwd
  3. Edit the svnserve.conf and add the line
    anon-access=none
  4. Uncomment the line
    passwd-db=passwd

Now to add an existing folder to this new repository execute the command below:
svn import localdir svn://diskstation.local/myrepo

The local directory localdir is now under source control. Add some files to the local directory and execute the status command:

svn status
?       newfile

The files you just added are shown starting with a question mark. You can add the new files to your repository with the add command:

svn add newfile
A      newfile

The file is now added to source control but it is not committed yet; lets do that now with the command commit command:

svn commit

Your default (terminal) editor will open and you are allowed to type a comment for this new revision; go ahead and type your comment (or leave it empty). After you type your comment press Ctrl-X; if you typed a comment pres Y and press enter; otherwise press c.

Subversion responds with the message below; your newfile is added:

Adding newfile
Transmitting file data .
Committed revision 119.

Delete a file from your repository with the delete command:

svn delete newfile
D        newfile

Commit the delete action with the commit command:

svn commit
Deleting newfile

If you ever run into the warning message “Directory ‘current/dir’ is out of date update local files” you have to update your local copy of the repository; execute the command below:

svn update

Add all new files to the SVN repo:

svn status | grep -v "^.[ \t]*\..*" | grep "^?" | awk '{print $2}' | xargs svn add
Share

NetBeans installation

netbeansDownload NetBeans at here. This script will install the Java JRE and NetBeans in one go.

After installation start up the NetBeans IDE. If you are running under gnome the fontsize is a bit big.

You can change this by adding

–laf javax.swing.plaf.metal.MetalLookAndFeel –fontsize 14

to your desktop shortcut. Th desktop shortcut is located at ~/.local/share/applications/. Change the line that starts with Exec to:

/bin/sh "/home/berend/netbeans-7.4/bin/netbeans" --laf javax.swing.plaf.metal.MetalLookAndFeel --fontsize 12

Now it is time to install the PHP plugin. Go to Tools -> Options; order by name and search for the PHP plugin. Select it and press install. Accept the dependencies and the license and press install. Choose restart the IDE now and press Finish.

Install also the PHPUnit plugin to help you create Unit testing classes.

Share

phpStorm 7 / XDebug environment configuration

The phpStorm 7 IDE is an excellent tool to write your PHP code in. This post describes the step to take to debug your PHP website with phpStorm 7 and XDebug. This post only describes the installation of XDebug and the use of phpStorm 7. You can also find posts about installing Apache and Mysql on this blog.

Configure phpStorm 7 / XDebug environmentFirst of all download a copy of phpStorm 7 and unpack it to a directory of your choice. PhpStorm 7 depends on java so you should also install java onto your system.

Next thing to do is configure XDebug and Apache to work together. First step is to determine the active php.ini . This can easily be done by creating a PHP script with a call to phpinfo();.

Copy the contents of this page (not the page source) and paste it into the textbox found at http://xdebug.org/wizard.php.

Download the XDebug archive at http://xdebug.org/files/xdebug-2.2.3.tgz. Unzip the archive with

tar -xzvf xdebug-2.2.3.tgz

Goto the directory created by the unzip command:

cd to xdebug-2.2.3

Run the phpize command (prepare PHP extension for compiling); the output should be something like:

$>phpize
Configuring for:
PHP Api Version: 20100412
Zend Module Api No: 20100525
Zend Extension Api No: 220100525

When you see something like the text above you know you’re good to go.

Execute ./configure to configure the make script

./configure

When configure runs ok execute the make command:

make

After the make command has finished you have a compiled xdebug.so  module in the modules directory.

Copy the xdebug.so  module to /usr/lib/php5/[Zend Extension value from phpinfo(); call]

Now in the output of the phpinfo()  call search for the value Loaded Configuration File. The second column shows the active php.ini . Edit this file and add the lines below (uncomment any [zend] section if it exists):

[XDebug]
zend_extension="/usr/lib/php5/20100525/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.profiler_enable=1
xdebug.profiler_output_dir="/tmp>"

Change the location of zend_extension as needed!

Restart your apache server:
sudo service apache2 restart

Rerun your phpinfo() script and paste it again into the textbox at http://xdebug.org/wizard.php

Check for a line that says something like “You’re already running the latest Xdebug version “, If it is there you have configured PHP to use the XDebug extension.

Now it is time to startup phpStorm 7 and create our first PHP project. Start your copy of phpStorm 7.

Select “Create New Project” (choose “Empty project for now; be sure that the location is in or below the DocumentRoot of your apache site) and follow the steps below:

  1. Add a new file index.php  and add a call tophpinfo()  to it (right click the project title on the left; select New -> PHP File).
  2. Select Run -> Edit configurations
  3. Select the + sign at the top left and select “Php Web Application”
  4. Name it for example “WebAppDebugConfig”
  5. Press the “…” after “Server” to add a server.
  6. Press the + sign at the top left.
  7. Change the servername to the name of your development host (both Name and Host) and press Ok
  8. Select the Server Name in the “Run/Debug Configurations” to make the error go away
  9. Fill out your start URL; /index.php 
  10. Press Ok

 

Share

Sublime 3 and the Emmet plugin

After installing Sublime 3 and the package control center you should also install the incredible Emmet plugin.

This plugin helps you write HTML / CSS code lightning fast.
emmetio

For example:
Create a new document in Sublime and save it as index.hml. Inside the sublime editor type

html:5<press tab>

The following HTML document will be generated:

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>

</body>
</html>

After you press tab  a default HTML 5 template will be generated. The cursor is positioned at the <title>  tag; this is the most likely item you are going to change. Type your title and move the cursor after the <body>  tag. The type:

ul>li*2>a.link-${$}<press tab>

After you press tab the following HTML will be generated:

<ul>
<li><a href="">1</a></li>
<li><a href="">2</a></li>
</ul>

Explanation of the shortcode:
Create an ul  and with that 2 li  items. Within theli  ahref  is generated with a class link followed by a sequence number. The {$}  inserts the sequence number as text.

Share
GIT logo

Mount NFS share under Ubuntu

On the server:

Edit the file /etc/exports  file and add the line:

/share hosts(rw,nohide,insecure,no_subtree_check,async,all_squash,anonuid=idofshare,anonguid=guidofshare]

Example:

/home *(rw,nohide,insecure,no_subtree_check,async,all_squash,anonuid=1008,anongid=1008)

Explanation:

/share  is the location you want to share
hosts  is the specification of hosts you allow access
all_squash  to translate all anonymous id’s (not known on server) to the give anonuid and anongid
no_subtree_check does no checking on the complete subtree of filepermissions (see also here)

After adding or changing an export to the /etc/exports file don’t forget to restart the NFS server:

sudo service nfs-kernel-server restart

On the client:

To view the list of exported shares on the server execute the command:

showmount -e [ip_of_server]

 

Example of output:

Export list for 192.168.2.200:
/home *

To mount the NFS share local create a new subfolder and execute the command:

mount -v [host]:/home ~/home/

This will mount the folder /home on the server local on your /home/ folder.

 

 

Share

Send email with PHP script

So you want to send an email through a PHP script. Well that is dead simple (provided you have your smtp server setup correctly). See the code fragment below:

$to = "email@to.com";
$subject = "Your subject";
$message = "Your message";
$headers = "From: webmaster@from.com" . "\r\n" .
   "Reply-to: webmaster@from.com" . "\r\n" .
   "X-Mailer: PHP/" . phpversion();
mail($to, $subject, $message, $headers);

 

Share

Analyze IP addresses accessing your Apache server

The awk command below retrieves the first column of your apache log file which containsscript the IP address of the browser accessing your host (if you have a virtual host setup with the vhost_combined CustomLog you should retrieve column 2 instead).

After retrieving the column it is sorted and all unique values are determined and counted. After that the list of unique values and there count is sorted (reverse) to get the top list of IP’s.

awk '{ print $1}' $LOGFILE | sort | uniq -c | sort -nr > $DEST

Output of this statement:

606 188.203.177.225
502 84.87.80.237
376 86.81.89.200
365 24.132.181.21
295 94.212.84.128
279 86.81.89.250
251 94.212.208.48
235 85.150.175.72
226 94.212.194.142

 

 

Share

Apache deny and allow access from ipaddress

With help of a .htaccess file we can deny or allow access from a specific ip address or range of ip addresses.

Deny access from all IP addresses in the range 192.168.2.*:

<Limit GET HEAD POST>
order allow,deny
allow from all
deny from 192.168.19.
</Limit>

The line order allow,deny means that Apache should first evaluate the allow entries (which states that everyone is allowed access) and then the deny entries (which states that the range 192.168.19.* is denied access). Effectively this means that the range 192.168.19.* is denied access.

Order of evaluation is allow, deny; so this means:
allow access from all
deny access from 192.168.19.

Allow only access from the IP range 192.168.19.*:

<Limit GET HEAD POST>
order deny,allow
allow from 192.168.19.
deny from all
</Limit>

Order of evaluation is deny, allow; so this means:
deny access from all
allow from 192.168.19.

Share