Vim colorschemes

If you want to customize the colors you get in  VIM

Here is a gallery:   http://vimcolorschemetest.googlecode.com/svn/html/index-html.html

To try out different schemes you can type

:colorscheme XXXXX

in vi  where XXX is the scheme name  (without the .vim extension )

Once you find one you like you can put that command in your .vimrc in your home directory

I like :colorscheme darkblue

It looks for the files in /usr/share/vim/vim70/colors directory.

The only ones we have now on ccdev are listed below — if you pick one from that website we can download it and put it in that directory so everyone can choose it.

/usr/share/vim/vim70/colors/blue.vim

/usr/share/vim/vim70/colors/darkblue.vim

/usr/share/vim/vim70/colors/default.vim

/usr/share/vim/vim70/colors/delek.vim

/usr/share/vim/vim70/colors/desert.vim

/usr/share/vim/vim70/colors/elflord.vim

/usr/share/vim/vim70/colors/evening.vim

/usr/share/vim/vim70/colors/koehler.vim

/usr/share/vim/vim70/colors/morning.vim

/usr/share/vim/vim70/colors/murphy.vim

/usr/share/vim/vim70/colors/pablo.vim

/usr/share/vim/vim70/colors/peachpuff.vim

/usr/share/vim/vim70/colors/ron.vim

/usr/share/vim/vim70/colors/shine.vim

/usr/share/vim/vim70/colors/slate.vim

/usr/share/vim/vim70/colors/torte.vim

/usr/share/vim/vim70/colors/zellner.vim

Posted in Uncategorized | Leave a comment

Separating storage of mysql database files

We often have very large databases we want to create in mysql.

If we don’t have enough space in the /var/lib/mysql partition it is handy to be able to specify that a specific database be stored on another drive.

This can fairly easily be done by using innodb_file_per_table parameter in your my.cnf and using symbolic links.  The only tricky part is getting it to work under SELinux.  ( Don’t turn off SELINUX like other people say )  just follow these instructions to get it to allow what you want.

Steps to add new database that will use external storage:

Create the database using:

mysqladmin -uroot -p [pw] create newdbname

Shutdown mysql

/etc/init.d/mysqld stop

Edit /etc/my.cnf  adding line for innodb_file_per_table under the mysqld section

[mysqld]

innodb_file_per_table

While db is shut down — move the directory for the new database to a partition with space.

mv /var/lib/mysql/newdbname /bigpartition/mysql/newdbname

Create a symbolic link to the new location ( mysql looks only in /var/lib/mysql for databases on startup)

cd /var/lib/mysql

ln -s /bigpartition/mysql/newdbname newdbname

ls -l /bigpartition/mysql/newdbname

Fix the context on the newly created directories or you the database will not be visible when mysql restarts ( SELinux will prohibit mysql from using files in these directories )

chcon -c -t mysqld_db_t /bigpartition/mysql

chcon -c -t mysqld_db_t /bigpartition/mysql/newdbname

Re-start the MYSQL database

/etc/init.d/mysql start

Restore your database dump or create new tables.  The command I use is:

nohup time gunzip < backup.dmp.gz | mysql -uroot -p[dbpw] newdbname > restore.err 2>&1 &

Posted in Uncategorized | Leave a comment

Loading compressed file into mysql without uncompressing

If you have a compressed file from a mysqldump backup of your mysql database, and you don’t have space to uncompress it to load it on another machine.  You can load it directly from the compress file using this command:

zcat backupdump.sql.gz | mysql -uusername -p databasename

This will uncompress the file on the fly without using the space to hold the uncompressed file.

NOTE: You can create a compressed on the fly backup of a table by doing this command:

mysqldump -uuser -ppass dbname tablename | gzip – > backupdump.sql.gz

Leave out the tablename to dump the entire database..

I run this command in backup scripts for all my databases every night from cron.

These backup scripts typically look like this to name the file using todays date:

#!/bin/bash

cd /backupdirectory

DAY=`date ‘+%m%d%y’`

OUTFILE=”dataabasename.dmp.sql.$DAY.gz”

mysqldump -uuser -ppass dbname | gzip – > $OUTFILE

scp $OUTFILE remoteserverforsafekeeping.com:/backups

Posted in Uncategorized | Leave a comment

Fixing VIM to allow smart match finding using the percent key

Edited the file

/usr/share/vim/vim70/syntax/smarty.vim

Added the following code:

" HTML:  thanks to Johannes Zellner and Benji Fisher.
if exists("loaded_matchit")
let b:match_ignorecase = 1
let b:match_skip = 's:Comment'
let b:match_words = '<:>,' .
\ '<\@<=[ou]l\>[^>]*\%(>\|$\):<\@<=li\>:<\@<=/[ou]l>,' .
\ '<\@<=dl\>[^>]*\%(>\|$\):<\@<=d[td]\>:<\@<=/dl>,' .
\ '<\@<=\([^/][^ \t>]*\)[^>]*\%(>\|$\):<\@<=/\1>'
endif

This sets the HTML tag matching words for the matchit plug in when the filetype of Smarty is identified.

Then I edited the /etc/vimrc

Adding these lines to the bottom:

" CODE added to universally turn on the matchit plugin.
" added K. Meek 9/09
:source /usr/share/vim/vim70/macros/matchit.vim
:filetype plugin on

Now when you are editing a .tpl file the syntax is “SMARTY” for color coding, but the match words will match HTML tags


So you can position your cursor over say a tag and hit the % key and it will move cursor to the matching tag.  Same with

will find matching

VERY COOL!

You may need the matchit.vim plugin.  You can download it here.

http://www.vim.org/scripts/script.php?script_id=39

Posted in Uncategorized | 1 Comment

Background Gradient Image Creation Tool

If you need to create a gradient image for a background you might try this tool.

It is pretty slick.

http://www.ogim.4u2ges.com/gradient-image-maker.asp

Posted in Uncategorized | 1 Comment

Faster MYSQL Index creation

Creating indexes in mysql on large tables can take a long time. Because it makes a temporary copy of the entire DB file first then creates the indexes.

So be sure you have enough free space for the complete DB ( MYI and MYD for MYISAM databases ) plus space for the new version.

If you need to create multiple indexes doing them all in one command saves the time of creating that copy of the DB each time ( many hours in some cases )

Also increasing the Sort buffer sizes will greatly speed things up.

Here is the SQL we used to reduce creation time from 4 days to 11 hours on a 400 Million record table (80Gig Size).

set myisam_sort_buffer_size=2000000000;
set sort_buffer_size=2000000000;
alter table schema.tablename
add index index1 using BTREE(field1,field2),
add index index2 using BTREE(field3,field4),
add index index3 using BTREE(field5);

Posted in Uncategorized | Tagged | Leave a comment

Generate SQL to create indexes in mysql

If you have a mysql database table with indexes and you want to get the alter table  commands to “create” the same indexes on another db

You can run this sql — replacing the tablename with your table.

Just add

alter table TABLENAME

Then paste the add index commands generated by the SQL below

SELECT    concat(‘add index ‘, i.index_name , ‘ using BTREE(‘,
group_concat(i.column_name order by i.seq_in_index), ‘),’) cmd
FROM        information_schema.STATISTICS i      — i for index
WHERE   i.table_name        = ‘DCAS’
GROUP BY     i.index_name

Posted in Uncategorized | Tagged | Leave a comment

Meek Consulting is online!

The home of Fairwayfiles is now back online

Posted in Uncategorized | Leave a comment