Archive for the ‘Software Development’ Category

Vim Tips of the Day: Moving and working with split windows

Jul
5
:vs <filename>   Open a file in vertical split window
:sp <filename>   Open a file in horizontal split window
Ctrl + ww             Switch between windows (in rotation)
Ctrl + wj               Switch to split window on the bottom
Ctrl + wk              Switch to split window on the top
Ctrl + wh              Switch to split window on the left
Ctrl + wl               Switch to split window on the right

-Edwin

Vim Tips of the Day: Format a Text Block to Wrap at Specified Width

Mar
1

At times I found that I needed to edit a text and auto-wrap doesn’t work automatically. So with this tip you can select the text you want to wrap, and Vim will wrap it for you. First, you need to set the text width size of your preference. I personally like to have 80 characters in width:

:set textwidth=80

If you put this on your .vimrc, everytime you type a new line of text, Vim automagically wrap your text when it reaches 80 characters. Beware that this option actually wrap your text by inserting line breaks. If this is not the behaviour you want, you can use ‘:set wrap’ option to let Vim only display text as wrap.

There are times when the ‘textwidth’ option doesn’t work automatically.. and when that happens, you can select the text you want to wrap (with Visual Mode: Shift + v), and type gq

source: StackOverflow

VIM Tips of the Day: Save a File with Root Permission without Re-opening the File

Mar
1

Tips of the day: courtesy of commandlinefu

Save a file in VIM with root permission without re-opening the file:

:w !sudo tee %

To do this silently, just pipe it to null like so:
:w !sudo tee % > /dev/null

Completely Remove a File from a Git Repo

Apr
11

This guide helped me removing a file and its associated history from my git repo.

A Good Article on How to Become a Creative Software Developer (or in general)

Mar
16

I’ve been looking to improve my creativity lately when I stumbled upon this article on my RSS feeds:
http://softwarecreation.org/2010/how-to-become-an-expert-creativity/

I recently had an interview and the interviewer mentioned that I was lacking on creativity which he said is essential to a software developer, and then it hit me. I knew that it was not my greatest strength, but I constantly ignored it (as in not trying to improve it) just because I thought I have other qualities such as being knowledgeable. Perhaps this article is a start for me to develop my creativity skills.

Change Default Storage Engine in MySQL

Jan
30

I like my default engine to be InnoDB because it’s fully transactional and supports foreign key references. However, the default engine in MySQL is MyISAM.

There are several ways to change the default storage engine:

  1. Add default-storage-engine = innodb to your /etc/mysql/my.cnf under mysqld server section
  2. The default storage engine can be specified at server startup with the –default-storage-engine option.
  3. For a running server, an administrator who has the SUPER privilege can change the default storage engine globally for all clients by setting the global storage_engine system variable:
    SET GLOBAL storage_engine = innodb;

    Setting the storage engine this way affects any client that connects after the statement executes. Clients that are connected at the time of statement execution are unaffected.

  4. Any client can change its own default storage engine by issuing either of these statements:
    SET SESSION storage_engine = innodb;
    SET storage_engine = innodb;
    

If you change your default storage engine using Method 1, you can optimize the performance by adding few more instructions, as explained in this Stack Overflow post.

I use Method 1, and I added 3 lines to my /etc/mysql/my.cnf:

Under [mysqld] :

default-character-set = utf8
default-storageengine = innodb

… then I also added this line in InnoDB section:

innodb_buffer_pool_size = 512M

Removing Your Site from Search Engine Crawler

Jan
30

Don’t want search engine like Google to include your site in the search results?

Create a file called “robots.txt” on your root HTML directory, the path where your main site’s URL belongs: http://www.yoursite.com/

This is normally located in www directory or public_html.

In this file, add these lines:

User-agent: *
Disallow: /

“Disallow” property indicates the path that you don’t want to be crawled/searched by search engines, including its child URL. In the example above, your site will be completely removed from search engine results as the main URL is disallowed.

If you want to exclude only certain child URLs, you can do write something like this:

User-agent: *
Disallow: /about
Disallow: /secret

Check what color works on your Vim

Jan
12

To test what color works on your Vim, you can type this on an open Vim session:

:e $VIMRUNTIME/syntax/colortest.vim
:so %

To actually change certain syntax color, you need to Google your way out :)

One example is to change the color for a comment:

hi Comment ctermfg=blue

Useful Web Dev Articles This Week

Dec
1

Top 20+ MySQL Best Practices

9 Most Common IE Bugs and How to Fix Them

Zen Coding: A Speedy Way To Write HTML/CSS Code

Backing-up Your SVN Repository

Oct
21

To back up your SVN repository:

svnadmin dump path_to_svn_repo > backup_filename
tar cfz backup_filename.tgz backup_filename

Then to restore the SVN dump somewhere else:

tar xfvz backup_filename.tgz
svnadmin create new_svn_repo
svnadmin load new_svn_repo < backup_filename