Batch convert Safari webarchive files to PDF #

via Terminal & textutil/cupsfilter

textutil -convert html *.webarchive && for i in *.html ; do cupsfilter "$i" > "$i".pdf ; done

via Automator & Download URLs as PDFs action

via AppleScript & Safari

-- Keep code for Safari separate from the code for System Events.
tell application "Safari"
   activate
   -- Tell Safari, as the known frontmost application, to display the 'choose folder' dialog.
   set SaveFolderPath to POSIX path of (choose folder with prompt "Select Folder to Save PDF Files")
   tell window 1
       set current tab to tab 1
       set ctabs to (count tabs)
   end tell
end tell

repeat with i from 1 to ctabs
   tell application "System Events"
       tell process "Safari"
           click menu item "Show Reader" of menu "View" of menu bar 1
           click menu item "Export as PDF…" of menu "File" of menu bar 1
           repeat until exists sheet 1 of window 1
               delay 1
           end repeat
           -- The sheet opens alread primed with a file name based on the tab name.
           if (i is 1) then
               -- Make sure the file gets saved to the folder chosen above.
               -- This is only necessary first time round the repeat, as the folder becomes the default next time.
               keystroke "g" using {command down, shift down}
               repeat until exists sheet 1 of sheet 1 of window 1
                   delay 1
               end repeat
               log "passed delay"
               tell sheet 1 of sheet 1 of window 1
                   set value of combo box 1 to SaveFolderPath -- NB. the folder path here, not the file name.
                   click button "Go"
                   
               end tell
           end if
           click button "Save" of sheet 1 of window 1
           click menu item "Close tab" of menu "File" of menu bar 1
       end tell
       
       tell application "Safari" to display dialog "Close after 1 second..." giving up after 1
   end tell
end repeat

via Paparazzi!

via EagleFiler & Web archive to PDF script

See also

/mac | Oct 11, 2020

Back up iOS apps to a PC or Mac #

A little history

Before iOS 9, iOS apps could be backed up to Macs and PCs via iTunes1:

Adding insult to injury, iTunes 12.7 removed the App Store, closing the door on downloading/backing up iOS apps from there:

Why bother?

You may want to back up an app before it disappears from the App Store or preserve an older, better version, e.g.,

Download iOS apps from Apple to a PC or Mac

iOS apps can still be downloaded via iTunes 12.6.3 (does not run on Mojave or higher), Apple Configurator 2 (with some caveats), or iMazing:

Copy apps from an iOS device to a PC or Mac

To back up all apps on your iOS device to apps/ in the current directory of your Mac, jailbreak your device, install usbmuxd, start iproxy, then:

$ scp -P 4444 -r root@localhost:/var/containers/Bundle/Application apps/

Convert iOS .app to .ipa

$ mkdir Payload
$ cp -R appname.app Payload/
$ zip -r appname.ipa Payload/

Install .ipa from a PC or Mac to an iOS device

Footnotes

  1. The backups were located in:

  2. Apple Configurator 2 also allows installing an iOS .app via Actions → Add → Apps... → Choose from my Mac...

See also

/mac | Sep 28, 2020

iOS Safari has a weight problem #

The auspiciously-titled Safari hogging up storage on your iPhone? Here's the fix! exhorts users to tap Settings → Safari → Advanced → Website Data → Remove All Website Data (mgmiller68 wonders in the comments how this differs from Settings → Safari → Clear History and Website Data); alas, neither method proved efficacious.

Others advise waiting days for the issue to clear; sadly, not even weeks availed.

Still others recommend a draconian backup, wipe, and restore approach.

Macworld's Documents & Data: A mysterious black hole of data storage in iOS concludes unpropitiously:

"At a minimum, I’d like to know what’s taking up all that space. Those 7GB of Documents & Data probably include something that’s gotten stuck, that can’t be deleted, such as an old iOS update perhaps. But it would be helpful if every app had to offer a feature to delete its caches, or if there were a global Clear Caches feature in iOS."

Found the offending files by jailbreaking and SSHing into the device then:

# cd /var/mobile/Containers/Data/Application/

# find . -name Safari
./{GUID}/Library/Safari

# cd {GUID}

# du -h
...
4.0G    ./tmp/Download-tCA2Caas
...
3.7G    ./tmp/Download-UT0Nlzkj
...
7.8G    ./tmp
8.0G    .

Emptying the tmp directory did the trick:

Before After
iPhone 28.5 of 32GB used iPhone 19.9 of 32GB used
Safari 8.5 GB Safari no longer showing

H/T jareehD for the filepath hint.

/misc | Sep 26, 2020

Deleting a subdirectory in the path of a URL via sed or perl #

Delete the divers subdirs which appear between "/blog/" and the filenames in this example:

$ cat index.rss
...
    <link>https://tinyapps.org/blog</link>
...
      <link>https://tinyapps.org/blog/misc/202009080700_usbimager.html</link>
...
      <link>https://tinyapps.org/blog/mac/202009070700_2011_mac_mini_snow_leopard.html</link>
...
      <link>https://tinyapps.org/blog/windows/202008200700_vostro_2420_lines.html</link>
...

with GNU sed:

$ sed -i -E 's (tinyapps.org/blog)/[a-z]+ \1 ' index.rss

