Saturday, September 5, 2015

Mac Tips and Tricks



https://support.apple.com/guide/automator/welcome/mac
Let your Mac do repetitive tasks for you
To begin, you will need to launch the automator. Then you can create a new service in it. Now you can locate the function, which indicates “Copy to Clipboard”. When you see that, you need to drag and drop into the right hand side of the panel. Now you can select “Service Receives Selected” into “Files or Folders”. As the last step, you can save the automated service and give it a meaningful name, such as “Copy Path”. 
How can I find out if I have Xcode commandline tools installed?
/usr/bin/xcodebuild -version
will give you the xcode version, run it via Terminal command


Laptop is a script to set up a macOS computer for web development, and to keep it up to date.

  • The command line tools are the basic foundation. Many basic tools are needed to compile your Swift/Objective-C code.
  • XCode is the IDE which brings a few additional packages with it.
So the command line tools get sure that the basic UNIX tools are covered (as GCC for example) to be able to compile and link code.

brew install duti
Now you need to find the id of the app you want to use, and assign it to the extension you want to use it for. In this example, I already use Brackets for *.sh and I want to also use it for *.md files instead of xcode.
  • Set TextEdit as the default handler for Word documents:
    echo 'com.apple.TextEdit   com.microsoft.word.doc all' | duti
A command-line tool to select default applications for document types and URL schemes on Mac OS X




Get the default app id for .sh files:

duti -x sh

output:
  Brackets.app
  /opt/homebrew-cask/Caskroom/brackets/1.6/Brackets.app
  io.brackets.appshell

Use this app id for all .md files:

duti -s io.brackets.appshell .md all










$ duti -x md
Mou.app
/Applications/Mou.app
com.mouapp.Mou

Find out the bundle ID for an app


I want to change from Mou to Sublime Text, so I need Sublime Text’s bundle ID. There are a couple of ways I could get this info.

If I knew that another file type foo already uses Sublime Text as its default, I could use duti -x foo& look at the third line of the results, as with Mou above.

OR I can use this one-line AppleScript:



$ osascript -e "id of app "Sublime Text 2"" 
com.sublimetext.2

This works for any app on your system, like this:


$ osascript -e "id of app "Espresso""
com.macrabbit.Espresso



Bash Completion on macOS With Brew
$ brew install bash-completion
$ brew tap homebrew/completions
After you run that first command, in typical brew fashion, it will request that you add the following tidbit to your ~/.bash_profile. Don’t forget this part. It’s critical!
if [ -f $(brew --prefix)/etc/bash_completion ]; then
    . $(brew --prefix)/etc/bash_completion
fi

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun


The problem is that Xcode Command-line Tools needs to be updated.
Go back to your terminal and hit:
xcode-select --install
You'll then receive:
xcode-select: note: install requested for command line developer tools


Activity Monitor > View > All Processes, Hierarchically ought to do it, with a bit of scrolling...

The Stationery Pad feature has been around for years. Helpful though it can be, very few people use it. And that’s too bad.
It’s a way of creating a template document. For example, create a blank TextEdit document, save it to the desktop, select it, press Command-I, and enable the Stationery Pad option. Double-click on that document and you generate a copy of it, complete with all of the original document’s content. The original file remains untouched.


This is part of resume. A feature introduced with Lion.
Per default, windows are restored the next time you open the application. If you want to completly close all windows just one time, you can quit an application using ++Q instead of the standard +Q to quit an application.

You can pin Siri results to your taskbar for later. When you ask Siri for information just click the plus icon at the top right of the grey box displaying the result of a Siri query.
Taking screenshots of Siri
When Siri shows you results, you can just drag that screen to your desktop or Finder window. This will create an automatic screenshot of the results, which is handy for future reference, rather than re-running the command, and perhaps getting different information.




This command allows you to copy text from stdin into the clipboard1 buffer. Trivial example:
echo 'Hello World!' | pbcopy
“Hello World!” is now in your clipboard.

pbpaste

Pastes from your clipboard to stdout. Trivial example:
echo `pbpaste`


$ pbcopy < file.txt
$ pbpaste 


