Friday, December 30, 2016

epoch and date conversion in Linux command line


http://stackoverflow.com/questions/14805591/how-to-convert-strings-like-19-feb-12-to-epoch-date-in-unix

date --date="19-FEB-12" +%s
Current epoch:
date +%s
So, since your dates are in the past:
NOW=`date +%s`
THEN=`date --date="19-FEB-12" +%s`

let DIFF=$NOW-$THEN
echo "The difference is: $DIFF"

Convert epoch seconds to date

Convert seconds since the epoch (1970-01-01 UTC) to a date

$ date --date='@2147483647'

Details see $man date


qyang@ubuntu:~$ date +%w
6                                                           0 is SUN, 6 is SAT
qyang@ubuntu:~$ date --date='2-JAN-2017' +%w
1                                                           1 is MON
qyang@ubuntu:~$ date --date='2-JAN-2017' +%s
1483275600


qyang@ubuntu:~$ date --date='2-JAN-2017' +%s
1483275600
qyang@ubuntu:~$ ipython
Python 2.7.12 (default, Nov 19 2016, 06:48:10) 

In [1]: 1483275600+60*24*60*60.
Out[1]: 1488459600.0

So, in 60 days from 2-Jan-2017 will be 3-Mar-2017:
qyang@ubuntu:~$ date --date='@1488459600.0'
Fri Mar  3 00:00:00 AEDT 2017

To calculate how many days between two dates:
qyang@ubuntu:~$ date --date='31-Dec-2016' +%s
1483102800
qyang@ubuntu:~$ date --date='6-Mar-2017' +%s
1488718800
qyang@ubuntu:~$ ipython
Python 2.7.12 (default, Nov 19 2016, 06:48:10)
Type "copyright", "credits" or "license" for more information.
In [1]: (1488718800 - 1483102800)/(24*60*60.)
Out[1]: 65.0
It's 65 days from 31-Dec-2016 to 6-Mar-2017.

Sunday, December 25, 2016

Using Open DNS for Household Internet Monitoring



http://www.howtogeek.com/68886/how-to-configure-your-router-for-network-wide-url-logging/

https://www.opendns.com


roblox.com

To block uTube:
youtube.com
googlevideo.com
youtube.l.google.com
ytimg.com
ytimg.l.google.com


Tuesday, September 13, 2016

Fix PAC Seg fault in Ubuntu 16.04



[1] https://sourceforge.net/p/pacmanager/bugs/271/
[2] https://sourceforge.net/p/pacmanager/discussion/1076055/thread/f6d6690e/


qyang@ubuntu:/opt/pac/lib/ex/vte32/auto/Gnome2/Vte$ cd /opt/pac/lib/ex/vte64/auto/Gnome2/Vte/
qyang@ubuntu:/opt/pac/lib/ex/vte64/auto/Gnome2/Vte$ ll
total 1.1M
-rw-r--r-- 1 root root 265K Nov  5  2015 Vte.so_64_5.022
-rw-r--r-- 1 root root  66K Nov  5  2015 Vte.so_64_5.020
-rw-r--r-- 1 root root  68K Nov  5  2015 Vte.so_64_5.018
-rw-r--r-- 1 root root 281K Nov  5  2015 Vte.so_64_5.016
-rw-r--r-- 1 root root 278K Nov  5  2015 Vte.so_64_5.014
-rw-r--r-- 1 root root  88K Nov  5  2015 Vte.so_64_5.000
drwxr-xr-x 3 root root 4.0K Jan  2  2016 ../
lrwxrwxrwx 1 root root   53 Jan  2  2016 Vte.so -> /opt/pac/lib/ex/vte64/auto/Gnome2/Vte/Vte.so_64_5.018
drwxr-xr-x 2 root root 4.0K Jan  2  2016 ./

qyang@ubuntu:/opt/pac/lib/ex/vte64/auto/Gnome2/Vte$ sudo rm Vte.so
qyang@ubuntu:/opt/pac/lib/ex/vte64/auto/Gnome2/Vte$ sudo ln -s /opt/pac/lib/ex/vte64/auto/Gnome2/Vte/Vte.so_64_5.022 Vte.so
qyang@ubuntu:/opt/pac/lib/ex/vte64/auto/Gnome2/Vte$ ll
total 1.1M
-rw-r--r-- 1 root root 265K Nov  5  2015 Vte.so_64_5.022
-rw-r--r-- 1 root root  66K Nov  5  2015 Vte.so_64_5.020
-rw-r--r-- 1 root root  68K Nov  5  2015 Vte.so_64_5.018
-rw-r--r-- 1 root root 281K Nov  5  2015 Vte.so_64_5.016
-rw-r--r-- 1 root root 278K Nov  5  2015 Vte.so_64_5.014
-rw-r--r-- 1 root root  88K Nov  5  2015 Vte.so_64_5.000
drwxr-xr-x 3 root root 4.0K Jan  2  2016 ../
lrwxrwxrwx 1 root root   53 Sep 14 13:30 Vte.so -> /opt/pac/lib/ex/vte64/auto/Gnome2/Vte/Vte.so_64_5.022
drwxr-xr-x 2 root root 4.0K Sep 14 13:30 ./

Sunday, April 3, 2016

How to create Bootable USB for Ubuntu 14.04 (UEFI and Legacy Compatible)



You Tube Intro


Win32 Disk Imager 



Win32 Disk Imager to burn *.iso to USB flash drive.
Then, reboot from USB from UEFI enabled laptop. Should work. (Live CD has limitation as most new laptop no longer have CD drive.)

To restore USB flash drive. Follow step 5 in uTube video.

Saturday, April 2, 2016

Bit Torrent in Ubuntu



https://help.ubuntu.com/community/BitTorrent



qyang@ubuntu:~$ dpkg --list |grep transmission
ii  transmission                                                2.82-1.1ubuntu3.1                                   all          lightweight BitTorrent client
ii  transmission-common                                         2.82-1.1ubuntu3.1                                   all          lightweight BitTorrent client (common files)
ii  transmission-gtk    




Sunday, February 14, 2016

Saturday, January 2, 2016

Vi Error 'E185: Cannot find color scheme 'morning' in freshly installed ubuntu 14.04.3

Copied all ~/.vim folder to newly installed ubuntu box. But vi is complaining on start up. "E185: Cannot find color scheme 'morning'" Because at default it's using vim.tiny. qyang@ubuntu:~$ ll /etc/alternatives/vi lrwxrwxrwx 1 root root 17 Dec 6 13:24 /etc/alternatives/vi -> /usr/bin/vim.tiny* In old ubuntu box: qyang@lgm-pc:~$ ll /etc/alternatives/vi lrwxrwxrwx 1 root root 18 Jun 15 2015 /etc/alternatives/vi -> /usr/bin/vim.gnome Installing vim-gnome fixed this issue. ($sudo apt-get install vim-gnome)