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

BLOCK
c7.rbxcdn.com
facebook.com
game.weixin.qq.com
roblox.com
www.roblox.com
sumdog.com

pokemon.com
scratch.mit.edu

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


NOT BLOCK
coolmath-games.com
play.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 ./

----
Uninstall and reinstall also fixed the issue after upgrade office Ubuntu from 14.04 to 16.04.
Pac start working in Unity rather than gnome.

$sudo apt remove pac
qyang@lgm-pc:~$ sudo dpkg -i ~/Downloads/pac-4.5.5.7-all.deb
Selecting previously unselected package pac.
(Reading database ... 333327 files and directories currently installed.)
Preparing to unpack .../Downloads/pac-4.5.5.7-all.deb ...
Unpacking pac (4.5.5.7) ...
Setting up pac (4.5.5.7) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for desktop-file-utils (0.22-1ubuntu5.1) ...
Processing triggers for mime-support (3.59ubuntu1) ...
Processing triggers for gnome-menus (3.13.3-6ubuntu3.1) ...
Processing triggers for bamfdaemon (0.5.3~bzr0+16.04.20160824-0ubuntu1) ...
Rebuilding /usr/share/applications/bamf-2.index...
qyang@lgm-pc:~$ pac
PAC started (pac) with PID 23818
INFO: Used config file '/home/qyang/.config/pac/pac.nfreeze'
INFO: Using 'Unity' tray icon

Sunday, April 3, 2016

How to create Bootable USB Ubuntu 14.04 installation disk (UEFI and Legacy Compatible) and restore it back to full size after use

Linux Way to restore bootable USB:

Gui tool in lubuntu -> preferences -> Disks. (chose format USB disk as win95 fat32)

( Bootable usb write protected.
  $sudo mount -o,rw /dev/sdb1 /media/gyang/test
  or
  $mount -o remount,rw /media/gyang/test
  or
  $sudo hdparm -r0 /dev/sdb
  Not solving the issues.)



Windows Way:

You Tube Intro


Win32 Disk Imager 


superuser how to put USB back to original full size


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.


To restore bootable USB drive to its original size.

  1. Run CMD as Administrator
  2. Type DISKPART
  3. list disk
  4. select disk 1 (if your usb drive mine was 1)
  5. clean
  6. create partition primary
  7. active
  8. Choose a format:
    • FAT32 is the standard for USBs: format fs=fat32 quick
    • NTFS is more modern, but isn't as widely supported: format fs=ntfs quick
  9. assign
  10. exit
  11. exit

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    




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)