Search This Blog

Loading...

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');
}

Mar 20, 2013

DOM Manipulation: How to Enable / Disable Element in jQuery

What I love about jQuery is its effectiveness in dealing with DOM manipulation. You can easily select, add or remove classes in your html document. You can also manipulate html attributes on the fly. For example if you want to disable / enable element, all you have to do is to set disabled attribute to "disabled" using the following code.

/* to disable */ 
$('.myElement').attr('disabled', 'disabled'); 

To enable it just simply removed the added "disabled" attribute or you can assign an empty string value to disabled attribute.

$('.myElement').attr('disabled', '');  

OR

$('.myElement').removeAttr('disabled');  

Mar 7, 2013

Exporting Database Table Schema to Excel / CSV Format

In exporting database table schema, I highly recommend the mysql query browser tool. It allows you to export your table schema in csv, html, xml, excel and plist (property list) file format. Aside from that, It also gives you a complete set of drag-and-drop tools to visually build, analyze and manage your db queries. I like it compare to Navicat or Mysql toad in terms of handling database schema simply because of simplicity.

Here are the steps on how to export table schema using mysql query browser. 

1. Run the mysql browser query application, login and choose the database you want to use.


2. Write this sql command “desc table_name;” in the query field and hit execute button.



3. Right after hitting the execute button you will be able to see the list. Hit the “File” menu link at the top, then choose Export ResultSet. Choose the format you like and you’re good to go.