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

Wednesday, July 13, 2016

Missing Drop Down Arrows in Pull down Cell

In Windows,

"Missing arrows" is a fairly common problem, and usually they can be fixed by using the keyboard shortcut to show objects -- Ctrl + 6

Can fix the issue.


How about Office in Mac?

Wednesday, March 16, 2016

Where is the hash key

Where is the hash key from the Apple Keyboard connecting to iPad?


Ans: Alt + 3 (press alt and 3 key)

Wednesday, February 17, 2016

Useful Shortcuts in Mac OS X

  1. In Safari, go to top of the page or go to bottom of the page
    1. Shortcut: Command + "Up arrow" or Command + "Down arrow
  2. In Safari, shortcut to tabs
    1. Shortcut: Command + "number"
  3. Fine tuen the volume -- by pressing F11 or F12, the system will increase or decrease the volume level by one unit, if you want to have a fine adjustment, the following shortcut will take one quarter unit of volume adjustment.
    1. Shortcut: Option + Shift + F11 or F12
  4. Show the desktop 
    1. Command + F3
  5. Delete a word 
    1. shortcut: Option + Delete

How to show Chinese Calendar in Calendar app in Mac

View the lunar calendar

Choose Calendar > Preferences, click General, click the “Show alternate calendar” pop-up menu, then choose a lunar calendar.

Sunday, January 31, 2016

Excel Useful Formula #1

1. Find the repeated contents: =if(countif(A:A,A2)>1, "Repeated content", "")


2. Formula: =TRUNC((DAYS360(D1,today(), FALSE))/360, 0)

D1: is your target cell for input date of birth
today(): is the formula to return the date of today

3. Ranking: =rank(K2, K$2:K$56) ranking of 55 students results

4. Grading: =if(K2>=85, "A", If(K2>=74, "B", IF (K2>=60, "Pass", "Fail")))

5. Count with condition:

=countif(B2:B56, "80")

=countif(B2:B56, ">=80")

Friday, January 1, 2016

Sorting in OSX

In OSX, sorting and arranged by is different.


  • View > Arrange By > None (^⌘0)
  • Hold Option, View > Sort By > Name (^⌥⌘1)



Try the above commands, you will see the difference!

Monday, November 2, 2015

ShortCut in OS X -- "Forward Delete"

The new Apple keyboard remove the "forward delete" button.

And you can use short cut for fulfilling it now.

Here is the short cut.

Fn + Delete

Monday, October 12, 2015

Where is Network Utility in El Capitan?

It is easy!
You just need to type "network utility" in spotlight (the icon in the top right hand corner).
Then drag the icon of network utility to your Dock.

That's it :D

How to View Email Header in Mail app?

Ether way:

For a single email:
Select the message (highlight an email), then choose the following from the menu bar
View --> Message --> All headers

For all the email:
1. Select Mail --> Preferences
2. In "Viewing" tab, click the select box at the end of "Show message headers:"
3. Click "OK".




Wednesday, May 27, 2015

Use Mac Notebook in Closed Clamshell or Closed Display Mode

Requirements for closed-display mode:
  • Power adapter
  • External keyboard, mouse, or trackpad
  • External display



Enable closed-clamshell (display closed) mode

Use these steps to enable closed-clamshell (display closed) mode.
Note: If your external display isn't recognized when it is connected and the computer is powered on, try connecting the display while the computer is asleep or while the computer is off; wake or power on the computer after you connect the display. 

If you're using a wired keyboard and mouse

  1. Make sure the computer is plugged in to an outlet using the AC power adapter.
  2. Connect a USB keyboard and mouse to your computer.
  3. With the computer turned on connect the Mac notebook (using the appropriate Apple adapter if necessary) to the appropriate port on the external display or projector and turn the display or projector on.
  4. After your computer's Desktop appears on the external display, close the computer's lid.
  5. When you close the lid: 
    • In OS X Lion and later, the external display will change to a blue screen, then will show your desktop.
    • In Mac OS X v10.6.8 and earlier, wake the computer up by clicking the mouse button or by pressing a key on your external keyboard.
You should now be able to use your Mac notebook as you normally would, with a USB keyboard and mouse.

If you're using a Bluetooth keyboard and mouse on a Bluetooth enabled Mac notebook

  1. Make sure the computer is plugged in to an outlet using the AC power adapter.
  2. Verify that Bluetooth is turned on by using the Bluetooth pane of System Preferences or the Bluetooth menu icon.
  3. Pair your Bluetooth keyboard or mouse with the computer. For step-by-step instructions, see this article for keyboard pairing or see this article for mouse pairing.
  4. In System Preferences, be sure that the Allow Bluetooth devices to wake this computer option is selected.
  5. With the computer turned on connect the Mac notebook (using the appropriate Apple adapter if necessary) to the appropriate port on the external display or projector and turn the display or projector on.
  6. After your computer's Desktop appears on the external display, close the computer's lid.
  7. When you close the lid: 
    • In OS X Lion and later, the external display will change to a blue screen, then will show your desktop.
    • In Mac OS X v10.6.8 and earlier, wake the computer up by clicking the mouse button or by pressing a key on your external keyboard.
You should now be able to use your Mac notebook as you normally would, with a USB keyboard and mouse.

How to disconnect your Mac notebook from the display after use

For best results, put your computer to sleep before disconnecting your display.

Some DVI and Mini DisplayPort displays—including Apple's aluminum-framed DVI displays and the 24-inch and 27-inch LED Cinema Displays—can be unplugged without putting the computer to sleep. If you aren't sure whether your display supports this feature, put your computer to sleep before unplugging the display.

Opening the internal display while in closed-clamshell mode

Opening the display on your Mac notebook while it's in closed-clamshell mode will have different results based on the operating system you're using.

Saturday, April 18, 2015

Network Utility is Moved Again in OS X 10.10.3

Apple moved the "Network Utility" Application into /System/Library/CoreServices/Applications.

It is able to find it by using "Spotlight" search -- "network utility.app"

Friday, March 13, 2015

4 Code for iPhone

Signal Check
Input the following in the dial pad
*3001#12345#*
Then press "dial"
>-50dBm  indicates signal strength is very good

-50 to -70 indicates signal strength is pretty good

-70 to -90 indicates signal strength is normal

'-90' - '-100dBm' indicates signal strength is normal


Incoming Call status (turn on call forward or not)
Input the following in the dial pad
*#21#
Then press "dial"

IMEI Number

Input the following in the dial pad
*#06#
Then press "dial"


Show the Support Number of Service Provider

Input the following in the dial pad
*#5005*7672#

Then press "dial"

Friday, March 6, 2015

Five usages of "Delete" key in Mac

In Mac, when "delete" key is pressed, Mac deletes a character of the left hand side of the cursor.

And any other usages ?

1. Press "fn" and "delete" key at the same time, Mac deletes a character of the right hand side of the cursor.
2. Press "option" and "delete" key, Mac deletes a whole word of the left hand side of the cursor.
3. Press "command" and "delete" key, Mac deletes the whole line.
4. Select a file or files and press "command" and "delete", Mac deletes the selected file(s) to recycle bin.