tag:blogger.com,1999:blog-30733466468868019772024-03-14T07:11:17.174-04:00Computer Tips and TricksComputers from Unix, Linux to WindowsPatrick Wonghttp://www.blogger.com/profile/00539734435134026704noreply@blogger.comBlogger112125tag:blogger.com,1999:blog-3073346646886801977.post-69573785791077946872017-10-21T20:33:00.003-04:002017-10-21T20:33:59.215-04:00Running Ubuntu on Windows 10 Subsystem for Linux<br />
<div>
To install Ubuntu directly to Windows 10, it becomes a desktop app, you need to complete following steps:</div>
<ol>
<li>From Windows Setting, select "Update and Security"</li>
<li>Select "For Developers" in Update and Security</li>
<li>Then select Developer mode, and pick yes to install the package</li>
<li>Reboot the system</li>
<li>Type "Windows Features" at Task Bar, then select "Windows Subsystem for Linux (Beta)". Windows will update necessary files</li>
<li>Reboot the system</li>
<li>Type "bash" at Task Bar to bring up a terminal, then type y at prompt to install Ubuntu</li>
<li>Create new user and password at prompt</li>
<li>Type bash in Task Bar to start up Ubuntu</li>
</ol>
Patrick Wonghttp://www.blogger.com/profile/00539734435134026704noreply@blogger.com0tag:blogger.com,1999:blog-3073346646886801977.post-55760649408760038392017-10-07T22:16:00.001-04:002017-10-12T19:37:32.282-04:00Use Systemd for Running Meteor on Ubuntu 16.04For myapp, create a service file myapp.service at /etc/systemd/system: <br />
<br />
[Unit]<br />
Description=Myapp<br />
After=network.target<br />
<br />
[Service]<br />
WorkingDirectory=/home/pwong/myapp<br />
ExecStart=/usr/local/bin/meteor --production<br />
Restart=always<br />
StandardOutput=syslog<br />
StandardError=syslog<br />
SyslogIdentifier=Myapp<br />
User=pwong<br />
Group=pwong<br />
Environment=NODE_ENV=production<br />
Environment=PWD=/home/pwong/myapp<br />
Environment=PORT=3000<br />
Environment=HTTP_FORWARDED_COUNT=1<br />
Environment=ROOT_URL=http://myapp.com<br />
Environment=MONGO_URL=mongodb://user:pwd@mongodb0,mongodb1,mongodb2:27017/myapp?replcaSet=rs0<br />
Environment=MONGO_OPLOG_URL=mongodb://user:pwd@mongodb0,mongodb1,mongodb2:27017/local?replcaSet=rs0&authSource=admin<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
<br />
----------------------------------------------------------------- <br />
Note:<br />
<br />
1. The above configuration is used for replcation set rs0 and remote mongodb server<br />
2. Without the Install section, the service won't startup during the boot time. This section force the system to create a symbolic link for startup.<br />
3. The local database won't accept user creation, so the user is created at admin. Therefore authSource has to be defined in this case.<br />
<br />
Perform the following to enable the service and check the status of the service:<br />
<br />
$ sudo systemctl daemon-reload<br />
$ sudo systemctl enable myapp<br />
$ sudo systemctl start myapp<br />
$ sudo systemctl status myapp<br />
<br />Patrick Wonghttp://www.blogger.com/profile/00539734435134026704noreply@blogger.com0tag:blogger.com,1999:blog-3073346646886801977.post-10029600664655578662016-12-10T16:51:00.002-05:002016-12-10T16:51:30.856-05:00remove old mysql binary logs <div class="syntaxhighlighter nogutter " id="highlighter_853976" style="background: none rgb(255, 255, 255); border: 0px; bottom: auto; box-sizing: border-box; direction: ltr; float: none; height: auto; left: auto; line-height: 1.1em; margin: 1em 0px; outline: 0px; padding: 1px; position: relative; right: auto; top: auto; vertical-align: baseline; width: 642.167px;">
<div class="lines" style="background: none; border: 0px; bottom: auto; box-sizing: border-box; direction: ltr; float: none; height: auto; left: auto; line-height: 1.1em; margin: 0px; outline: 0px; padding: 0px; position: static; right: auto; top: auto; vertical-align: baseline; width: auto;">
<div class="line alt1" style="background-image: none; border: 0px; bottom: auto; box-sizing: border-box; direction: ltr; float: none; height: auto; left: auto; line-height: 1.1em; margin: 0px; outline: 0px; padding: 0px; position: static; right: auto; top: auto; vertical-align: baseline; width: auto;">
<div class="line alt1" style="background-image: none; border: 0px; bottom: auto; box-sizing: border-box; direction: ltr; float: none; height: auto; left: auto; line-height: 1.1em; margin: 0px; outline: 0px; padding: 0px; position: static; right: auto; top: auto; vertical-align: baseline; width: auto;">
<span style="font-size: 14px;">The binary logs can use lots of storage space. Following are 2 ways to clean them up, by name and by time. </span><br />
<span style="font-size: 14px;"><br /></span></div>
<div class="line alt1" style="background-image: none; border: 0px; bottom: auto; box-sizing: border-box; direction: ltr; float: none; height: auto; left: auto; line-height: 1.1em; margin: 0px; outline: 0px; padding: 0px; position: static; right: auto; top: auto; vertical-align: baseline; width: auto;">
<span style="font-size: 14px;"><span style="font-size: small;">To remove all binary logs up to mysql-bin.003456:</span></span><br />
<span style="font-size: 14px;"><span style="font-size: small;"><br /></span></span></div>
<div class="line alt1" style="background-image: none; border: 0px; bottom: auto; box-sizing: border-box; direction: ltr; float: none; height: auto; left: auto; line-height: 1.1em; margin: 0px; outline: 0px; padding: 0px; position: static; right: auto; top: auto; vertical-align: baseline; width: auto;">
<span style="font-size: 14px;"><b><i>mysql> PURGE BINARY LOGS TO 'mysql-bin.</i></b></span><b><i>003456<span style="font-size: 14px;">';</span></i></b></div>
<div class="line alt1" style="background-image: none; border: 0px; bottom: auto; box-sizing: border-box; direction: ltr; float: none; height: auto; left: auto; line-height: 1.1em; margin: 0px; outline: 0px; padding: 0px; position: static; right: auto; top: auto; vertical-align: baseline; width: auto;">
<br /></div>
<div class="line alt1" style="background-image: none; border: 0px; bottom: auto; box-sizing: border-box; direction: ltr; float: none; height: auto; left: auto; line-height: 1.1em; margin: 0px; outline: 0px; padding: 0px; position: static; right: auto; top: auto; vertical-align: baseline; width: auto;">
<span style="background-color: initial; font-size: 14px;">To remove all binary logs by date/time (Before December 8th, 2016 @6:00):</span></div>
<div class="line alt1" style="background-image: none; border: 0px; bottom: auto; box-sizing: border-box; direction: ltr; float: none; height: auto; left: auto; line-height: 1.1em; margin: 0px; outline: 0px; padding: 0px; position: static; right: auto; top: auto; vertical-align: baseline; width: auto;">
<span style="font-size: 14px;"><br /></span></div>
<div class="line alt1" style="background-image: none; border: 0px; bottom: auto; box-sizing: border-box; direction: ltr; float: none; height: auto; left: auto; line-height: 1.1em; margin: 0px; outline: 0px; padding: 0px; position: static; right: auto; top: auto; vertical-align: baseline; width: auto;">
<span style="font-size: 14px;"><b><i>mysql> PURGE BINARY LOGS BEFORE '2016-12-08 00:06:00';</i></b></span></div>
<div class="line alt1" style="background-image: none; border: 0px; bottom: auto; box-sizing: border-box; direction: ltr; float: none; height: auto; left: auto; line-height: 1.1em; margin: 0px; outline: 0px; padding: 0px; position: static; right: auto; top: auto; vertical-align: baseline; width: auto;">
<span style="font-size: 14px;"><br /></span></div>
<div class="line alt1" style="background-image: none; border: 0px; bottom: auto; box-sizing: border-box; direction: ltr; float: none; height: auto; left: auto; line-height: 1.1em; margin: 0px; outline: 0px; padding: 0px; position: static; right: auto; top: auto; vertical-align: baseline; width: auto;">
<span style="font-size: 14px;">Search for </span><span style="background-color: initial; font-size: 14px;">MySQL binary logs, error logs, temporary files:</span></div>
<div class="line alt1" style="background-image: none; border: 0px; bottom: auto; box-sizing: border-box; direction: ltr; float: none; height: auto; left: auto; line-height: 1.1em; margin: 0px; outline: 0px; padding: 0px; position: static; right: auto; top: auto; vertical-align: baseline; width: auto;">
<span style="background-color: initial; font-size: 14px;"><br /></span></div>
<div class="line alt1" style="background-image: none; border: 0px; bottom: auto; box-sizing: border-box; direction: ltr; float: none; height: auto; left: auto; line-height: 1.1em; margin: 0px; outline: 0px; padding: 0px; position: static; right: auto; top: auto; vertical-align: baseline; width: auto;">
<span style="font-size: 14px;"><b><i># lsof -nc mysqld | grep -vE '(.so(..*)?$|.frm|.MY?|.ibd|ib_logfile|ibdata|TCP)'</i></b></span></div>
</div>
</div>
</div>
Patrick Wonghttp://www.blogger.com/profile/00539734435134026704noreply@blogger.com1tag:blogger.com,1999:blog-3073346646886801977.post-74405851557709225712016-12-06T16:20:00.000-05:002016-12-07T20:30:46.717-05:00Enable https for Nginx Modify listen line in config file for example /etc/nginx/sites-enabled/default.<br />
<br />
<b><i>listen 80 default_server;</i></b><br />
<br />
and add listen 443 and certificate/key path. Following example is for Let's Encrypt installation.<br />
<br />
<b><i>listen 80;</i></b><br />
<b><i>listen 443 default ssl;</i></b><br />
<b><i>ssl_certificate /etc/letsencrypt/live/domainname/cert.pem;</i></b><br />
<b><i>ssl_certificate_key /etc/letsencrypt/live/domanname/privkey.pem;</i></b><br />
<b><i><br /></i></b>
To force http to https, add following in the server block say just after above entries. Myserver.com is used as server_name in following example.<br />
<br />
<b><i>server_name myserver.com;</i></b><br />
<b><i>if ($scheme = http) {</i></b><br />
<b><i> return 301 https://$server_name$request_uri;</i></b><br />
<b><i>}</i></b><br />
<div>
<br />
Check syntax error in config file:<br />
<br />
<b><i>nginx -t</i></b><br />
<br /></div>
Reload or restart Nginx server.<br />
<br />
<b><i>/etc/init.d/nginx reload|restart</i></b>Patrick Wonghttp://www.blogger.com/profile/00539734435134026704noreply@blogger.com0tag:blogger.com,1999:blog-3073346646886801977.post-71762516849811084922016-12-03T19:58:00.001-05:002016-12-03T19:58:45.893-05:00Reset MySQL root password<br />
<div>
Following is a way to reset MySQL root password when you forgot.</div>
<ol>
<li>Stop MySQL: <b><i>/etc/init.d/mysqld stop</i></b></li>
<li>Startup MySQL without password prompt: <b><i>mysqld_safe --skip-grant-tables &</i></b></li>
<li>Login to MySQL: <b><i>mysql --user=root mysql</i></b></li>
<li>Reset password: mysql> <b><i>update user set Password=PASSWORD('new-password') where user='root';</i></b></li>
<li>mysql> <b><i>flush privileges;</i></b></li>
<li>mysql> <b><i>exit;</i></b></li>
<li>Kill running mysql daemon: <b><i>kill mysql-pid</i></b></li>
<li>Start MySQL: <b><i>/etc/init.d/mysqld start</i></b></li>
</ol>
Patrick Wonghttp://www.blogger.com/profile/00539734435134026704noreply@blogger.com0tag:blogger.com,1999:blog-3073346646886801977.post-29590580786938617552016-11-29T20:32:00.000-05:002016-12-10T11:46:15.912-05:00Online Administrator's tools<b><i>IP Location:</i></b><br />
<a href="https://www.iplocation.net/">https://www.iplocation.net/</a><br />
<br />
<b><i>Whois:</i></b><br />
<a href="https://who.is/">https://who.is/</a><br />
<br />
<b><i>Password generator:</i></b><br />
<a href="https://strongpasswordgenerator.com/">https://strongpasswordgenerator.com/</a><br />
<br />
<b><i>Dig:</i></b><br />
<a href="https://toolbox.googleapps.com/apps/dig/">https://toolbox.googleapps.com/apps/dig/</a><br />
<br />
<b><i>SSL Server Test:</i></b><br />
<a href="https://www.ssllabs.com/ssltest/analyze.html?">https://www.ssllabs.com/ssltest/analyze.html?</a><br />
<br />
<b><i>Email Server Test:</i></b><br />
<a href="http://mxtoolbox.com/diagnostic.aspx">http://mxtoolbox.com/diagnostic.aspx</a><br />
<br />
<b><i>DNS Speed Test:</i></b><br />
<a href="https://www.ultratools.com/tools/dnsHostingSpeed">https://www.ultratools.com/tools/dnsHostingSpeed</a><br />
<br />
<b><i>PageSpeed Insights:</i></b><br />
<a href="https://developers.google.com/speed/pagespeed/">https://developers.google.com/speed/pagespeed/</a><br />
<br />
<b><i>Mobile Website Speed Testing Tool</i></b><br />
<a href="https://testmysite.thinkwithgoogle.com/">https://testmysite.thinkwithgoogle.com/</a>Patrick Wonghttp://www.blogger.com/profile/00539734435134026704noreply@blogger.com1tag:blogger.com,1999:blog-3073346646886801977.post-4453741555767315112016-11-26T08:20:00.001-05:002016-11-26T08:20:17.231-05:00Troubleshooting logrotate and cron on Ubuntu serverMy client's logrotate was not rotate the logs for months. However, manually run logrotate is fine. use debug, verbose, even force options can't find anything funny. The content of /var/lib/logrotate/status looks normal. Finally, check the cron job to see if anything wrong there.<br />
<ol>
<li><b><i>Tail /var/log/cron.log</i></b> and see "Authentication token is no longer valid; new one required".</li>
<li>Run "<b><i>chage -l root</i></b>" to check the aging information of root account, and "password must be changed" message shown up.</li>
<li>Generate a new password from https://strongpasswordgenerator.com, then run <b><i>passwd</i></b> command to change to the new passwd for root. </li>
<li>Check /var/log/cron.log again after a cron job is executed, and the cron.log seems OK. The problem fixed.</li>
</ol>
<div>
Conclusion: Since the cron job is essential for automatic log rotation. If cron job has any problem, the log files don't get rotated even manual run has no problem at all. </div>
<br />
<br />Patrick Wonghttp://www.blogger.com/profile/00539734435134026704noreply@blogger.com1tag:blogger.com,1999:blog-3073346646886801977.post-42350318025045868762016-11-25T18:29:00.000-05:002016-11-25T18:29:07.145-05:00Speed test from Linux Command lineRun following 3 commands to do the test.<br />
<ol>
<li>wget -O speedtest https://raw.github.com/sivel/speedtest-cli/master/speedtest.py</li>
<li>chmod +x speedtest</li>
<li>./speedtest</li>
</ol>
Following is a sample test result:<br />
Retrieving speedtest.net configuration...<br />
<div>
<div>
Testing from DigitalOcean (x.x.x.x)...</div>
<div>
Retrieving speedtest.net server list...</div>
<div>
Selecting best server based on ping...</div>
<div>
Hosted by fdcservers.net (New York City, NY) [2.13 km]: 5.872 ms</div>
<div>
Testing download speed................................................................................</div>
<div>
Download: 832.04 Mbit/s</div>
<div>
Testing upload speed....................................................................................................</div>
<div>
Upload: 485.81 Mbit/s</div>
</div>
<div>
<br /></div>
Patrick Wonghttp://www.blogger.com/profile/00539734435134026704noreply@blogger.com0tag:blogger.com,1999:blog-3073346646886801977.post-40454114225222248952015-08-02T22:11:00.001-04:002015-08-02T22:11:58.203-04:00Yum Install Ipython on CentOS 6 1. Add EPEL repo.<br />
<i>rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
</i><br />
2. Install Ipython with Yum.<br />
<i>yum install ipython</i>Patrick Wonghttp://www.blogger.com/profile/00539734435134026704noreply@blogger.com0tag:blogger.com,1999:blog-3073346646886801977.post-688925792052242222015-08-02T19:26:00.000-04:002015-08-02T19:26:22.770-04:00Share files with You Colleagues through Python Simple HTTP Server1. Start up the http server at directory where the files to share with. <b>The server script can be found at section 3 in bold.</b><br />
<p> <i>$ python -m Simple-HTTPserver.py<br />
Serving HTTP on 192.168.88.132 port 8000 ...</i></p>
2. Your colleague can access your http server to check the list of files such as:<br />
<p> <i>$ curl 192.168.88.132:8000</i></p>
3. To display the content of the script, for example Simple-HTTPserver.py:<br />
<pre><i>$ curl 192.168.88.132:8000/Simple-HTTPserver.py
<b>import sys
import BaseHTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
HandlerClass = SimpleHTTPRequestHandler
ServerClass = BaseHTTPServer.HTTPServer
Protocol = "HTTP/1.0"
if sys.argv[1:]:
port = int(sys.argv[1])
else:
port = 8000
server_address = ('192.168.88.132', port)
HandlerClass.protocol_version = Protocol
httpd = ServerClass(server_address, HandlerClass)
sa = httpd.socket.getsockname()
print "Serving HTTP on", sa[0], "port", sa[1], "..."
httpd.serve_forever()</i></b>
</pre>
4. To download the script either use wget or redirect the output of above to the file Simple-HTTPserver.py. Please modify the server address to meet your need.<br /><br />
<i>$ wget 192.168.88.132:8000/Simple-HTTPserver.py</i><br />
<i>$ curl 192.168.88.132:8000/Simple-HTTPserver.py > Simple-HTTPserver.py</i>Patrick Wonghttp://www.blogger.com/profile/00539734435134026704noreply@blogger.com0tag:blogger.com,1999:blog-3073346646886801977.post-10677765750411646072015-08-02T08:01:00.002-04:002015-08-02T08:01:46.659-04:00Run Python script on remote serverInstead of copying over the Python script to the remote server to run, the local script can be run on remote server as follow as long as you are a valid user:<br /><br />
<i>cat script.py | ssh user@machine python -</i>Patrick Wonghttp://www.blogger.com/profile/00539734435134026704noreply@blogger.com0tag:blogger.com,1999:blog-3073346646886801977.post-68322954443466084722015-07-23T13:04:00.001-04:002015-07-24T07:20:31.230-04:00Install LEMP on Centos 7.11. Install Nginx, then test it at http://ip_address<br />
<i> yum install nginx -y</i><br />
<i> systemctl start nginx </i><br />
<i> systemctl enable nginx</i><br />
<i><br /></i>
2. Modify /etc/nginx/nginx.conf to add following:<br />
<i> location ~ \.php$ {</i><br />
<i> root /usr/share/nginx/html;</i><br />
<i> fastcgi_pass 127.0.0.1:9000;</i><br />
<i> fastcgi_index index.php;</i><br />
<i> fastcgi_param SCRIPT_FILENAME \ $document_root$fastcgi_script_name;</i><br />
<i> include fastcgi_params;</i><br />
<i> }</i><br />
<i><br /></i>
3. Restart Nginx server:<br />
<i> systemctl restart nginx</i><br />
<i><br /></i>
4. Install MySQL<br />
<i> yum install mariadb-server mariadb</i><br />
<i> systemctl start mariadb</i><br />
<i> mysql_secure_installation </i><br />
<i> systemctl enable mariadb.service </i><br />
<i><br /></i>
5. Install PHP<br />
<i> yum install php php-common php-fpm php-mysql -y</i><br />
<i> systemctl start php-fpm</i><br />
<i> systemctl enable php-fpm</i><br />
<i><br /></i>
6. Modify /etc/php.ini to make "cgi.fix_pathinfo=0"<br />
<br />
7. Modify /etc/php-fpm.d/www.conf to change both user and group equal to nginx instead of apache.<br />
<br />
8. Restart Nginx:<br />
<i> systemctl restart php-fpm</i><br />
<i><br /></i>
9. Create /usr/share/nginx/html/info.php with following code to test php. The php information page should be displayed at http://ip/info.php<br />
<i> <?php phpinfo(); ?></i><br />
<i><br /></i>
10. After the information on page http://ip/info.php confirmed. delete the file /usr/share/nginx/html/info.php.
<br />
<br />
<hr />
If needed do the following to change the default PHP-FPM port to Unix socket:<br />
<br />
1. Modify /etc/php-fpm.d/www.conf as show below:<br />
from:<br />
<i> listen = 127.0.0.1:9000</i><br />
to: <br />
<i> listen = /var/run/php-fpm/php5-fpm.sock</i><br />
<br />
2. Modify /etc/nginx/nginx.conf<br />
from:<br />
<i> fastcgi_pass 127.0.0.1:9000;</i><br />
to:<br />
<i> fastcgi_pass unix:/var/run/php-fpm/php5-fpm.sock;</i><br />
<br />
Finally, restart Nginx and PHP-FPM:<br />
<i> systemctl restart nginx</i><br />
<i> systemctl restart php-fpm</i>Patrick Wonghttp://www.blogger.com/profile/00539734435134026704noreply@blogger.com0tag:blogger.com,1999:blog-3073346646886801977.post-66836566318586656092015-07-13T15:32:00.000-04:002015-07-13T15:32:01.717-04:00Install FTP server vsftpd on CentOS 7.11. yum install vsftpd ftp -y<br />
2. vi /etc/vsftpd/vsftpd.conf with following changes:<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>## Set to "NO" ##<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>anonymous_enable=NO<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>## Uncomment ##<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>ascii_upload_enable=YES<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>ascii_download_enable=YES<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>## Uncomment - Enter your Welcome message - This is optional ##<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>ftpd_banner=Welcome to UNIXMEN FTP service.<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>## Add at the end of this file ##<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>use_localtime=YES<br />
<br />
3. systemctl restart vsftpd<br />
4. systemctl enable vsftpdPatrick Wonghttp://www.blogger.com/profile/00539734435134026704noreply@blogger.com0tag:blogger.com,1999:blog-3073346646886801977.post-90910925651524387612015-06-27T15:12:00.002-04:002015-07-17T22:12:40.036-04:00Install LAMP on Centos 7.1Install Apache<br />
<br />
<ul>
<li><i>yum install httpd </i></li>
<li><i>systemctl start httpd.service </i></li>
<li><i>systemctl enable httpd.service</i> </li>
</ul>
<br />
<br />
Install MySQL<br />
<br />
<ul>
<li><i>yum install mariadb-server mariadb</i></li>
<li><i>systemctl start mariadb</i></li>
<li><i>mysql_secure_installation </i></li>
<li><i>systemctl enable mariadb.service</i> </li>
</ul>
<br />
<br />
Install PHP<br />
<br />
<ul>
<li><i>yum install php php-mysql </i></li>
<li><i>systemctl restart httpd.service</i> </li>
</ul>
<br />
<br />
Install PHPmyadmin<br />
<br />
<ul>
<li><i>yum install epel-release </i></li>
<li><i>yum install phpmyadmin</i></li>
<li><i>systemctl restart httpd.service</i> </li>
</ul>
Patrick Wonghttp://www.blogger.com/profile/00539734435134026704noreply@blogger.com0tag:blogger.com,1999:blog-3073346646886801977.post-12818087064196203342015-06-25T18:00:00.000-04:002015-06-25T18:01:06.965-04:00Grant Sudo Privileges To a User on Centos 7From the command line:<br />
<i>gpasswd -a webapp wheel</i>Patrick Wonghttp://www.blogger.com/profile/00539734435134026704noreply@blogger.com0tag:blogger.com,1999:blog-3073346646886801977.post-88045361047577666792015-06-22T21:30:00.000-04:002015-06-23T22:31:24.238-04:00Install Elasticsearch on Centos 7.1<br />
<ol>
<li>Download Current Java Runtime Environment from: http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html</li>
<li>sudo rpm -Uvh jre-8u45-linux-x64.rpm</li>
<li>java -version</li>
<li>sudo rpm -Uvh https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.6.0.noarch.rpm</li>
<li>Define network.host: localhost in /etc/elasticsearch/elasticsearch.yml</li>
<li>sudo systemctl daemon-reload</li>
<li>sudo systemctl enable elasticsearch.service</li>
<li>sudo systemctl start elasticsearch.service</li>
<li>Execute <i>curl -XGET 'http://localhost:9200/_cluster/health?pretty=true'</i> to make sure the server is up and running</li>
</ol>
Patrick Wonghttp://www.blogger.com/profile/00539734435134026704noreply@blogger.com0tag:blogger.com,1999:blog-3073346646886801977.post-76804382563172123462015-05-25T21:36:00.001-04:002015-05-25T21:36:13.906-04:00Logrotate uses 100% CPU issue on CentOSA typical /var/lib/logrotate.status looks like:<br />
<br />
<i>logrotate state -- version 2</i><br />
<i>"/var/log/daemon.log" 2015-5-9</i><br />
<i>"/var/log/portage/elog/summary.log" 2015-5-9</i><br />
<i>"/var/log/mysql/mysql.err" 2015-5-9</i><br />
<i>"/var/log/mysql/mysql.log" 2015-5-9</i><br />
<i>"/var/log/mysql/mysqld.err" 2015-5-9</i><br />
<i>"/var/log/atop/dummy_before" 2015-5-25</i><br />
<i>"/var/log/atop/dummy_after" 2015-5-25</i><br />
<i>"/var/log/net-snmpd.log" 2015-5-9</i><br />
<i>"/var/log/xinetd.log" 2015-5-23</i><br />
<i>"/var/log/wtmp" 2015-5-9</i><br />
<i><br /></i>
It is a small file say hundred bytes, but the size may reaches megabytes if there are some config errors.<br />
<div>
<br /></div>
<div>
Following command can be used to check the configuration of logrotate without change anything:</div>
<div>
<br /></div>
<div>
<i>sudo /usr/sbin/logrotate -d /etc/logrotate.conf</i></div>
<div>
<i><div>
reading config file /etc/logrotate.conf</div>
<div>
including /etc/logrotate.d</div>
<div>
reading config file daemon</div>
<div>
reading config info for /var/log/daemon.log</div>
<div>
reading config file elog-save-summary</div>
<div>
reading config info for /var/log/portage/elog/summary.log</div>
<div>
reading config file mysql</div>
<div>
...</div>
<div>
<br /></div>
</i></div>
<div>
It may indicate a bad logrotate.status file if the command hangs with a huge logrotate status file, </div>
<div>
<br /></div>
<div>
To fix the problem, simply delete the logrotate.status. The logrotate will re-create a new one for you.</div>
<div>
<br /></div>
<div>
<br /></div>
Patrick Wonghttp://www.blogger.com/profile/00539734435134026704noreply@blogger.com0tag:blogger.com,1999:blog-3073346646886801977.post-12677878831800444322015-04-26T18:17:00.003-04:002015-04-26T18:18:43.929-04:00SVN client side problems If there is a performance or strange issue on a specific tree try the following:<br />
<br />
<br />
<ol>
<li>In Windows, delete the roaming profile folder %AppData%\Subversion. </li>
<li>Rename your current tree then chekout a fresh copy to work with. Then copy any uncommitted files from the old (renamed) tree to the new tree. </li>
</ol>
Patrick Wonghttp://www.blogger.com/profile/00539734435134026704noreply@blogger.com1tag:blogger.com,1999:blog-3073346646886801977.post-28424103127863677732015-01-12T18:18:00.000-05:002015-01-12T18:18:53.412-05:00Setup Color Scheme Distinguished For VimRun <i>mkdir -p ~/.vim/colors</i><br />
<br />
Download distinguished.vim and move to the directory.<br />
<br />
Add following to ~/.vimrc<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><i>syntax on</i><br />
<i><span class="Apple-tab-span" style="white-space: pre;"> </span>colorscheme distinguished</i><br />
<br />
Append following to ~/.bashrc<br />
<i>export TERM=xterm-256color</i><br />
<br />
Run <i>. ~/.bashrc</i> to bring up the term setting.<br />
<br />
For more schemes examples see http://www.vimninjas.com/2012/08/26/10-vim-color-schemes-you-need-to-ownPatrick Wonghttp://www.blogger.com/profile/00539734435134026704noreply@blogger.com0tag:blogger.com,1999:blog-3073346646886801977.post-32821329932661209322014-12-22T21:48:00.000-05:002014-12-22T21:48:03.252-05:00Excel VBA - Misc File Handling Subroutines<i><br /></i>
<i><br /></i>
<i>Sub CopyFile()</i><br />
<i> FileCopy "fullPATH\filename1", "fullPATH\filename2"</i><br />
<i>End Sub</i><br />
<i><br /></i>
<i>Sub renameFile()</i><br />
<i> Name "fullPATH\oldFileName" As "fullPATH\newFileName"</i><br />
<i>End Sub</i>Patrick Wonghttp://www.blogger.com/profile/00539734435134026704noreply@blogger.com0tag:blogger.com,1999:blog-3073346646886801977.post-28226702434507738252014-12-22T20:40:00.003-05:002014-12-25T08:01:43.575-05:00Copy With Destination Defined Makes Cleaner VBA Code Following example code simplify the copy process by eliminating 4 line codes such as Range.copy, Sheet.Activate, Range.Select, and Activesheet.Paste.<br />
<br />
<i>Range("B12:C17").Copy Destination:=Range("B30")</i><br />
<i><br /></i>
Even shorter:<br />
<br />
<i>Range("B12:C17").Copy Range("B30")</i><br />
<i><br /></i>
Similarly, following code can be used for moving:<br />
<br />
<i>Range("B12:C17").Cut Range("B30")</i>Patrick Wonghttp://www.blogger.com/profile/00539734435134026704noreply@blogger.com0tag:blogger.com,1999:blog-3073346646886801977.post-44198253396540034342014-12-22T20:22:00.000-05:002014-12-22T20:55:07.980-05:00Excel VBA - Delete All Blank Lines in Work SheetFollowing subroutine deletes all blank lines from current work sheet from the bottom with the range defined A1:Z50.<br />
<i><br /></i>
<i>Sub DeleteRowsFromBottom()</i><br />
<i>Dim range As range, rows As Integer, i As Integer</i><br />
<i> </i><br />
<i>Set range = ActiveSheet.range("A1:Z50")</i><br />
<i>rows = range.rows.Count</i><br />
<i>For i = rows To 1 Step (-1)</i><br />
<i> If WorksheetFunction.CountA(range.rows(i)) = 0 Then range.rows(i).Delete</i><br />
<i>Next</i><br />
<i><br /></i>
<i>End Sub</i><br />
<i><br /></i>Patrick Wonghttp://www.blogger.com/profile/00539734435134026704noreply@blogger.com0tag:blogger.com,1999:blog-3073346646886801977.post-2637848739310096362014-12-22T20:06:00.000-05:002014-12-22T20:53:02.888-05:00Save Current Excel Workbook To A CSV Format FileFollowing code can be used to save the current work book into CSV format to the folder fullPATH and ignore the backup.<br />
<br />
<i>ActiveWorkbook.SaveAs Filename:= _</i><br />
<i> "fullPATH\fileName.csv", FileFormat:= _</i><br />
<i> xlCSV, CreateBackup:=False</i>Patrick Wonghttp://www.blogger.com/profile/00539734435134026704noreply@blogger.com0tag:blogger.com,1999:blog-3073346646886801977.post-90729493457625648622014-12-22T19:58:00.001-05:002014-12-22T20:52:02.028-05:00Excel VBA - Search Match Text Following subroutines can be used to search a word "pattern" in column B and assume total row is 50.<br />
<br />
This search from top:<br />
<br />
<i>Sub topDownSearch()</i><br />
<i>Dim lastRow As Integer</i><br />
<i>Dim curRow As Integer</i><br />
<i><br /></i>
<i>lastRow = 50</i><br />
<i><br /></i>
<i>For curRow = 1 to lastRow Step 1</i><br />
<i> If Cells(curRow, 2) = "pattern" Then</i><br />
<i> Cells(curRow, 2).Select</i><br />
<i> MsgBox (Cells(curRow, 2))</i><br />
<i> End If</i><br />
<i>Next</i><br />
<i><br /></i>
<i>End Sub</i><br />
<br />
This search from bottom:<br />
<i><br /></i>
<i>Sub bottomUpSearch()</i><br />
<i>Dim lastRow As Integer</i><br />
<i>Dim curRow As Integer</i><br />
<i><br /></i>
<i>lastRow = 50</i><br />
<i><br /></i>
<i>For curRow = lastRow To 1 Step -1</i><br />
<i> If Cells(curRow, 2) = "pattern" Then</i><br />
<i> Cells(curRow, 2).Select</i><br />
<i> MsgBox (Cells(curRow, 2))</i><br />
<i> End If</i><br />
<i>Next</i><br />
<i><br /></i>
<i>End Sub</i><br />
<br />
<br />
<br />
<br />Patrick Wonghttp://www.blogger.com/profile/00539734435134026704noreply@blogger.com0tag:blogger.com,1999:blog-3073346646886801977.post-55468826305904966182014-12-14T11:43:00.000-05:002014-12-14T13:33:35.333-05:00Install Jenkins and Plugins/Tools for PHP5 CI on Ubuntu 14.04You have to be a super user to perform the following steps.<br />
<br />
Install Jenkins:<br />
<i>wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | apt-key add -</i><br />
<i>echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list</i><br />
<i>apt-get update</i><br />
<i>apt-get install jenkins</i><br />
<i><br /></i>
Go to http://localhost:8080/ with a browser to make sure Jenkins is up and running.<br />
<i><br /></i>
Install Plugins:<br />
<i>wget http://localhost:8080/jnlpJars/jenkins-cli.jar</i><br />
<i> java -jar jenkins-cli.jar -s http://localhost:8080 install-plugin checkstyle</i><br />
<i> java -jar jenkins-cli.jar -s http://localhost:8080 install-plugin clover</i><br />
<i> java -jar jenkins-cli.jar -s http://localhost:8080 install-plugin dry</i><br />
<i> java -jar jenkins-cli.jar -s http://localhost:8080 install-plugin htmlpublisher</i><br />
<i> java -jar jenkins-cli.jar -s http://localhost:8080 install-plugin jdepend</i><br />
<i> java -jar jenkins-cli.jar -s http://localhost:8080 install-plugin plot</i><br />
<i> java -jar jenkins-cli.jar -s http://localhost:8080 install-plugin pmd</i><br />
<i> java -jar jenkins-cli.jar -s http://localhost:8080 install-plugin violations</i><br />
<i> java -jar jenkins-cli.jar -s http://localhost:8080 install-plugin xunit</i><br />
<i> java -jar jenkins-cli.jar -s http://localhost:8080 safe-restart</i><br />
<i><br /></i>
Download Tools:<br />
<i>wget https://phar.phpunit.de/phpunit.phar</i><br />
<i>wget https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar</i><br />
<i>wget https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar</i><br />
<i>wget https://phar.phpunit.de/phploc.phar</i><br />
<i>wget http://static.pdepend.org/php/latest/pdepend.phar</i><br />
<i>wget https://phar.phpunit.de/phpcpd.phar</i><br />
<i>wget http://phpdox.de/releases/phpdox.phar</i><br />
<i>curl -s http://getcomposer.org/installer | php</i><br />
<i>chmod +x *.phar</i><br />
<i><br /></i>
Install and Verify:<br />
<i>mv phpunit.phar /usr/local/bin/phpunit</i><br />
<i> phpunit --version</i><br />
<i> PHPUnit 4.4.0 by Sebastian Bergmann.</i><br />
<i><br /></i>
<i>mv phpcs.phar /usr/local/bin/phpcs</i><br />
<i> phpcs --version</i><br />
<i></i><i style="white-space: pre;"> PHP_CodeSniffer version 2.0.0 (stable) by Squiz (http://www.squiz.net)</i><br />
<i><br /></i>
<i>mv phpcbf.phar /usr/local/bin/phpcbf</i><br />
<i> phpcbf --version</i><br />
<i> PHP_CodeSniffer version 2.0.0 (stable) by Squiz (http://www.squiz.net)</i><br />
<i><br /></i>
<i>mv phploc.phar /usr/local/bin/phploc</i><br />
<div>
<i> phploc --version</i><br />
<i> phploc 2.0.6 by Sebastian Bergmann.</i><br />
<div>
<i><br /></i></div>
<div>
<i>mv pdepend.phar /usr/local/bin/pdepend</i></div>
<i> pdepend --version</i><br />
<i> PDepend 2.0.4</i><br />
<i><br /></i>
<i>mv phpcpd.phar /usr/local/bin/phpcpd</i><br />
<i> phpcpd --version</i><br />
<i> phpcpd 2.0.1 by Sebastian Bergmann.</i><br />
<div>
<i><br /></i></div>
<div>
<i>mv phpdox.phar /usr/local/bin/phpdox</i></div>
<i></i><br />
<i> phpdox --version</i><br />
<i> phpDox 0.7.0 - Copyright (C) 2010 - 2014 by Arne Blankerts</i><br />
<i><br /></i>
<i>mv composer.phar /usr/local/bin/composer</i><br />
<i> composer --version</i><br />
<i> Composer version 1.0-dev (4cc52afcc4debecf4fa7ce998198355fea98e656) 2014-12-13 18:54:43</i></div>
Patrick Wonghttp://www.blogger.com/profile/00539734435134026704noreply@blogger.com0