Friday, August 24, 2012

How to check if MySql table supports utf8 format


The best way to find if a MySql table is in UTF-8 format is to query the information schema. 

Use below query: 


select c.character_set_name from information_schema.tables as t,
     information_schema.collation_character_set_applicability as cwhere c.collation_name = t.table_collationand t.table_schema = "your_db"
and t.table_name = "table_name";


This would work with just mysql version >= 5.0.

Enjoy. 

Wednesday, August 22, 2012

Unable to connect - MFEWSErrorDomain error 56


Unable to connect - MFEWSErrorDomain error 56 using MAC Mail Client connecting to Exchange

I spent days troubleshooting my MAC mail client problem connecting to Exchange Server. 

Couple of things you should check for this are: 

1. You are able to connect to your Exchange Server. 
2. The Error above definitely means some incorrect settings. A common one is Mail > Preferences -> Accounts -> Advanced Look for Internal Server Path. If the Internal Server Path is set to EWS/webservices.aspx change it to to: EWS/exchange.asmx and retry. 
3.  Check Ports on which you are trying to connect to. 


Sunday, August 19, 2012

Find files created in last 24 hours in unix

This can be easily achieved by using the find command. 

find [path] [options]

See man page for detailed options of find command. 

find . -ctime -1 # finds files which are created in less then 1 day from currrent folder.
find . -ctime +2 # finds files which are created older then 2 days from currrent folder.


Enjoy. 

How to find out directory size in ubuntu from terminal


Commands like ls -l or df -h show me the file sizes or disk space utilization but none of them show me the size of a directory.

To see the directory size in ubuntu from terminal or command line use the command du as below. 


du -hs /path/to/folder


Where,.  

 -h is for displaying the size in human readable format. Like in MB or GB etc.
-s is for summary.  

Tuesday, August 14, 2012

uBuntu Linux find if package is installed in Linux from Terminal


In Debian / Ubuntu


Find if package is installed or not
dpkg -s ttf-mscorefonts-installer

Where ttf-mscorefonts-installer is the package name that I want to find out if it is installed or not. 

Other useful commands are: 

To print a list of packages installed on the system. 
dpkg-query -l

List of packages installed on the system that start with "ttf"
dpkg-query -l 'ttf*'


In Red Hat Enterprise / Fedora Linux / Suse Linux / Cent OS


$ rpm -qa | grep ttf-mscorefonts-installer


Monday, August 13, 2012

Simple PHP script for sending emails


Here is a simple PHP emailer script.

<?php
$to = "someone@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>

Saturday, August 11, 2012

Show form element values in PHP



The below code reads all form variables and prints them. 

<?php
$keys =array_keys($_POST); // store all variable names into a numericaly indexed array begining at 0
for ($i =0; $i <count($keys); $i++) // go trought the created array and do....
{
echo $keys[$i] . ": " . $_POST[$keys[$i]] . "<br>\n"; // print data in the format var_name: var_value
}
?>