Monday, May 14, 2012

Run scp, wget Background

It is really effortless to run scp & wget in background mode.

#scp -r large_file user@example.com..... #wget http://example.com/large_file

Press CTRL + Z

and then type

#bg

Your process is now running in the background

Wednesday, May 2, 2012

Create Gradient with CSS

Here is an example of creating gradient with CSS

background: #f7f7f7; /* Old browsers */background: -moz-linear-gradient(top,  #f7f7f7 0%, #eff1f0 33%, #e3e3e3 73%, #dddddd 100%); /* FF3.6+ */background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f7f7f7), color-stop(33%,#eff1f0), color-stop(73%,#e3e3e3), color-stop(100%,#dddddd)); /* Chrome,Safari4+ */background: -webkit-linear-gradient(top,  #f7f7f7 0%,#eff1f0 33%,#e3e3e3 73%,#dddddd 100%); /* Chrome10+,Safari5.1+ */background: -o-linear-gradient(top,  #f7f7f7 0%,#eff1f0 33%,#e3e3e3 73%,#dddddd 100%); /* Opera 11.10+ */background: -ms-linear-gradient(top,  #f7f7f7 0%,#eff1f0 33%,#e3e3e3 73%,#dddddd 100%); /* IE10+ */background: linear-gradient(top,  #f7f7f7 0%,#eff1f0 33%,#e3e3e3 73%,#dddddd 100%); /* W3C */filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f7f7f7', endColorstr='#dddddd',GradientType=0 ); /* IE6-9 */

Tuesday, April 24, 2012

USB Storage failed to mount after apt-get upgrade on sheevaplug

After using apt-get upgrade on the debian squeeze on the sheevaplug, I found the my external usb complex drive was not working anymore
#dmesg shows:

scsi_mod: Unknown symbol blk_get_queue

After did a little bit research, it seems need to execute command

#flash-kernel

and reboot my sheevaplug, the driver was back!!!

Friday, April 20, 2012

Mysql Change current database characterset

Assuming you have a database with default character set latin-1 & wish to convert it to utf-8, it is very simple to convert it without any external tool

1. Dump the database:

mysqldump -h localhost -u changeit -pchangeit --opt --compatible=mysql40 --default-character-set=latin1 database>database.sql

parameter –compatible=mysql40 is to dump the database without charset settings.

2. Create a database utf8 default:

CREATE DATABASE `database_new` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

3. Reimport the database

mysql -h localhost -u changeit -pchangeit --default-character-set=utf8 database_new < database.sql

Now you have received the utf8 character set database_new.

Friday, March 16, 2012

Install Apache + mod_svn_dev + SVN + user-friendly-svn on QNAP

The ipkg for QNAP can only install Apache web server & SVN server seperately, there is no way to load mod_svn_dav in order to obtain a web interface management system such as user-friendly-svn or svnmanager to work.

My soluction is recomplile Apache2, PHP5.4, Subversion 1.6.17, here is something you need to do before the compilation.

ipkg install grepipkg install sedipkg install gccipkg install binutilsipkg install makeipkg install autoconfipkg install automakeipkg install diffutilsipkg install m4ipkg install libxml2ipkg install fileipkg install perlipkg install libdbipkg install gawk

By default the QNAP uses the grep, sed, awk from busybox which is a bit out of date, so we installed their latest version from the ipkg, then you will need to update the link in /bin

mv /bin/awk /bin/awk_bakln -s /opt/bin/awkmv /bin/grep /bin/grep_bakln -s /opt/bin/grepmv /bin/sed /bin/sed_bakln -s /opt/bin/sed

NOTE: if you use ipkg install linuxutils again, you will re-do the link as the installation will roll back those command to busybox again.

Download icu-config, it is reuqired by php

wget http://download.icu-project.org/files/icu4c/4.8.1.1/icu4c-4_8_1_1-src.tgztar xfvz icu4c-4_8_1_1-src.tgz./configure --prefix=/path_to_you_preferredmake && make install

Change the working directory to source code for apache2
configure with

./configure --prefix /path_to_you_preferred --enable-authz-host --enable-proxy --enable-proxy-http --enable-so --enable-rewrite --enable-vhost-alias  --enable-modules --enable-dav --enable-so --enable-dav=shared --enable-dav-fs=shared make && make install


Change the working directory to source code for subversion1.6.17

./configure --prefix=/path_to_you_preferred --with-apxs=/YOUR_APACHE_DIRECTORY/bin/apxs --with-apr=/YOUR_APACHE_DIRECTORY/bin/apr-1-config --with-apr-util=/YOUR_APACHE_DIRECTORY/bin/apu-1-config --with-berkeley-db=/opt/libmake & make install

Trouble shooting:
If you experienced with undefined symbol: REP_CACHE_DB_SQL
Then vi subversion/libsvn_fs_fs/rep-cache-db.h alter REP-CACHE-DB_SQL to REP_CACHE_DB_SQL.
This bug was something wrong when generate rep-cache-db.h


Change the working directory to source code for PHP5.4

PHP

./configure --prefix=/path_to_you_preferred --with-icu-dir=/YOUR_ICU_DIRECTORY/icu4 --with-apxs2=/share/YOUR_APACHE_DIRECTORY/bin/apxs --with-mysql=/mnt/ext/opt/mysql --with-pdo-mysql=/mnt/ext/opt/mysql --libdir=/share/MD0_DATA/.qpkg/Optware/lib --includedir=/share/MD0_DATA/.qpkg/Optware/includemake && make installvi /YOUR_APACHE_DIRECTORY/conf/httpd.conf

Make sure you have following modules loaded

LoadModule dav_module     modules/mod_dav.soLoadModule dav_svn_module     modules/mod_dav_svn.soLoadModule authz_svn_module   modules/mod_authz_svn.soLoadModule php5_module        modules/libphp5.so

AddType application/x-httpd-php-custom .php

    SetHandler application/x-httpd-php

change your user group to in httpd.conf

create an alias for usvn

Alias /usvn /USVN_FOLDER/public    Options +SymLinksIfOwnerMatch    AllowOverride All    Order allow,deny    Allow from all

Follow the installation guide usvn to complete the installation.

Sunday, February 26, 2012

Attributes related to WinForms Designer

  1. BrowsableAttribute
    This attribute tells designer, whether the associated property should be displayed.
  2. DefaultEventAttribute
    This attribute tells designer, if double clicked a component, which event it should generate code for.
  3. DefaultValueAttribute
    This attribute indicates the default value for the property. If you donate a value not equals default value, it will be displayed in bold.
  4. DesignerCategoryAttribute
    This attribute tells designer it belongs to what category.
  5. DesignerSerializationVisibilityAttribute
    This attribute tells designer how to serialize the associated property.
  6. DesignTimeVisibleAttribute
    This attribute tells designer whether the component should be displayed in toolbox.

To be continued…

Thursday, February 23, 2012

How to use default parameter in C# 2.0 & 3.5

For example, I need a method like this:

public void InitData(int index, object value, bool required = false) {}

I can write it as:

using System.Runtime.InteropServices;public void InitData(int index, object value, [Optional, DefaultParameterValue(false)] bool required) {}

The attribute Optional tells compiler that the parameter required has default value. And the attribute DefaultParameterValue(false) tells compiler what is the default value.

Very simple. Isn’t it?