Wednesday, 24 December 2014

Show line numbers in VIM

Enable: :set number Disable :set nonumber

Comment/Uncomment multiple lines in Vim

SOURCE: https://hurley.wordpress.com/2007/06/13/vim-tip-comment-out-multiple-lines/ Commenting out a bunch of lines without a vim plugin: Select your lines with VISUAL BLOCK (CTRL-V), then press I to insert before all highlighted lines. Next type your comment character, # (for python, shell, etc). Last press ESC. I forget not frequently used, but helpful VIM commands from time to time. Why not blog it? You can alternatively select your lines with VISUAL LINE (SHIFT-V), then type : s/^/# This tells the selected lines that you wish to substitute the start of the line with the # char.

Sunday, 21 December 2014

Install English dictionary on Slackware

Go to Slackbuilds.org and install the package Artha.

slocate: fatal error: Could not find user database '/var/lib/slocate/slocate.db': No such file or directory

You will see this message if you just run the slocate command the first time. Just run the following command to update slocate db: #updatedb

Fix mouse pointer disappeared (touchpad) after suspending

modprobe -r psmouse modprobe psmouse

Unzip multiple .zip files

unzip '*.zip'
( single quotes)

Install new TTF fonts on Slackware 14

1. Copy your ttf fonts to the folder /usr/share/fonts/TTF 2. Run the command to update your fonts cache: fc-cache -f -v

Sunday, 27 April 2014

php mcrypt so slow



If you don't specify argument for mcrypt_create_iv(), it will use /dev/random(on Linux) by default as a random number generator. The problem of /dev/random is that its random pool depends on the system interrupts, when there is not enough system interrupts, it cannot generate enough random numbers, then the process tries to get the random numbers will wait and hang. Let's look at a simple example.
$ dd if=/dev/random bs=1024k count=1
When your system is busy, you will find the output speed is very slow, sometimes there will be pause.
The solution is using /dev/urandom instead of /dev/random, /dev/urandom is also a random number generator, but it doesn't depends on system interrupts.

mcrypt_create_iv ($length, MCRYPT_DEV_URANDOM); 

Friday, 18 April 2014

English Learning Links


http://www.englishclub.com/learn-english/learn-english-how.htm

watching short films
http://www.multimedia-english.com/videos/section/official-1/tag/short-film-88

LISTENING

Kid's Storybooks:
http://freekidsbooks.org/
http://www.magickeys.com/books/
http://www.techsupportalert.com/free-audio-books-children
http://www.workaudiobook.com/WorkAudioBook/Download--Audiobooks-with-Subtitles.aspx?tag=windows
http://www.ted.com/talks
https://librivox.org/


TOEIC
http://blog.eslexplorer.com/blog/a-list-of-the-best-toeic-preparation-resources

Friday, 4 April 2014

Sites for first grade math worksheets

http://www.homeschoolmath.net/worksheets/grade_1.php

http://www.eduplace.com/math/mw/models/tm_1.html

http://www.worksheetfun.com/letter%20and%20numbers/cloud%20rain%20missing%20numbers%201-30%20-%201.pdf

Monday, 31 March 2014

Fixing slow performance of sending mail from PHP via Sendmail

Source: http://www.alphadevx.com/a/372-Fixing-slow-performance-of-sending-mail-from-PHP-via-Sendmail


Recently I have had two separate test servers that were very slow sending out emails from PHP scripts via the mail() function, where PHP was configured to use a local Sendmail binary to send the emails. The scripts were hanging for roughly one minute while waiting for Sendmail to work, which was severely impacting testing efforts.
When I run a test call to mail() and tail the maillog file, I see the following entries:
 1 
 2 
 3 
 4 
 5 
$ tail -f /var/log/maillog
Sep 13 11:30:27 myserver sendmail[29118]: My unqualified host name (myserver) unknown; sleeping for retry
Sep 13 11:31:27 myserver sendmail[29118]: unable to qualify my own domain name (myserver) -- using short name
Sep 13 11:31:27 myserver sendmail[29118]: My unqualified host name (myserver) unknown; sleeping for retry
Sep 13 11:31:35 myserver sendmail[29135]: My unqualified host name (myserver) unknown; sleeping for retry
So it seems that this is a local domain name resolution issue. The trick here is to ensure that you have an entry in your /etc/hosts file for your unqualified hostname, that is the short version returned by the hostname command, which points to the local loop-back IP rather than it's external IP like so:
 1 