https://www.papersizes.org/us-paper-sizes.htm
https://www.papersizes.org/a4-foolscap-letter.htm
These are the A4 paper size used internationally, Letter and Legal paper sizes in the US and the old imperial foolscap paper size that was used in the British Commonwealth prior to the introduction of the ISO 216 standard.
Letter at 279mm (11.0") is slightly smaller than A4 at 297mm (11.7"), both Legal at 356mm (14.0") and Foolscap at 330mm (13.0") are longer than A4 with Legal being the longest. Foolscap is the narrowest at 203mm (8.0"), followed by A4 at 210mm (8.3") and then Letter and Legal at 216mm (8.5").

https://www.howtogeek.com/200660/learn-how-to-use-os-x%E2%80%99s-spotlight-search-like-a-champ/
Spotlight is useful enough for simple searches alone, but you can go deeper by using natural language. What does this mean? That you can type surprisingly specific queries and get the results you’d expect. For example: type “pictures from december 2015” and you will see only photos from that specific month.

Or, if you prefer, you can also request the weather in a particular place by typing, for example, “weather in buffalo NY.”
The trick also works for sports scores. Type “NHL scores” and you’ll see a schedule for today and a few recent scores.

You can also use Spotlight as a quick calculator.

There are a few more tricks like this. For example, type “define” followed by any word to see a quick definition from the web.

stock prices, currency conversion, online videos, even results from Maps if you’re looking for the location of a nearby business. It’s not quite as feature complete as Siri in macOS

https://www.cnet.com/how-to/7-ways-to-keep-your-macbook-from-overheating/

4. No laps, no sun

I can no longer plop down on the couch and use my MacBook on my lap or stomach without the fan kicking in almost immediately. When I do want to use it on the couch, I grab a coffee-table book to put it on, to keep my MacBook's vents unobstructed.
MacBooks vent from the back edge, so make sure the back of your MacBook isn't blocked or it will heat up quickly. That means, don't rest it on a pillow or blanket but on a flat surface like a desk, table, counter or book.
I also find the cooling fan spins less frequently when my MacBook Pro isn't sitting in direct sunlight. When the sun hits my kitchen table in the morning, it's time to take my coffee and MacBook to my office. Apple recommends keeping your MacBook in a spot that's between 50 and 95 degrees Fahrenheit (10-35 degrees Celsius).


https://www.macworld.co.uk/how-to/mac/should-i-log-out-my-mac-or-just-shut-down-3623615/
In other words, by the time you notice a significantly decreased battery life, you will probably be buying a newer computer. So plug it in whenever you want. Don’t worry about it at all. (And btw, you can leave the power plugged in as long as you want after the battery is fully charged. It won’t overcharge as long as you are using original Apple power adapters.)

The TL;DR answer? The real destroyer of li-ion battery life is temperature extremes - most commonly heat. Charging practices have comparatively negligible impact on battery life. Just keep the machine cool, actually USE the battery now and then - and you'll be fine. That's it. Finis. That's really seriously all you need to know!

http://osxdaily.com/2014/09/16/how-to-change-the-mail-font-size-in-mac-os-x/
  1. Pull down the “Mail” menu and select “Preferences”
  2. Choose the “Fonts & Colors” tab and adjust the following:
    • To change email message font size: Alongside “Message Font”, click the ‘Select’ button and then use the Size indicator to increase or decrease the font size – the default is size 12
    • To change email inbox list font size: Click the “Select” button next to ‘Message list font’ and adjust the size as desired

https://www.imore.com/voice-memos

  1. Tap the more button on the bottom left of the recording. It's three horizontal dots.
  2. Tap Share.
  3. Tap the method by which you'd like to share your Voice Memo and proceed as normal with your chosen method.
https://www.idownloadblog.com/2018/08/14/howto-voice-memos-mac/
Just click and hold a memo in the list, then drag it to the desktop or a custom folder on your Mac and let go off the finger. Doing so will export the selected memo as an audio file with the .M4A extension.

Voice Memos is especially popular with journalists, bloggers, musicians and other people who conduct interviews for a living
https://www.idownloadblog.com/2018/08/14/howto-voice-memos-mac/
Voice Memos is one of the apps that Mojave brings from iOS to the desktop. These ported apps were realized using Apple’s brand-new framework, coming next year, that it says was designed to make porting existing iPhone and iPad apps to macOS easier.

http://harshj.com/duplicating-a-tab-in-safari/
DUPLICATING A TAB IN SAFARI
  1. Hit the combos: Command + L and then Command + Return (or Enter)
P.s. This technique will not result in the duplicated tab carrying the history of previous pages as it does in Google Chrome. It merely opens the current page in a new tab.

  • Sync Google Contacts in iPhone
    • Add your Gmail account at Settings -> Passwords & Accounts
    • Change to your Gmail account at Settings -> Contacts -> Default Account
    • So now every time you create an account at Phone app in iPhone, it will be synced to Google Contacts.
https://apple.stackexchange.com/questions/139884/make-the-green-full-screen-window-icon-on-yosemite-maximize-windows
In order to maximize the window so that it fills the visible window content, use:
 + Click on green icon
In order to maximize the window both in width and height to the current desktop for applications like Google Chrome use:
 +  + Click on green icon
https://www.cultofmac.com/410346/how-to-maximize-your-el-capitan-windows-without-going-full-screen/
There are two ways to expand any window on your Mac. One trick, which came around when OS X Yosemite did, is to Option-Click the green button itself. That’s all well and good, but it does require a little extra thinking, and if you accidentally hit the green button without the Option key, you’ll get a full screen window. Not good.
The best way, in my opinion, to zoom your windows out to fit the size of the content within them is to double click on the title bar.

https://cheonhyangzhang.wordpress.com/2017/05/26/change-mac-screenshots-folder/
defaults write com.apple.screencapture location ~/Documents/Screenshots
killall SystemUIServer
https://petapixel.com/2017/09/25/make-iphone-shoot-jpegs-ios-11/
In the Camera settings, tap the Formats option.
On the Formats screen, select Most Compatible instead of High Efficiency.
https://www.markandersononline.com/blog/open-safari-without-opening-windows-last-session/
Open Safari Without Opening Windows From The Last Session
defaults write com.apple.Safari NSQuitAlwaysKeepsWindows -bool false
defaults read com.apple.Safari NSQuitAlwaysKeepsWindows
http://brettterpstra.com/projects/markdown-service-tools/

https://computers.tutsplus.com/tutorials/use-markdown-anywhere-on-a-mac-with-markdown-service-tools--cms-21406
Services allow you to extend the functionality of an application by providing a means for it to connect to other applications. 
https://apple.stackexchange.com/questions/3606/how-can-i-choose-to-unrar-with-the-default-application
You might want to try The Unarchiver. It can open many format besides rar files.
Then once you installed it, open its preferences and select all the file format you want him to manage.
http://osxdaily.com/2017/11/22/use-touch-id-sudo-mac/
  1. Open Terminal app if you haven’t done so already, then enter the following command:
  2. sudo nano /etc/pam.d/sudo
  3. Hit Return and then add the following line to the top:
  4. auth sufficient pam_tid.so
  5. Save the edit with Control+O and then exit nano with Control+X

Upgrade os:
App store -> upgrade -> the top banner, free update
- not update software parts
https://apple.stackexchange.com/questions/42345/where-can-i-download-filemerge-the-app-for-comparing-two-tools-and-merging-the
FileMerge is part of Xcode 4.x by Apple which you can download from the Mac App Store.
But FileMerge.app is now embedded inside the Xcode.app package and is not easily accessible as a standalone tool... Unless you do this:
  1. Browse to /Applications/Xcode.app
  2. Right-click -> Show package contents
  3. Contents -> Applications
  4. Right-click FileMerge.app -> Make Alias -> Enter password
  5. Copy the Alias to somewhere, like /Applications
  6. Delete the original Alias
https://apple.stackexchange.com/questions/154506/desktop-icons-rearrange-spontaneously-yosemite
I went into "View" and clicked on to Sort by "None". Simple. Problem solved.
http://teohm.com/blog/mac-tips-change-default-application-for-a-file-type/
To switch the default application for file type, right-click the file, select Get Info and change the application in Open With section.
Remember, remember.. click Change All… button to apply the changes to all files. It seems obvious, but took me a while to figure this out. :)
https://medium.com/productivity-freak/what-if-you-could-really-customize-your-new-touch-bar-ea42ec66f42c
What if you could REALLY customize your new Touch Bar?
Option click EVERYTHING
Ever needed to copy a file’s path to clipboard? Easy, copy as Pathname now appears when you hold the awesome ⌥ modifier!

