Quickies

[categories] [index] [all (525)] [latest]

Mac OS X - CLI
  1. $ sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'select LSQuarantineDataURLString from LSQuarantineEvent'
    

    you can delete the table with:

    $ sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'delete from LSQuarantineEvent'
    
  2. $ /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/AppleMobileDeviceHelper.app/Contents/Resources/AppleMobileBackup --help
    
  3. $ atos -o MyiPhoneBinary -arch armv7 0x00009f16
    -[AppDelegate application:didFinishLaunchingWithOptions:] (in MyiPhoneBinary) (AppDelegate.m:253)
    
  4. $ ioreg -l | grep Capacity
        | |           "MaxCapacity" = 4047
        | |           "CurrentCapacity" = 3901
        | |           "LegacyBatteryInfo" = {"Amperage"=18446744073709548440,
                                             "Flags"=4,"Capacity"=4047,
                                             "Current"=3901,
                                             "Voltage"=11976,
                                             "Cycle Count"=283}
        | |           "DesignCapacity" = 4600
    
    • MaxCapacity is capacity at full charge
    • DesignCapacity is the original capacity
    • "Cycle Count" is the number of recharge cycles
  5. $ install_name_tool -change libbz2.1.0.2.dylib @executable_path/../Frameworks/libbz2.1.0.2.dylib MyFunBinary 
    
  6. $ pmset -g
     sleep      0 (imposed by 6783)
    

    here, process 6783 is responsible

  7. $ sudo gcc_select 3.3
    $ sudo gcc_select 4.0
    
  8. This solution needs Apple Pages and pandoc.

    # in Pages, convert x.doc into x.rtf
    $ textutil -convert html x.rtf -output x.html
    $ pandoc -f html -t markdown x.html -o x.markdown
    
  9. for i in *.HEIC; do sips -Z 2016 format jpeg -s formatOptions 80 "${i}" --out "${i%HEIC}jpg"; done
    
  10. $ plutil -convert xml1 foo.plist 
    $ plutil -convert binary1 bar.plist 
    
  11. $ diskutil erasevolume HFS+ 'RAM Disk' `hdiutil attach -nomount ram://204800`  
    
  12. hdiutil create -fs HFS+ -volname VOL_NAME -srcfolder SRC DST.dmg
    
  13. $ sudo mdutil -E -i on /
    
  14. $ defaults write com.apple.ImageCapture disableHotPlug -bool YES
    
  15. $ defaults write com.apple.LaunchServices LSQuarantine -bool NO
    

    on a file basis

    $ xattr -d com.apple.quarantine PATH
    
  16. $ sudo mdutil -E off -d /
    
  17. sqlite3 ~/Library/Safari/CloudTabs.db "select url from cloud_tabs;"
    

    Requires to disable SIP.

  18. $ /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -dump
    
  19. $ defaults write com.apple.NetworkBrowser BrowseAllInterfaces 1
    
  20. $ codesign -dvvvv --extract-certificates /Applications/Mail.app
    

    The certificates are saved in DER format, named codesign0, codesign1, ...

    They can be displayed with OpenSSL :

    $ openssl x509 -inform DER -in codesign0 -text
    
  21. $ /System/Library/Frameworks/JavaScriptCore.framework/Versions/Current/Resources/jsc
    > 1+1
    2
    
  22. Prevent /usr/bin/login from searching the system logs so that it can display the date and time of your last login.

    $ touch .hushlogin
    
  23. $ sudo opensnoop -f /path/to/file
    $ sudo opensnoop -n Terminal
    $ sudo opensnoop -p <pid>
    
  24. $ sudo update_prebinding -root /
    
  25. End the directory name with .noindex

  26. $ defaults read /Library/Preferences/SystemConfiguration/com.apple.airport.preferences RememberedNetworks | grep SSID_STR
    
  27. Delete recursively starting from current directory.

    $ find . -name .DS_Store -ls -exec rm {} ;
    

    To be used through an alias such as rmDS, for instance.

    If you don't need to print the delete file names:

    $ find . -name ".DS_Store" -delete
    
  28. # diskutil repairPermissions /
    
  29. With sips, a built-in Mac OS X tool.

    $ sips -Z 640 *.jpg
    
  30. $ sudo periodic daily weekly monthly
    
  31. # softwareupdate -i -a
    

    no need to open Mac App Store

  32. $ otool -v -s __TEXT __objc_methname RuntimeBrowser 
    RuntimeBrowser:
    Contents of (__TEXT,__objc_methname) section
    0x000000010000b450  init
    0x000000010000b455  mainBundle
    0x000000010000b460  pathForResource:ofType:
    ...
    
  33. $ defaults write NSGlobalDomain InitialKeyRepeat -int 7
    $ defaults write NSGlobalDomain KeyRepeat -int 0
    

    Here, smaller is better.

  34. $ otool -L /Users/nst/Desktop/InstrumentServer.app/Contents/MacOS/InstrumentServer 
    /Users/nst/Desktop/InstrumentServer.app/Contents/MacOS/InstrumentServer:
            /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 11.0.0)
            @executable_path/../Frameworks/NostromoSeries.framework/Versions/A/NostromoSeries (compatibility version 1.0.0, current version 1.0.0)
            @executable_path/../Frameworks/SenCC.framework/Versions/A/SenCC (compatibility version 1.0.0, current version 1.0.0)
            /Library/Frameworks/Python.framework/Versions/2.5/Python (compatibility version 2.5.0, current version 2.5.0)
            /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
            /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.3.3)
    
  35. $ sudo spctl --master-disable
    
  36. Can replace unix find:

    $ mdfind -onlyin ~/Documents Leopard
    
  37. $ spctl --assess --verbose=4 /Applications/Notes.app
    /Applications/Notes.app: accepted
    source=Apple System
    
  38. defaults write com.apple.TextEdit NSShowAppCentricOpenPanelInsteadOfUntitledFile -bool false
    
  39. update the database

    $ sudo /usr/libexec/locate.updatedb
    

    use the database

    $ locate my_report
    
  40. slow down traffic with apple.com

    sudo ipfw pipe 1 config bw 40kbit/s
    sudo ipfw add pipe 1 src-ip 17.149.160.49
    sudo ipfw add pipe 1 dst-ip 17.149.160.49
    

    delete rules

    sudo ipfw flush
    

    Thanks Cédric for this great tip!

    See also: Traffic Shaping in Mac OS X

  41. $ sudo xcode-select /Library/Developer/CommandLineTools/
    
    $ xcode-select --print-path
    /Library/Developer/CommandLineTools