Search This Blog

Loading...

Mar 18, 2014

Auto Detection of CSV EOL using PHP

Different Operating  Systems always find a way to make developers life in uneasy. Just like what happened when we created a import contact script that will parse a csv file then save it to a database.

The script runs smoothly using a Windows CSV format but not with MS DOS format. The problem is with their EOL (end of lines). The MAC options convert the windows CR/LF to the MAC CR only standard and LF when it is used in LINUX. See more detailed variation of csv format here.

(CR - carriage return , LF - line feed)

This runtime setting does it for me. Technically what it does is detecting what EOL configuration of a file have. So no matter what OS you have created teh csv file it PHP will detect it.

See: http://us.php.net/manual/en/filesystem.configuration.php#ini.auto-detect-line-endings

 ini_set("auto_detect_line_endings", true); 

Back on Track

Guys, sorry for not posting any updates for a  year now. I've been busy for a real estate project for a year now. But I decided to go back in writing, although it more probably short tips, notes and tricks. So, keep going guys. I appreciate your effort in visiting my blog.


Mar 22, 2013

CSS Shorthand: Font, Background, List Style and More

Not using shorthand CSS is I think the most common mistake that we do as a web developer. Shorthand for CSS properties like font, background, border and more are oftentimes ignored and not even know the syntax is. The advantage of shorthand CSS is to save lines of code and not to mention that you can easily update them. Here are some css shorthand samples:

FONT:

Syntax:
  
.body{
 font: font-style font-variant font-weight font-size/line-height font-family;
}
Sample:
  
.body{
 font: normal small-caps normal 13px/150% Arial, Helvetica, sans-serif;
}

BORDER:

Syntax:
  
.myClass{
  border: border-width border-style border-color;
}
Sample:
  
.myClass{
  border: 1px solid #CCC;
}

BACKGROUND:

Syntax:
  
.body{
 background: background-url background-repeat background-attachment background-position background-color;
}
Sample:
  
.body{
 background: url('image/sample.png') no-repeat scroll 0 0 #FFF;
}

LIST-STYLE:

Syntax:
  
.mylist{
  list-style: list-style-type list-style-position list-style-image;
}
Sample:
  
.mylist{
  list-style: disc outside url('images/test.png');
}