https://medium.com/productivity-freak/avoiding-productivity-mousetraps-177d80fa533b
⌘+ ⇧ + / : Open the help menu
Hold Option ⌥ + left/right (ctrl on windows) buttons to jump by word. 

10x : Jumpy
For code editing, this is one of those things that you can’t go back from. Jumpy and Acejump are plugins for editors / IDE that are assign short codes to places in the file, and you can jump to those shortcodes without using the mouse.
Hit shift + enter

Add shift to jump by word Shift ⇧ + Option ⌥ + left/right (win: shift+ctrl+left/right)

By just adding a : in the fuzzy file navigation, we can go directly to the line we need, thus saving a LOT of valuable time and keeping focus.
Atom / Sublime3 — File symbols : ⌘+ R 
http://www.dummies.com/computers/macs/macbook/how-to-use-macbooks-automator/
  1. Select Application and click Choose.
  2. Click the desired application in the Library list.
    Automator displays the actions available for that application.
  3. Drag the desired action from the Library window to the workflow window.
  4. Modify any specific settings provided for the action you chose.
  5. Repeat Steps 2–4 to complete the workflow.
  6. Click Run (in the upper right) to test your script.
    Use sample files while you’re fine-tuning your application lest you accidentally do something deleterious to an original (and irreplaceable) file!
  7. When the application is working as you like, press cmd+Shift+S to save it.
  8. In the Save dialog that appears, type a name for your new application.
  9. Click the Where pop-up menu and specify a location where the file should be saved.
  10. Click the File Format pop-up menu and choose Application.
  11. Click Save.

https://apple.stackexchange.com/questions/104624/apply-rules-to-messages-in-mailbox
To apply the rules to existing messages, just select the mailbox and use "Apply Rules" from the "Message" menu. Or use the shortcut ++L
https://discussions.apple.com/thread/3423056
"Smart" boxes are just pointers to mails of certain criteria, you need to create other real Mailboxes & make rules
https://www.howtogeek.com/252635/how-to-organize-your-email-with-smart-mailboxes-in-apple-mail/
One of the more intriguing features of Apple Mail is smart mailboxes, which collate your mail according to a predetermined set of rules. You mail doesn’t actually get moved to these smart mailboxes, it just appears as though it is.

Smart mailboxes are kind of like rules (aka filters), but instead of messages being flagged, copied, or moved based on a filter’s criteria, they remain in your inbox and only appear as if they’ve been moved. Smart mailboxes are a great way of organizing mail pertaining to a certain project or conversation without actually affecting it in any way.

If you have a lot of smart mailboxes of varied purposes, you can create a folder in which to compile similar smart mailboxes in one place

https://www.lifewire.com/os-x-mailbox-search-1165024
  1. Click in the Search field.
    • ​​You can also press Alt-Command-F.
  1. ​Make sure the current—and desired—folder is selected in the Mailboxes bar under Search:.
    • ​​To have macOS search all folders, make sure All is selected.
https://superuser.com/questions/303525/what-is-the-shortcut-to-access-the-menubar-in-mac-os-x

The exact same functionality doesn’t exist on Mac OS X. There's no concept of underlined characters in the menus for quick selection.
You can move keyboard focus to the menu bar by pressing Ctrl+F2. Configure the shortcut in System Preferences.
You can press Cmd+? and start typing any menu bar item label to select it from the Help menu entry. This helps tremendously with the menus of rather complex applications.
enter image description here
If you’re a Mac newcomer or have just installed a new app, it’s handy to get an overview of available shortcuts. CheatSheet provides such a thing in a user-friendly manner.
https://istweb.apple.com/supporting-apps/directory/
Capture the entire screen
Step 1: Press the “Command” + “Shift” + “3” keys simultaneously.
That will save a copy of your screen to your clipboard. You can alternatively press the same combination without the “Command” key in order to save the image as a PNG file to your desktop.
Capture a selected area
Step 1: Press the “Command” + “Shift” + “4” keys simultaneously.
Step 2: With your mouse pointer turned into a crosshair, use it to select the region you wish to capture.
Step 3: You can fine-tune your selection by pressing the space bar, which will let you take a full-screen capture or to select an open menu.
Your selection will then be copied to the clipboard. Alternatively, don’t press the “Command” key and your screenshot will be saved to the desktop as a PNG file.

https://www.tekrevue.com/tip/event-attachments-calendar-mac/
If you attach a file to a Calendar event and then later delete that event, it will also delete the copy of the file you attached. The Calendar app will warn you with a confirmation box before it lets you delete events with attachments, but just make sure that any important files are still backed up in their original locations prior to deleting their associated Calendar events.
How to remove Siri from the Touch Bar on the MacBook Pro
https://howchoo.com/g/zjbimjyxztr/how-to-remove-siri-from-the-touch-bar-on-the-macbook-pro#customize-the-control-strip
Highlight the Siri button, click, and drag the Siri button upward and out of the Touch Bar. It will now disappear.

#### Change Notification type
- Preferences > Notifications
- None: no notification at all, Banners go away automatically, Alters stays until user dismisses it

https://imusic.aimersoft.com/transfer-music/itunes-manually-manage-music.html
How to Set "Manually Manage Music" in iTunes
  • Step 3: Click on your device icon near the top-left corner of your iTunes window.
  • Step 4: Select Summary option from the device’s settings appearing on the left side on the screen.
  • Step 5: Look out for “Options” and tick the check box next to "Manually manage music and videos". Then click Apply.
http://osxdaily.com/category/mac-os-x/