or Perl:

$ perl -pi -e 's|(tinyapps.org/blog)/[a-z]+|\1|' index.rss

/nix | Sep 13, 2020

macOS: Block (most) keyboard input for cleaning, etc. #

Keyboard Cleaner 1.2 [137k] Disables keyboard input (well, most: Command+Shift+3 worked and Command+Tab switched focus to the next app (though the black screen obscured that fact)) until Command+Q is pressed. 📺

UPDATE: Michael Leddy kindly wrote in to suggest KeyboardCleanTool, which does a more thorough job of blocking keyboard input (including the Function keys, which Keyboard Cleaner does not). He has written more about the tool here.

/mac | Sep 13, 2020

Rare addition to file and macOS pages #

H/T HN

/misc | Sep 08, 2020

Install Snow Leopard on a 2011 Mac Mini #

(See also Downgrading from Lion to Snow Leopard on the latest Mac hardware)

  1. Install Snow Leopard via a 10.6.7 universal installer disc (a MacBook Pro or iMac 10.6.7 "Mac OS X Install DVD" can be made universal via Joel Bruner's bash script 💾).

  2. Install all updates*

  3. From a Lion install, copy

    /System/Library/Extensions/:
    AppleIntelHDGraphics.kext
    AppleIntelSNBGraphicsFB.kext

    and

    /System/Library/Extensions/IOPlatformPluginFamily.kext/Contents/Plugins/ACPI_SMC_PlatformPlugin.kext/Contents/Resources/:
    Macmini5_1.plist
    Macmini5_2.plist
    Macmini5_3.plist

    into the same locations on the Mac Mini.

  4. Run this script as root and reboot:

    cd /System/Library/Extensions/IOPlatformPluginFamily.kext/Contents/PlugIns/ACPI_SMC_PlatformPlugin.kext/Contents/Resources
    chown root:wheel Macmini5*
    chmod 644 Macmini5*
    cd /System/Library/Extensions
    chown -R root:wheel AppleIntelHDGraphics.kext
    chown -R root:wheel AppleIntelSNBGraphicsFB.kext
    chmod -R 755 AppleIntelHDGraphics.kext
    chmod -R 755 AppleIntelSNBGraphicsFB.kext
    kextcache -system-prelinked-kernel
    kextcache -system-caches
    exit
    echo 'Finished'

Footnote

* Deuced civil of Apple to keep the old servers humming along:

Sources

Related

/mac | Sep 07, 2020

Fiction books featuring a stoic protagonist #

who, as Arnold relates, "with equanimity surveys
Lustre of goodness, strife of passion, sloth
Of ignorance, not angry if they are,
Not wishful when they are not ... who sits
A sojourner and stranger in their midst
Unruffled, standing off, saying—serene—
When troubles break, 'These be the Qualities!'"

Title Character Author
Foundation Salvor Hardin Asimov
A Gentleman in Moscow Alexander Rostov Towles
Knight Without Armour Ainsely Fothergill Hilton
Leave it to Psmith Ronald Psmith Wodehouse
A Man in Full Conrad Hensley Wolfe

See also Descriptive book titles that obviate the need to read the book.

/misc | Aug 26, 2020

Dell Vostro 2420: pink and grey lines on screen after Windows 10 upgrade #

Four years ago, RockNir posted Weird Lines and color changes suddenly appear on screen. What's happening? to the Dell laptops general forum. It read in part, "[My] Dell Vostro 2420 has been behaving weirdly at times ... pink and grey lines suddenly appear and cover the entire area of the screen, generally when I am not plugged in ... This problem started after I upgraded to Windows 10..." and included this image:

Dell Vostro 2420: pink and grey lines on screen after Windows 10 upgrade

Sadly, the forum has since gone read only, so I am posting the solution here in hopes that RockNir (and anyone else facing this issue) finds it:

  1. Control Panel > Intel Graphics and Media
  2. Advanced Mode > Power > Power Source: On battery
  3. Under "Power Conservation Features", uncheck "Display Refresh Rate Switching" and "Display Power Saving Technology"

Verified both the problem and the solution on a Dell Vostro 2420 running Windows 10.

See also:

/windows | Aug 20, 2020

Cloning a Bitlocker-encrypted disk #

Some options for cloning a Bitlocker-enabled system drive:

Footnotes

  1. TBWinPE does not include manage-bde.exe.

  2. Select "Read from Volume", which "allows things like the ability to see BitLocker volumes unencrypted" (if unselected, a sector-by-sector clone will be made, even if the Bitlocker partition was unlocked). Other options worth considering: Scale to Fit, Scale to Target, Align to Target, and Remove Gaps on Copy. Could not find an option or set of options that correctly resized a larger target; fixed with Paragon's Partition Manager Community Edition.

  3. A number of useful tools lie hidden beneath the surface: Explore > Quick Access Toolbar arrow > Save As > click the now-showing Save As button > This PC > X:

    right click desired tool > Open. You can also reveal the Menu Bar in the main menu via F10.

  4. If you missed the GUI prompt to unlock, make it reappear by clicking the SmartStart Wizard icon in the upper right hand corner (alternatively, run manage-bde -unlock inside cmd.exe).

Notes

/windows | Aug 19, 2020


Subscribe or visit the archives.