Friday, August 11, 2017

Batch renaming multiple files in Linux


[1] https://stackoverflow.com/questions/208181/how-to-rename-with-prefix-suffix

using 'rename'
rename 's/(.*)$/new.$1/' original.filename
shell script
for filename in *.jpg; do mv "$filename" "prefix_$filename"; done;
brace expansion
mv {,new.}original.filename


Convert multiple image files into one pdf file using Linux command line.

[1] https://www.imagemagick.org/script/index.php


Convert multiple images into one pdf file under Linux command line.

#apt-get install imagemagick
$convert file1.jpg file2.jpg merge.pdf

Tuesday, June 6, 2017

Set JAVA_HOME in Ubuntu


Ref from 'askubuntu.com'


Three files you could edit, '/etc/environment' is the one prefered in web post:
/etc/environment
/etc/profile
~/.bashrc

But I chose adding file: /etc/profile.d/dnm-build-envsetting.sh

- Reboot pc, and all environments variables settings remains.
        qyang@lgm-pc:~$ cat /etc/environment
        PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
        qyang@lgm-pc:~$ cat /etc/profile.d/dnm-build-envsetting.sh
        # Some environmental variables required for DmM builder to work for android build.
        # 2017-JUN-09
        JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
        ANDROID_HOME=/home/qyang/sandbox/android-sdk-linux
        QTDIR=/home/qyang/sandbox/qt-everywhere-opensource-4.8.7
        export JAVA_HOME
        export ANDROID_HOME
        export QTDIR


My old settings:
yang@lgm-pc:~/testsetupscript$ cat /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
qyang@lgm-pc:~/testsetupscript$ cat /etc/profile
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

if [ "$PS1" ]; then
  if [ "$BASH" ] && [ "$BASH" != "/bin/sh" ]; then
    # The file bash.bashrc already sets the default PS1.
    # PS1='\h:\w\$ '
    if [ -f /etc/bash.bashrc ]; then
      . /etc/bash.bashrc
    fi
  else
    if [ "`id -u`" -eq 0 ]; then
      PS1='# '
    else
      PS1='$ '
    fi
  fi
fi

# The default umask is now handled by pam_umask.
# See pam_umask(8) and /etc/login.defs.

if [ -d /etc/profile.d ]; then
  for i in /etc/profile.d/*.sh; do
    if [ -r $i ]; then
      . $i
    fi
  done
  unset i
fi

JAVA_HOME=/usr/local/java/jdk1.8.0_25
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export PATH

Wednesday, March 29, 2017

iPad 1 Sync files via SSH



Ipad 1 Sync files via SSH

set up ssh server on ipad Launch Cydia and search for and install OpenSSH.
When asked for a password, use alpine, which is the default password for all iOS devices
enable display mirror utube Install 'display mirror' but has to be launched from ssh console.recommend popup blocker 
QuentinYangs-iPad:~ mobile$ ls /private/var/mobile/AppLinks/VLC\ for\ iOS.app/                      
Documents  Library  VLC for iOS.app  tmp

QuentinYangs-iPad:~ mobile$ ls /private/var/mobile/AppLinks/VLC\ for\ iOS.app -al
lrwxr-xr-x 1 mobile mobile 61 Apr 27 00:01 /private/var/mobile/AppLinks/VLC for iOS.app -> /var/mobile/Applications/B6D6835D-FD34-46E3-A465-13B35D4C5E0F

QuentinYangs-iPad:~ mobile$ ls /private/var/mobile/AppLinks/VLC\ for\ iOS.app/Documents/

QuentinYangs-iPad:~ mobile$ scp qyang@10.1.1.223:~/mntNAS/George_Data/Piano-Lessons/SkillSuccess-Piano-12.mp4 /private/var/mobile/AppLinks/VLC\ for\ iOS.app/Documents/

SkillSuccess-Piano-12.mp4            100%   12MB   1.1MB/s   00:11                                 
You can sync pdf books, photos and videos without iTune.
pdf file all renamed for iBook
QuentinYangs-iPad:~/Media root# ls /User/Media/Books/      
17AEB683BBA94B97.pdf  393CA8C01CE99509.pdf  55751370609C1376.pdf  75D5D27C4A0DC68B.pdf Books.plist       FCA490F8F9022998.pdf    iBooksData2.plist
2C55379B44DA1163.pdf  41BD49AE796A4C07.pdf  57022687E730FA09.pdf  88E410A3599CEFD2.pdf D1BA0918562153F7.pdf  FE57A71807FEA6FC.pdf
2C6E68A747BA2443.pdf  469A3390FC378AB6.pdf  66E27D1EFDACF4E5.pdf  9079674DB7AACD01.pdf E7A9DF25828E2D49.pdf  Purchases
2ED56E68AB4ADD8B.pdf  4715CD83FB89E35A.pdf  67CD967BE223DBF0.pdf  B19F69918E0558B3.pdf E96849ADDB5E816B.pdf  Sync
34FB1FC3BE0C1B97.pdf  5084BDA3A2D21205.pdf  6F9EB200DCC1887B.pdf  B40AB6478931EDA5.pdf ECFEA7B8487512B9.pdf  com.apple.ibooks-sync.plist
Photos are kept original name and not encrypted. *.PNG files are screen shot done on iPad. Import are files imported from CANON-40D.
QuentinYangs-iPad:~/Media root# ls /User/Media/DCIM/
100APPLE  100IMPRT  101IMPRT  102IMPRT 103IMPRT  104IMPRT  105IMPRT  106IMPRT 107IMPRT  108IMPRT  109IMPRT  110IMPRT
QuentinYangs-iPad:~/Media root# ls /User/Media/DCIM/100APPLE/
IMG_0001.PNG  IMG_0007.PNG  IMG_0014.PNG  IMG_0020.PNG IMG_0026.PNG  IMG_0035.PNG  IMG_0041.JPG  IMG_0047.JPG IMG_0057.JPG  IMG_0063.PNG  IMG_0071.PNG  IMG_0085.JPG
IMG_0002.PNG  IMG_0008.PNG  IMG_0015.PNG  IMG_0021.PNG IMG_0027.PNG  IMG_0036.PNG  IMG_0042.JPG  IMG_0048.JPG IMG_0058.JPG  IMG_0064.PNG  IMG_0074.PNG
IMG_0003.PNG  IMG_0009.PNG  IMG_0016.PNG  IMG_0022.PNG IMG_0028.PNG  IMG_0037.PNG  IMG_0043.JPG  IMG_0051.JPG IMG_0059.PNG  IMG_0067.JPG  IMG_0079.PNG
IMG_0004.PNG  IMG_0010.JPG  IMG_0017.PNG  IMG_0023.PNG IMG_0029.PNG  IMG_0038.PNG  IMG_0044.JPG  IMG_0052.PNG IMG_0060.PNG  IMG_0068.JPG  IMG_0080.PNG
IMG_0005.PNG  IMG_0011.JPG  IMG_0018.PNG  IMG_0024.PNG IMG_0030.PNG  IMG_0039.PNG  IMG_0045.JPG  IMG_0055.JPG IMG_0061.PNG  IMG_0069.JPG  IMG_0081.PNG
IMG_0006.PNG  IMG_0012.PNG  IMG_0019.PNG  IMG_0025.PNG IMG_0034.PNG  IMG_0040.PNG  IMG_0046.JPG  IMG_0056.JPG IMG_0062.PNG  IMG_0070.JPG  IMG_0084.JPG

Win to Mac GUI

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