Wednesday, October 18, 2017

First General of Apple Watch

Just found that the first general of Apple Watch with watchOS 4 does not support some of the heart beat functions like resting rate, walking average, Breath rate, Elevated Heart Rate Notification, heart beat recovery rate.


So it is time to buy a new one :P

Thursday, October 12, 2017

Apple Watch Battery Life After Upgrading to WatchOS 4

After upgrading WatchOS, I found that my Apple watch (original one , not even series 1) burned out the battery quickly.
It dropped from 100% at 8am to 20% at 2pm........for normal use (without workout).

Reboot the Apple Watch was not working for my case.


After google for the solution, I found one works effectively.

It is "re-pair" the watch ......

According to imore web ,  the root cause of battery life problems should be something gets glitchy after upgrade the OS.
So un-paring and re-pairing can fix it.

1. tap Apple Watch at the top of the screen.
2. tap "information" button
3. tap "Unpair Apple Watch" and then confirm


And then pair the Apple Watch again.

My Apple Watch with watchOS4 works normally after the above actions.

The battery from 100% at 8 am dropped to 72% at 5 pm for normal use.

Tuesday, October 10, 2017

Grep Command with Lines

In Linux Bash shell,

> grep -B 1 -A 2 test Readme.txt

#-B number to set number lines before the match
#-A number to set number lines after the match

> grep -C 3 test Readme.txt

#-C number to set number lines before & after the match

Wednesday, October 4, 2017

Strat Chrom by Disabling Security

1. Quit all the Chrome app

2. Open Term

Type the following command


open -a /Applications/Google\ Chrome.app --args --disable-web-security --user-data-dir

Tomcat Monitor Script with Restarting

Here is my script.

#!/bin/sh

if netstat -tln | grep 8443  && ps -ef | grep tomcat | grep java

then
    date
    echo "Tomcat Running"

else
    date
    echo "Tomcat Stopped"
    source /root/.bash_profile
    date
    /app/apache-tomcat-8.0.28/bin/startup.sh >> /root/restarttomcat.log 2>&1
    echo "Tomcat Restarted"
    mailx -s "Tomcat not running" xxxx@gmail.com < /root/tomcatwordings
fi

"tomcatwordings" is file for the email contents. 


Here is the crontab
*/2 * * * * /root/checktomcat.sh >> /root/checktomcat.log 2>&1

"checktomcat.log" is the log for the monitoring script
"checktomcat.sh" is the script file with the above content.

Apache in MacOS

How start/stop Apache in MacOS?
1. Open Terminal
2. run "sudo - su"
3. apachectl start  // start Apache
or
3. apacchectl stop //stop Apache

Where is the configure file?
1. /etc/apache2

Where is the default DocumentRoot?
1. /Library/WebServer/Documents/



Friday, August 5, 2016

Excel Tips: Headers, Footers, Marcos (Updated)

1. Adding a File Path and Fileanme
If you need to show the current workbook's filename and path in a header or footer, you can use the following
Path: &[Path]
File Name: &[File]
Page: &[page]
Total pages: &[pages]
Name of worksheet: &[tab]

If you need to insert the file path and file name into a cell, try the following
=CELL("filename")
If you want to strip out the brackets and the sheet name, you can use the following variation on the formula:
=SUBSTITUTE(LEFT(CELL("filename"),FIND("]",CELL("filename"))-1),"[","")

2. Show the "Ampersands &" in header or footer, you need to &&
e.g. Tom && Jerry
it will be shown as "Tom & Jerry"


3. Add auto "last modified date"
You need to have a macro as the following

Private Sub Workbook_SheetChange(ByVal _
  Sh As Object, ByVal Target As Excel.Range)
    ActiveSheet.PageSetup.CenterFooter = _
      "Worksheet Last Changed: " & _
      Format(Now, "mmmm d, yyyy hh:mm")
End Sub

Or the following as last saved date

Private Sub Workbook_BeforeSave(ByVal _
  SaveAsUI As Boolean, Cancel As Boolean)
    Dim sht
    For Each sht In Sheets
        sht.PageSetup.CenterFooter = _
          "Workbook Last Saved: " & _
          Format(Now, "mmmm d, yyyy hh:mm")
    Next

End Sub

With font and font size assigned

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim sht
    For Each sht In Sheets
        sht.PageSetup.RightHeader = _
          "&""Calibri""&8" & _
          "Updated on: " & _
          Format(Now, "mmmm d, yyyy")
        
    Next
End Sub

The best way to accomplish the task above is to add a macro to the ThisWorkbook object that is triggered just before a workbook is saved.

For Windows, how to create a Macro
https://support.office.com/en-us/article/Create-or-delete-a-macro-2841ba85-9da6-4bd7-93a4-0da90844f283?ui=en-US&rs=en-US&ad=US&fromAR=1#bmcreatemacrovba