127.0.0.1               localhost localhost.localdomain myserver
You need to also ensure that this is the only line in that file for the 127.0.0.1 loop-back IP, as Sendmail will only look at a single line.

Friday, 28 March 2014

Subversion: reset user password

./htpasswd -m /path/to/your_svn_auth_file username_to_reset

Wednesday, 5 March 2014

Notes on setting up Web server for php mysql development on centos

Setup LAMP on Centos for dev:
- Install Centos
- configure networking
- update system
- disable selinux
- restart system
- configure hostname for dsn resolution at webserver and dev host
- install Apache (httpd)
- configure Apache to use hostname
- install php
- restart Apache
- setup web server document folder
- code sample info.php file to test the configuration and run to verify the current setup
- install mysql and setup securely r(i.e: run mysql_secure_installation)

How do I get PHP remote debugging working under Komodo?

Question:

How do I get PHP remote debugging working under Komodo?
Answer:

There are a couple of things you need to make sure of in order to get PHP remote debugging working:

1. xdebug must be configured correctly. The php.ini that your web server is using should contain statements like this:

; xdebug config for Linux and Mac OS X
zend_extension=/usr/share/php5/debug/xdebug.so
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=foo.bar.com
xdebug.remote_port=9000
xdebug.idekey=kyla

Note in particular that remote_host needs to be the hostname or ip address of the machine Komodo is running on, and remote_port needs to be the same as the remote port Komodo is using. You can check this by creating a script like this:



...and looking at the xdebug section in the output page.

2. Komodo must be configured correctly. At

Preferences / Debugger / Proxy

...set the field 'Listen for debug connections on port' to 9000 as above. Close the preferences and make sure that

Debug / Listen for remote debugger

...has a checkmark beside it.

3. You need to explicitly initiate a debugger session by adding the XDEBUG_SESSION_START get variable to the url in your browser:

http://baz.bar.com/script.php?XDEBUG_SESSION_START=1

If everything is correct, Komodo should pop-up a dialog inidicating that a remote application has requested a debugging session. If you click on 'OK', Komodo will step in to the first line of code in that script.

If this is still not working, some things to check are:

- can you ping the machine Komodo is running on form your web server?
- is the machine Komodo is on running some sort of software firewall that might be blocking the debugger requests?

Sunday, 12 January 2014

Mobile Internet Profile

Mạng: MobiFone
Dịch vụ: Mobile Internet
APN: m-wap
Username: mms
Password: mms
----
Mạng: MobiFone
Dịch vụ: Fast Connect
APN: m-wap
Username: mms
Password: mms
----
Mạng: Vinaphone
Dịch vụ: Mobile Internet
APN: m3-world
Username: mms
Password: mms
----
Mạng: Vinaphone
Dịch vụ: Mobile Broadband
(chưa có thông tin)
----
Mạng: S-Fone
Số quay: (chưa có thông tin)
(Cần xác nhận sử dụng thực tế và danh sách các dịch vụ hiện cung cấp bởi S-Fone)
(Sự khác nhau khi sử dụng điện thoại và USB để truy cập.)
----
Mạng: Viettel Mobile
Dịch vụ: Mobile Internet
APN: v-internet
----
Mạng: Viettel Mobile
Dịch vụ: D-Com 3G
APN: e-connect
----
Mạng: Vietnamobile
Dịch vụ: GPRS
APN: internet
----
Mạng: Vietnamobile
Dịch vụ: Mobile Internet (cần xác nhận có cùng thông tin với GPRS hay không, sử dụng điện thoại có khác với USB không)
----
EVN telecom

E-Mobile (CDMA)
username: evntelecom
password: evntelecom
(cần thông tin xác nhận kết nối, tên dịch vụ và số điện thoại quay)
EVNTelecomNet (3G)
APN: e-internet

----
Beeline VN
APN: internet
(cần xác nhận có cùng thông tin với GPRS hay không, sử dụng điện thoại có khác với USB không)

Wednesday, 8 January 2014

Charge ipad on centos

wget https://github.com/mkorenkov/ipad_charge/archive/master.zip

unzip master.zip

And compile it:
cd ipad_charge-master
make
sudo make install
 
Notes: libusb and libusb-devel should be installed before this.

Friday, 3 January 2014

Allow remote connection to mysql

1. Comment out the line here if any in file /etc/my.conf
#bind-address = 127.0.0.1

2. Restart mysql

3. Login mysql
mysql>GRANT ALL PRIVILEGES ON *.* TO username@ipaddress IDENTIFIED BY "password";