https://www.scrubly.com/blog/how-to-mac-mail/29-shortcuts-for-apple-mail-youll-love/
  • New message – command + N
  • Send message – command + shift + D
  • Save as draft – command + S
  • Forward message – command + shift + F
  • Attach file to message command + shift + A
  • Reply all – command + shift + R
  • Mark as read/unread – command + shift + U
  • Go to inbox – command + 1
  • Go to other items in favorites – command + 2, command + 3, etc…
  • Jump to the search field – command + option + F
https://www.lifewire.com/vip-email-alerts-os-x-mail-1172746
  1. Select Mail | Preferences… from the menu in Mac OS X Mail.
  2. Go to the General tab.
  3. Select the desired category for which you want to receive new message alerts under New message notifications::
    https://www.cultofmac.com/185867/only-get-notifications-for-a-specific-mailbox-in-mountain-lion-os-x-tips/

    https://support.apple.com/guide/mail/use-smart-mailboxes-mlhlp1190/mac
    https://support.apple.com/guide/mail/create-or-delete-mailboxes-mlhlp1021/mac
    A Smart Mailbox displays messages that are stored in other mailboxes and that meet certain criteria you specify. For example, a Smart Mailbox could include all the messages you receive about a specific project, regardless of which mailboxes the messages are stored in.
    https://www.imore.com/how-quickly-add-contact-your-vip-list-mac-mail
    To add the person to your VIP list, simply click on Add to VIPs.
    http://osxdaily.com/2014/01/29/change-notifications-banner-time-mac-os-x/

    First, it’s important to differentiate between “Banners” and “Alerts”; a banner will slide in and slide out of the Mac screen without interaction (or you can swipe on it to dismiss), while alerts require some sort of user involvement with manually closing or rescheduling the alert. In terms of identification, if the notification has a button attached to it, it’s an alert, otherwise it’s a banner.

    Users can change between banners and alerts by going to  > System Preferences > Notifications and selecting the app or service and choosing which they’d prefer.
    You’ll need to use the Terminal and defaults command strings to adjust the banner persistence time. Once you’re at the command prompt use the following syntax:
    defaults write com.apple.notificationcenterui bannerTime [time in seconds]
    defaults delete com.apple.notificationcenterui bannerTime
    https://www.dssw.co.uk/reference/pmset.html









































































    pmset — manipulate power management settings

    http://osxdaily.com/2011/03/21/temporarily-prevent-a-mac-from-sleeping/
    Temporarily Prevent a Mac from Sleeping
    pmset noidle
    This will prevent your Mac from sleeping indefinitely until pmset is no longer running. You can stop pmset from running by hitting Control+C in the same Terminal window. pmset is a power management utility that you can use to set sleep and wake times, but the noidle flag just provides a single use sleep prevention method.
    https://www.igeeksblog.com/best-ipad-video-player-apps/
    #1. OPlayer Lite
    #2. PlayerXtreme Media Player
    https://support.apple.com/kb/PH26216?locale=en_US&viewlocale=en_US
    macOS Sierra: Use Touch ID on your Mac

    https://www.cnet.com/news/access-menus-via-the-keyboard-in-os-x/
    Apple's default option for accessing the menus is to press Control-F2. However, this may sometimes not work, especially if you have the function hot keys used for other features like the Dashboard, Launch Pad, and other system controls and services.

    http://www.hammerspoon.org/go/#helloworld
    hs.hotkey.bind({"cmd", "alt", "ctrl"}, "W", function()
      hs.alert.show("Hello World!")
    end)
    hs.hotkey.bind({"cmd", "alt", "ctrl"}, "H", function()
      local win = hs.window.focusedWindow()
      local f = win:frame()
    
      f.x = f.x - 10
      win:setFrame(f)
    end)
    
    This will now cause ++ctrl+H to make move the currently focused window 10 pixels to the left. You can see that we fetch the currently focused window and then obtain its frame. This describes the location and size of the window. We can then modify the frame and apply it back to the window using setFrame().


    You will need to create a Lua script in~/.hammerspoon/init.lua using our APIs and standard Lua APIs.
    https://lifehacker.com/hammerspoon-is-powerful-free-automation-tool-for-os-x-1757351485
    Mac: There’s all kinds of automation tools on OS X, from the built-in Automator to commercial options like Keyboard Maestro. Hammerspoon’s another tool that sits in the same space, but works a little more like something like AutoHotKey.


    http://smallbusiness.chron.com/remove-gestures-mac-38529.html
    2. Click “Trackpad.” Three tabs appear at the top of the Trackpad settings window: “Point & Click,” “Scroll & Zoom” and “More Gestures.”
    3. Click a tab to view a list of the gestures in that category. For example, click “More Gestures” to see gestures such as “Swipe Between Pages” and “Show Desktop.”
    4. Click the check box next to the name of a gesture to deselect it. The gesture is now disabled. When you are finished removing gestures, click the red circle at the top of the Trackpad settings window to close it.
    http://deviceguides.vodafone.ie/web/apple-iphone-6-plus-ios8/explore/gps-maps-and-navigation/turn-gps-on-or-off
    Find "Location Services"
    Press Settings.
    Press Privacy.
    Press Location Services.
    https://gadgets.ndtv.com/apps/news/google-rolls-out-bill-reminder-feature-to-search-app-for-android-and-ios-603690


    127.0.0.1 MacBook-Pro.local
    dscacheutil -flushcache;sudo killall -HUP mDNSResponder

    https://www.howtoisolve.com/how-to-disable-enable-auto-updates-on-mac-os-x-yosemite-mavericks-and-apps/
    Step 1: Go to the Apple menu from the top bar.
    Step 2: Then, Click on System Preference option.
    Step 3: Next, Click on App store.
    Step 4: Setting Mainly Divided into different portion, Free updates, and Premium updates.
    Keychain
    https://help.queens.edu/hc/en-us/articles/205937040-How-to-Resolve-Mac-OS-X-Keychain-Problems
    The quickest way to reset your keychain in Mac OS X 10.4 or later:
    1. Open Keychain Access, which is in the Utilities folder within the Applications folder.
    2. From the Keychain Access menu, choose Preferences.
    3. Click General, then click Reset My Default Keychain.
    4. Authenticate with your account login password.
    5. Quit Keychain Access.
    6. Restart your computer.

    https://www.howtogeek.com/252635/how-to-organize-your-email-with-smart-mailboxes-in-apple-mail/
    https://support.apple.com/guide/mail/use-rules-to-manage-your-inbox-mlhlp1017/mac

    https://www.macworld.co.uk/how-to/mac/making-phone-calls-on-mac-3593777/
    1. Log both your iPhone and your Mac onto the same WiFi network.
    2. On your iPhone, go to Settings > iPhone > Calls on Other Devices and choose the devices that you can allow calls on.
    3. On you Mac, open FaceTime and choose FaceTime > Preferences and make sure ‘Calls from iPhone’ is selected
    http://osxdaily.com/2017/03/01/disable-mac-camera-completely/
    http://osxdaily.com/2015/10/05/disable-rootless-system-integrity-protection-mac-os-x/

    https://www.howtogeek.com/241937/how-to-adjust-your-macs-screen-brightness-manually-and-automatically/
    To enable or disable this option, open the System Preferences window and click the “Energy Saver” icon. Enable the “Slightly dim the display while on battery power” checkbox under the Battery tab to make your Mac’s screen dimmer when on battery power, or uncheck it to prevent your Mac from dimming the display automatically. Just remember that unchecking it might drain your battery faster.
    https://www.laptopmag.com/articles/switch-between-open-apps-osx
    1. Use Command-Tab and Command-Shift-Tab to cycle forward and backward through your open applications. (This functionality is almost identical to Alt-Tab on PCs.)
    2. Or, swipe up on the touchpad with three fingers to view the windows of open apps, allowing you to quickly switch between programs. This view is called Mission Control, which also has its own dedicated keyboard shortcut (F3).
    https://stackoverflow.com/questions/35004054/move-eclipse-app
    Looks like the installer puts a lot of files, including the actual plugins, into folders under the .p2 folder in your home directory. This is true no matter where you install eclipse, with the installer. So either other users would need at least read access to some locations in your account, or you moved your .p2 folder to a central location and changed the eclipse.ini file (embedded in a folder under the eclipse.app folder) to point to the correct location. If you leave the .p2 folder in your account, you'd still need to alter the myeclipse.ini file, as it uses relative paths to files

    For your situation, you might be better off using the standard installation method (unzipping the distribution file), moving the installation to /Applications.
    The likely problem here is that Eclipse anticipates the directory structure around it, and fails when the actual directory structure doesn't match its expectations. The simplest solution is to create an alias (like a PC shortcut) in the Applications folder that links back to the application in the folder where it is installed by default.
    To do this on a Mac, right click the application, which should be in the user root like so:
    ~/eclipse/java-mars/Eclipse.app
    
    You should see the dropdown below. Click the "Make Alias" option to create an alias for Eclipse in the same folder. Then just rename this alias "Eclipse," and drag and drop it in Applications, where it should work just fine. 

    http://osxdaily.com/2011/03/14/show-remaining-battery-life-in-the-mac-os-x-menu-bar/
    1. Click on the Battery icon in the upper right corner of the Mac menu bar
    2. Pull down and choose “Show Percentage” so that it’s checked – note that older versions of OS X will have two options to ‘Show’ and select ‘Time’ or ‘Percentage’
    https://discussions.apple.com/thread/4306641?tstart=0
    I already went to System Preferences > Notifications and set Mail Alert Style to "none" and also unchecking notification center, badge app icon and sound options.

    Despite taking these steps, the mail icon in my dock displays a "new email" light and dings whenever I receive a new email.

    https://www.cultofmac.com/269328/handy-keyboard-shortcuts-shut-sleep-mac-os-x-tips/

    Shut down your Mac

    To simply shut down your Mac safely and securely — letting all the background voodoo happen automatically — hit Control-Option-Command-Power (or Control-Option-Command-Eject). This will quit open programs and shut down your Mac without you needing to intervene or hit a confirmation button. This is an extremely helpful keyboard shortcut.

    Put your Mac to sleep

    If you want to send your Mac to sleep, hit Option-Command-Power (or Control-Option-Command-Eject). Your Mac will go to sleep, gently and effortlessly. It’s like a narcolepsy command for your Mac.
    f you want to put only the display to sleep, effectively locking your Mac (provided you have a wake from display sleep password), just hit Control-Shift-Power (or Control-Shift-Eject).

    Restart your Mac

    And, of course, if you want to restart your Mac, hit Control-Command-Power (or Control-Command/Eject for a quick reboot of your favorite machine.
    https://en.wikipedia.org/wiki/PF_%28firewall%29
    http://apple.stackexchange.com/questions/254654/port-forwarding-on-macos-sierra


    http://serverfault.com/questions/102416/iptables-equivalent-for-mac-os-x
    I want to forward requests from 192.168.99.100:80 to 127.0.0.1:8000. This is how I'd do it in linux using iptables:

    iptables -t nat -A OUTPUT -p tcp --dport 80 -d 192.168.99.100 -j DNAT --to-destination 127.0.0.1:8000
    sudo ifconfig lo0 10.0.0.1 alias
    sudo ipfw add fwd 127.0.0.1,9090 tcp from me to 10.0.0.1 dst-port 80
    http://serverfault.com/questions/574116/hostname-to-localhost-with-port-osx
    iptables -t nat -I PREROUTING -p tcp -d 192.168.1.0/24 --dport 2222 -j DNAT --to-destination 127.0.0.1:2222
    https://support.rackspace.com/how-to/modify-your-hosts-file/
    Make your changes take effect by flushing the DNS cache with the following command:
    dscacheutil -flushcache
    http://superuser.com/questions/478035/command-line-ssh-restart-mac-osx-mountain-lion
    There is no reason to 'unload' the sshd service, when instead you can just 'Stop' the sshd service. It will restart on it's own.
    sudo launchctl stop com.openssh.sshd
    http://www.launchd.info/
    a unified, open-source service management framework for starting, stopping and managing daemons, applications, processes, and scripts
    The behavior of a daemon/agent is specified in a special XML file called a property list. Depending on where it is stored it will be treated as a daemon or an agent.
    Job definitions crucial for the operation of the operating system are stored below /System/Library. You should never need to create a daemon or agent in these directories. Third-Party definitions which are relevant for every user are stored below /Library. Job definitions for a specific user are stored below the respective user's Library directory.
    TypeLocationRun on behalf of
    User Agents~/Library/LaunchAgentsCurrently logged in user
    Global Agents/Library/LaunchAgentsCurrently logged in user
    Global Daemons/Library/LaunchDaemonsroot or the user specified with the key UserName
    System Agents/System/Library/LaunchAgentsCurrently logged in user
    System Daemons/System/Library/LaunchDaemonsroot or the user specified with the key UserName
    https://technet.microsoft.com/en-us/library/mt269079(v=office.16).aspx

    http://osxdaily.com/2010/03/18/how-to-rename-a-file-or-folder-in-mac-os-x/
    Rename a file or folder by selecting it and hitting the ‘return’ key

    McAFee - process VShieldScan
    1. On the client system, right-click the McAfee system tray icon and select Quick Settings.
    Add folder to exclude form scan
    http://osxdaily.com/2010/10/08/mac-virtual-memory-swap/
    Mac OS X Swap File Location
    If you’re curious where the swap files are stored on your Mac, they’re located at:

    /private/var/vm/

    This directly also contains your sleepimage file, which is essentially what your Mac has been storing in memory prior to system sleep. This file is read again when you wake your Mac up to return to it’s previous state

    back to swap files in the same directory: they are named successively swapfile0, swapfile1, swapfile2, swapfile3, swapfile4, swapfile5. You can see them for yourself with the following command:
    ls -lh /private/var/vm/swapfile*

    sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist

    Again, this completely disables the Mac OS X paging ability, do not mess around with this for fun.

    Your next step would be to remove the swapfiles that are currently stored, they are generally pretty large (it is your virtual memory after all) and take up a fair amount of disk space.

    sudo rm /private/var/vm/swapfile*

    https://developer.apple.com/library/content/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLaunchdJobs.html
    http://www.grivet-tools.com/blog/2014/launchdaemons-vs-launchagents/

    http://www.launchd.info/
    launchd as "a unified, open-source service management framework for starting, stopping and managing daemons, applications, processes, and scripts. Written and designed by Dave Zarzycki at Apple

    http://www.dgkapps.com/blog/osx-tips/OSX-Tips-System-Startup-launchd-launch-daemons-startup-items-launch-agents-and-login-items
    Launch Daemons and Startup Items are launched during system boot up and affect the whole system.
    System processes are described by launchd preference files located in:
    /System/Library/LaunchDaemons
    Third party processes are described by preference files located in:
    /Library/LaunchDaemons
    launchd also runs SystemStarter during boot, which loads legacy third-party OSX startup items described in:
    /System/Library/StartupItems
    and
    /Library/StartupItems

    Launch Agents & Login Items

    Launch Agents and Login Items are launched once a user is logged in and effect only that user.
    Launch Agents are usually loaded when the user logs in. Those provided by the system are found in:
    /System/Library/LaunchAgents
    or
    /Library/LaunchAgents
    Third-party launch agents are found in any of:
    /System/Library/LaunchAgents
    /Library/LaunchAgents
    ~/Library/LaunchAgents
    Login Items are started at the very end of the user’s login and can be found in:
    ~/Library/Preferences/com.apple.loginitems.plist
    http://unix.stackexchange.com/questions/4681/how-do-you-sort-du-output-by-size
    du -h -d 1 | gsort -h
    du -h -d 1 | gsort -h -r

    Command+space - spotlight search
    http://osxdaily.com/2011/12/30/exclude-drives-or-folders-from-spotlight-index-mac-os-x/
    • Launch System Preferences from the  Apple menu and choose the “Spotlight” preference panel
    • Click on the “Privacy” tab
    • Drag & drop folders or drives to exclude from the Spotlight index, or click the “+” plus icon in the corner to manually select hard drives or directories
    Whatever folder or drive in that list is effectively hidden from the Spotlight index, making the contents not be indexed, and not appear in any file searches, whether it’s from the primary Command+Spacebar Spotlight menu, or Finder-window searches. This is a much better approach than disabling Spotlight if all you want to do is hide certain files from prying eyes. Additionally, if you don’t want Spotlight to run when you plug in an external hard drive, you can just add it to that list to have it not be indexed (of course, that means it won’t be searchable with Spotlight though too).

    https://www.tekrevue.com/tip/three-ways-to-prevent-spotlight-from-indexing-items-on-your-mac/
    First, and most bluntly, you can turn Spotlight off entirely. Note that this will also affect your ability to search within most of Apple’s applications, such as Mail and Finder, as they rely on the same Spotlight foundation that we’re about to kill.
    Open up Terminal from /Applications/Utilities and enter the following command to kill Spotlight entirely (you’ll need administrative privileges to execute the command):
    sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist

    sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist

    https://www.tekrevue.com/tip/show-spotlight-results-in-finder/
    Preview Spotlight Location with Command Key

    Reveal the Spotlight Result’s Location in Finder
    Simply highlight the desired result in Spotlight, hold the Command key, and press Return (or hold Command and double-click on the result). Normally, pressing Return will open the file or launch the application, but adding the Command key to the mix instead opens a new Finder window showing the folder that contains the Spotlight search result.
    http://osxdaily.com/2010/02/26/use-the-tab-key-to-switch-between-dialog-buttons-in-mac-os-x/
    http://apple.stackexchange.com/questions/7263/how-can-i-activate-buttons-with-just-the-keyboard
    •  (TAB) will move between buttons.
    • esc (ESC) is cancel.
    • space (SPACE) selects the active button (blue, outline).
    •  (RETURN) is OK or the default button (blue, pulsing, filled).
    http://apple.stackexchange.com/questions/113191/search-in-a-particular-folder-and-subfolder-through-spotlight
    If you want to search into a specific folder and its subfolders, you will need to go into the specific folder in Finder, use the search bar on the top-right corner of the window, and select the name of the folder on the same bar where it has the button "This Mac"

    http://apple.stackexchange.com/questions/122514/how-do-i-do-a-diagonal-arrow-keyboard-shortcut
    I suggest you to open your keyboard visualizer (by clicking on the flag that is near the clock in the menu bar).
    This will make appear a window with a keyboard representation.
    If you press the fn key, you'll see that the  will become a ↖︎ (Home key) in this window while  will become ↘︎ (End key).
    That's it: just press the fn+ or fn+ to obtain the diagonal-arrow.

    http://stonebreaker.calka.org/index.php?id=how-to-fix-a-problem-with-parentalcontrolsd-process-running-with-high-cpu-load-in-mac-os-x-mountain-lion
    Run System Preferences -> go to Users & Groups
    Disable Parental Controls on all users' accounts (including Guest account) - if enabled of course.
    Delete the "ParentalControls" directory located in /Library/Application Support/Apple/
    * You can do this by running the Terminal application and use the command below:
    sudo rm -rf /Library/Application\ Support/Apple/ParentalControls/
    
    At the moment, all I can offer is this: Macs have two useful commands for processes. Go to 'terminal' to use them:

    pgrep parentalcontrolsd (or even just pgrep parental - it works with partial names)

    If you get a number back, then parentalcontrolsd is running.

    Then you need:
    sudo pkill -9 parentalcontrolsd (you'll get prompted for your password - you need sudo to run this as root)

    This kills it stone dead (as you can see in the screenshot). Use pgrep to check.


    http://www.imore.com/how-open-apps-unidentified-developer-os-x-mountain-lion
    Ctrl+click or right click on the app and select Open from the contextual menu.
    How to change Gatekeeper settings to allow or disallow unidentified apps
    System Preferences > Privacy & Security > General > Allow applications downloaded from

    http://superuser.com/questions/581347/where-is-the-temp-folder-in-os-x/581355
    You can use: echo $TMPDIR.
    To open and browse the folder, use open $TMPDIR.
    http://osxdaily.com/2007/04/06/change-the-default-web-browser-in-mac-os-x/
    System Preferences > General > Default web browser

    http://heresthethingblog.com/2014/02/24/mac-tip-zoom-entire-display/
    System Preferences > Accessibility > Zoom
    Check "Use keyboard shortcuts to zoom":
    COMMAND + OPTION + 8 > Toogle Zoom
    COMMAND + OPTION + = > zoom out
    COMMAND + OPTION + - > zoom in

    Check "Use scroll gesture with modifier keys to zoom"
    Scroll scroll on the trackpad while pressing one of keys: CONTROL, OPTION, or COMMAND

    Most applications supports:
    COMMAND + "+" > zoom out
    COMMAND + "-" > zoom in
    http://osxdaily.com/2011/08/31/go-to-folder-useful-mac-os-x-keyboard-shortcut/
    1. From the “Go” menu navigate down to “Go to Folder” ….or better yet…
    2. Hit Command+Shift+G from the OS X desktop or a Finder window
    Tab completion works like this, you start to type a directory path or filename and hit the Tab key to complete the text for you, preventing you from typing out the entire thing.

    The Go To window also supports drag and drop, so if you already have a folder open somewhere or you just want to quickly retrieve the full path of something, just drag and drop a directory or file into the Go To Folder window.

    Automatically Hide the Dock
    System Preferences > Dock > Automatically hide and show the Dock
    Force Quit Applications

    Command+Option+D: hide or show dock

    Mac web developer apps
    https://gist.github.com/erikreagan/3259442

    https://mattstauffer.co/blog/setting-up-a-new-os-x-development-machine-part-1-core-files-and-custom-shell

    https://github.com/macdao/ocds-guide-to-setting-up-mac
    语音
    OS X 自带了语音功能,可以用say命令让 Mac 开口说话:
    say hello
    可以和&&或者;配合使用来提示你某任务已经完成:
    brew update && brew upgrade && brew cleanup ; say mission complete
    通过命令行来听取发音还是有点麻烦。其实我们几乎可以在任何地方选中单词,然后使用快捷键⌥+ESC发音。仅仅需要这样设置一下:选择System Preferences > Dictation & Speech,在Text to Speech标签页中选中Speak selected text when the key is pressed
    OS X 自带了词典(Dictionary)。你几乎可以在任何应用中通过三指轻拍触摸板来现实对应单词的释义。
    钥匙串访问(Keychain Access)是一个 OS X 应用程序,对我来说它最大的功能就是查看已经保存的各种账号和密码,包括 Wi-Fi 密码。
    brew cask install java
    如果你需要安装 JDK 7 或者 JDK 6,可以使用homebrew-cask-versions
    brew tap caskroom/versions
    brew cask install java6
    JAVA_HOME=/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home java -version
    其中JAVA_HOME=/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home可以用JAVA_HOME=`/usr/libexec/java_home -v 1.6`这种更加通用的方式代替。
    添加以下脚本到当前 shell 配置文件中:~/.zprofile或者~/.bash_profile
    function setjdk() {
        export JAVA_HOME=`/usr/libexec/java_home -v $@`
    }
    这样我们就可以通过输入一条命令进行版本切换了:
    setjdk 1.8
    Tools:
    open -a Terminal .
    open -a iTerm .
    http://www.idownloadblog.com/2014/05/18/how-to-find-a-wi-fi-password-on-mac/
    Step 1: Type Keychain Access into Spotlight search (Screen Shot 2014-05-16 at 2.54.07 PM) at the top-right menu bar.

    Step 2: In the sidebar, make sure you click on Passwords, then search for the network you want the password for and double click on it.
    Step 3: Click on Show Password. Confirm your administrator username and password.
    http://apple.stackexchange.com/questions/41001/how-can-i-get-the-terminal-to-keep-a-separate-history-per-tab-window
    export HISTFILE="$HOME/.bash_history_$TERM_SESSION_ID"
    if [ ! -e $HISTFILE ]; then cp "$HOME/.bash_history" "$HISTFILE"; fi

    https://gist.github.com/eric-hu/5846890

    http://superuser.com/questions/605410/cant-enable-swaping-in-mac-os-x-10-8-3
    http://wiki.summercode.com/how_to_disable_or_enable_swapping_in_mac_os_x

    5 Ways to Force Quit an Application in OS X
    1. In the Dock, right-click the icon of the unresponsive application.
    2. Hold down the Option key, and you’ll see “Quit” change to “Force-Quit.”

    http://blog.2baxb.me/archives/1250
    Homebrew + cask
    iTerm2
    代替terminal,提供了不少扩展功能,我最喜欢的是自动完成和分屏广播。

    mac下的docker主要贡献是调试应用更简单了。

    BetterZip
    压缩包查看和解压工具,把这个也列上的原因是很多人推荐的解压工具没有查看功能只能解压缩让我很不习惯。

    MacVim
    Macdown & Mou
    mou是之前用的人比较多的markdown编辑器,但是目前项目处于长草状态。Macdown是mou的开源版,目前长势良好,推荐作为mou的代替品。

    Markdown Plus
    不错的Markdown编辑器,支持各种让人爱不释手的特性(最重要的是支持vim键位),虽然目前不是非常成熟,不过我已经入坑了。

    jd-gui

    Alfred2+PowerPack
    mac下的神级应用,用键盘搞定从找文件到开应用、从查字典到查网页等各类问题问题,长处就一个字:快。
    有道翻译:查单词
    http codes:查http状态码
    pm2.5:查pm
    dash:查函数文档
    encode/decode:字符转码
    copy path:复制finder中的路径
    dns switch:翻墙用
    强烈推荐购买Powerpack,否则系统自带的spotlight就行了。

    ynergy
    在多个电脑之间共享键盘、鼠标和剪贴板的工具,支持linux、mac和windows系统

    OneNote
    Notes.app
    系统自带的备忘工具,随时记个事情之类的很方便。

    mindmanager
    思维导图工具。

    Using The Force Quit Window
    simply press “Command + Option + Escape” on your Mac, which will bring up the force-quit window:

    Force-Quit Using Activity Monitor

    Automatically Hide the Dock When Not in Use
    Open System Preferences from the  Apple menu and choose “Dock”
    Check the box for “Automatically hide and show the Dock” by clicking the checkbox next to it
    Colorize Mac 'Ls' Output
    http://tech-queries.blogspot.com/2010/09/colorize-mac-ls-output.html
    alias ls="ls -G"

    Safari
    To access developer tools, enable the Develop menu in Safari’s Advanced preferences.

    Open 7z: Unarchiver

    Page up/downUse the up and down arrow keys for one line at a time
    Use the up and down arrow keys while holding the Command key for Home-End
    Use the up and down arrow keys while holding the Option key for one page at a time


    Changing the priority of your wireless connections - Mac OSX
    Click the Advanced button in Network Preferences.

    Mac uninstall jdk:
    sudo rm -rf /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk

    diff tool
    http://www.git-tower.com/blog/diff-tools-mac/

    http://www.huffingtonpost.com/2014/04

    Clean Mac
    http://guides.macrumors.com/Cleaning_Your_Mac's_Hard_Drive
    • Download the application AppZapper (or any similar app uninstaller) and go through your application folder, removing all unneeded and unused applications you can find.
    • Download the application Monolingual and remove all localization files not used for your language. This can free up to 2GB of space, a significant step to freeing space.
    • Open iPhoto and delete photos you no longer need. iPhoto has its own application trash so remember to empty that.
    • Open iTunes and delete all of the music and podcasts you no longer like or need.
    • Spend some time and go through your Documents, Movies, and Pictures folder, deleting any junk you no longer have any use for.
    • Clear out old email messages in Mail or other email program.
    • Go to ~/Library/Caches/, and delete anything you see from applications you no longer have installed. Repeat the process in ~/Library/Preferences/.
    • Go to ~/Library/Safari/, and delete the “Icons” folder. This stores all of the favicons on websites, which appear next to the URL. This can also speed up web browsing speed in Safari.
    • If you don’t use it, remove Mac OS 9. To remove it, drag the "System Folder" and the "Application (Mac OS 9)" folders to the trash from the root of your hard drive.
    • If you don’t need it, remove the Xcode installer, located in /Applications/Installers/.
    • Go to ~/Music/GarageBand/ and delete any GarageBand demo songs.
    • Remove unecessary iChat icons from ~/Pictures/iChat Icons/.

    http://www.chriswrites.com/10-tips-to-free-up-hard-drive-space-in-mac-os-x/
    http://macpaw.com/how-to/delete-junk-files-on-mac

    Labels

    Review (572) System Design (334) System Design - Review (198) Java (189) Coding (75) Interview-System Design (65) Interview (63) Book Notes (59) Coding - Review (59) to-do (45) Linux (43) Knowledge (39) Interview-Java (35) Knowledge - Review (32) Database (31) Design Patterns (31) Big Data (29) Product Architecture (28) MultiThread (27) Soft Skills (27) Concurrency (26) Cracking Code Interview (26) Miscs (25) Distributed (24) OOD Design (24) Google (23) Career (22) Interview - Review (21) Java - Code (21) Operating System (21) Interview Q&A (20) System Design - Practice (20) Tips (19) Algorithm (17) Company - Facebook (17) Security (17) How to Ace Interview (16) Brain Teaser (14) Linux - Shell (14) Redis (14) Testing (14) Tools (14) Code Quality (13) Search (13) Spark (13) Spring (13) Company - LinkedIn (12) How to (12) Interview-Database (12) Interview-Operating System (12) Solr (12) Architecture Principles (11) Resource (10) Amazon (9) Cache (9) Git (9) Interview - MultiThread (9) Scalability (9) Trouble Shooting (9) Web Dev (9) Architecture Model (8) Better Programmer (8) Cassandra (8) Company - Uber (8) Java67 (8) Math (8) OO Design principles (8) SOLID (8) Design (7) Interview Corner (7) JVM (7) Java Basics (7) Kafka (7) Mac (7) Machine Learning (7) NoSQL (7) C++ (6) Chrome (6) File System (6) Highscalability (6) How to Better (6) Network (6) Restful (6) CareerCup (5) Code Review (5) Hash (5) How to Interview (5) JDK Source Code (5) JavaScript (5) Leetcode (5) Must Known (5) Python (5)

    Popular Posts