rsync to Amazon AWS server using PEM file

One liner here:
rsync -rave --filter='merge public/.rsync-filter' "ssh -i /keypath/key.pem" $PWD/public/* ubuntu@55.55.55.55:/var/www/www.server.com/

Posted on March 24, 2015 at 14:19 by arte · Permalink · Leave a comment
In: English, Linux

How quickly copy one DB to another

Well, this is quite simple actually:
mysqldump -u db_user -pYourPass -h 127.0.0.1 database_name_from | mysql -u db_user -pYourPass -h 127.0.0.1 database_name_to

Posted on September 10, 2013 at 18:03 by arte · Permalink · Leave a comment
In: English, Linux, mySQL, Ubuntu

MS’SQL on Ubuntu Linux via PHP

Hi Folks,

today we are going to install & use MS’SQL on Ubuntu Linux! Yay!

Well, in fact installation is very simple with a tiny twists 😉

Installation (very simple):

sudo apt-get install php5-mssql

Now how to use it?

PHP Code below:


// Connect to MSSQL
$link = mssql_connect($db['from']['server_ip'], $db['from']['username'], $db['from']['password']);
if (!$link) {
    die('Something went wrong while connecting to MSSQL');
}else{
    if( mssql_select_db($db['from']['database'],$link) ){
        echo "<h2>DB Selected: ".$db['from']['database']." </h2><hr>";
    }else{
        die("DB Not selected");
    }
    
    $sql="SELECT TOP 20 * FROM yaf_User";
    $sql_resource = mssql_query($sql);
    while($row = mssql_fetch_array($sql_resource)){
        echo "<br>".$row['Name'];
    }
    // Clean up
    mssql_free_result($sql_resource);
}

Looks simple – doesn’t? Well – there is a catch 😉 With Select * from table; you will most definitely get an error message saying something like:

Unicode data in a Unicode-only collation or ntext data cannot be sent to clients using DB-Library (such as ISQL) or ODBC version 3.7 or earlier.

There are are two ways of fixing it.

Option 1:
Request fields with SQL Casting: SELECT CAST(field1 AS TEXT) AS field1 FROM table
So you cast your field as text for every varchar (or sometimes nvarchar in MS’SQL). Lousy option – to be honest. But works great for a quick fix.

Option 2:
Convert you PHP & your DB connection and everything arounf it to use proper UTF-8 aka Unicode.

Change this file: /etc/freetds/freetds.conf

Add lines as below:

[global]
;tds version = 4.2
tds version = 8.0
client charset = UTF-8

I also changed php.ini file (but not sure if it’s really needed):

mssql.charset = "UTF-8"

Have fun with you MS’SQL!

Posted on September 10, 2013 at 15:21 by arte · Permalink · Leave a comment
In: English, Fighting the system, Linux, MS'SQL, Ubuntu

How to add new MySQL user from the command Line

Very simple actually.

GRANT ALL PRIVILEGES ON *.* to root@127.0.0.1 identified by 'secretpassw0rd'

Posted on July 8, 2013 at 16:07 by arte · Permalink · Leave a comment
In: English, mySQL

MS NAV Web Services to/from PHP, receiving and sending data

Some time ago I came across a project where I had to connect MS’NAV and Drupal, two completely different systems one is proprietary (hello MS) and another is PHP & MySql (welcome, open source!)
There where few options how both systems could communicate automatically, but unfortunately REST was not available as an option on the MS’NAV version I had to connect to, so I was left with only option – SOAP.

Don’t get me wrong – I’ve developed multiple SOAP services in Java and PHP, used different libraries, so I am not new to the technology. I do have my own opinion about it and consider it slightly “redundant”, but… in this case I didn’t have much choice.
So… connecting MS’NAV and PHP via SOAP, with NTLM authentication on NAV side:

Read the rest of this post »

Posted on April 2, 2013 at 17:51 by arte · Permalink · 32 Comments
In: Drupal, English, Fighting the system · Tagged with: , ,

How to install SVN server on Ubuntu (via dav_svn aka apache module)

Well, well, well. Today we are going to install subversion on Ubuntu server in a few easy steps.

Step1: install all necessary software (considering Apache is up & running already)

sudo apt-get install subversion libapache2-svn

Step 2: Adding new user called “svn”

sudo useradd -d /home/svn -m svn

sudo passwd svn

Step 3: creating repository

sudo svnadmin create /var/svn/reponame

Read the rest of this post »

Posted on April 1, 2013 at 13:54 by arte · Permalink · Leave a comment
In: Uncategorized

Sendmail alternative – postfix on ubuntu (when PHP doesn’t send emails) in a few easy steps

Imagine you have your new shiny Ubuntu server. You installed your php, apache & mysql and everything seems fine until… you realised your system doesn’t  send emails.

If there is a problem – there must be a solution! In our case it’s either install good (… not so in fact) sendmail or postfix.

We decided to install postifix:

> sudo apt-get install postfix

Pick the correct option in a nice interface (for the web site it’s normally Internet)

choose Internet in postfix install

choose Internet in postfix install

 

 

 

 

 

 

 

 

Now it’s all “almost” working ;)You also have to go and change php.ini to pick your new mail sending program.

* Please note: since I am using Apache MPM_Worker on my local server – my PHP is working as a FastCGI module. So, my php.ini is located here: /etc/php5/cgi/php.ini
on a default installation of Apache it’s most likely here:  /etc/php5/apache2/php.ini

Check where is your new “sendmail” is located:
> which sendmail
/usr/sbin/sendmail

Good! Now change php.ini – find following string in it:
"; http://php.net/sendmail-path"

and add / edit following line below (don’t forget to replace email from field – just in case):

sendmail_path = /usr/sbin/sendmail -t -i -f name_from@your_server_name.com

Restart Apache:

> sudo service apache2 restart

 

PS: more info can be found here: https://help.ubuntu.com/12.04/serverguide/postfix.html

One useful hint – To configure postfix, run the following command:
sudo dpkg-reconfigure postfix

 

To test if it’s working ok:

> apt-get install mailutils

echo 'this is a test mesage body' | mail -s test_email_header username@gmail.com

And test in PHP document on the server:


<?php
// The message
$message = "Line 1\r\nLine 2\r\nLine 3";
// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message = wordwrap($message, 70, "\r\n");
// Send
if (mail('caffeinated@example.com', 'My Subject', $message)){
echo "ALL GOOD";
}else{
echo "Sending Failed";
}
?>

THE END

Posted on March 28, 2013 at 12:20 by arte · Permalink · 2 Comments
In: Fighting the system, Linux, Ubuntu · Tagged with: , , , ,

Scuba Diving in Doolin / Ireland. Dolphin and caves.

Well, well, well 🙂
Today I am going to tell you a story of a dolphin, a diver and… lost Go Pro Hero HD2 😉

But first lest start with a nice video of myself Scuba Diving in Doolin on 25 of August 2012:

Hope you enjoyed it!
What about Lost Camera? Well… on the second day dive while I was putting my fins in the water my camera slipped off my shoulder and… was never recovered.

So if anyone will find a really nice Go Pro HD2 with an LCD back-screen and a new flatscreen diving box in Doolin. It is mine 🙁

Posted on August 27, 2012 at 10:16 by arte · Permalink · Leave a comment
In: Uncategorized

Tissot SeaTouch – how to remove error symbol (for example after changing battery)

asd

asd

Have you seen that strange wrench symbol on your watch? I did! And AFTER I changed battery and had my watch pressure tested for as “little” as 43€ 😉
Manual says… TA-DA! Error – Contact service centre. Well, thanks guys! Actually it’s THEY did it to my watch!

I had two options – go back to the centre and have them to fix it, or do reset manually.
I am lazy (you know – “good” lazy, means I prefer spend time more productive, rather than running around different places, so I googled it and found my solution.

And here it comes:

  1. Put the watch into sleep mode as per the manual.
    (activate touch screen, touch centre till OPT appears, middle button once and the shows 24h or 12h, touch centre twice to show SLEEP then leave a few seconds and LCD goes blank and both hands go to the 12 o’Clock position)
  2. once in sleep mode, hold the 2 o’Clock position button for 6 seconds then touch the 6 o’Clock or Dive position on the face of the watch,
  3. 3.the digital display should show something like 06G316, if not repeat step 2.

4.then use 2 o’Clock position button to cycle through all the different message codes until you are back at the first one.
5.finally use the 3 o’Clock position button to come out of sleep mode and hey presto done spanner gone.

 

Probably later on I will put a short youtube video as well as I also noticed that some of the simple steps, described in the manual are not working as they described there and my little hack was not in the manual at all.

Have fun and a nice day!

Posted on August 1, 2012 at 12:49 by arte · Permalink · 17 Comments
In: English

Agile in general and Scrum in particular

Best video on Scrum I’ve seen so far:

 

Posted on March 29, 2012 at 17:46 by admin · Permalink · Leave a comment
In: Uncategorized