30 мая 2018 г.

Apple Notes -> Evernote

Так случилось, что появился у меня Evernote Premium, ввиду чего захотелось перенести накопленные за пару лет работы заметки из Apple Notes туда. Нашелся замечательный applescript-файл, позволяющий сделать это быстро и вкусно. Спасибо перечисленным в заголовке авторам и вообще всем участникам треда.
(*

    ====================================================

      [EN] Import Apple Notes into Evernote

    ====================================================

    

    DATE:    2013-10-24

    AUTHOR: d.b.walker

    

    REVISED BY:  JMichaelTX on 2016-03-28 to make BUG fix.

    

    REF:

      • Importing from Apple Mail.app's Notes - Mac Help - Evernote User Forum       

      • https://discussion.evernote.com/topic/4046-importing-from-apple-mailapps-notes/?do=findComment&comment=236445

    

    Posted 24 Oct 2013

    Modified this script to work with Mavericks Notes, which is no longer in the mail app.

    Added the original creation and modification dates

    Added multiple tags - replace with your own

    Did not add the long note name fix (I needed to preserve my note names)

    ====================================================

    

    FURTHER DEVELOPED BY: Nigel Garvey 2017-03-21/22/23, based on information in the Evernote fora, to allow a choice of Notes source folder(s) and to handle attachments.

    

    CAVEATS:

        1. I don't have Evernote and can't test that part of the code.

        2. (No longer relevant. Thanks to Yvan Koenig for the fix.)

        3. Any attachments are simply "appended" to the Evernote notes in the order they happen to be returned by Notes.

        4. The effect in Evernote of Notes's references to the attachments in the note HTML is unknown.

*)



main()



on main()
-- User choice of one or more Notes folders (by name).
tell application "Notes"
activate
set folderNames to name of folders
set chosenFolderNames to (choose from list folderNames with multiple selections allowed)
if (chosenFolderNames is false) then error number -128 -- Cancel button.
end tell
-- Preset HFS and POSIX versions of a path to a folder on the desktop for storing any attachments.
set tempFolderPath to (path to desktop as text) & "Attachments from Notes:"
set tempFolderPosix to quoted form of POSIX path of tempFolderPath
-- Repeat with each chosen folder name:
repeat with i from 1 to (count chosenFolderNames)
-- Get all the notes in the folder with this name.
set thisFolderName to item i of chosenFolderNames
tell application "Notes" to set theNotes to notes of folder thisFolderName
set quotedFolderName to quoted form of thisFolderName
-- Repeat with each note in the folder:
repeat with j from 1 to (count theNotes)
set thisNote to item j of theNotes
tell application "Notes"
-- Get the relevant note data.
set myTitle to the name of thisNote
set myText to the body of thisNote
set myCreateDate to the creation date of thisNote
set myModDate to the modification date of thisNote
set myAttachments to the attachments of thisNote
-- Any attachments will need to be extracted to the folder on the desktop and attached to the Evernote note from there.
-- To preserve the attachment names and avoid confusion in the case of duplicated names, each attachment is saved to a separate subfolder in a hierarchy based on the folder/note/attachment structure. 
set attachmentFiles to {}
set attachmentCount to (count myAttachments)
if (attachmentCount > 0) then
-- If this note has any attachments, create or add to the hierarchy of the folder on the desktop to accommodate each one.
do shell script ("mkdir -p " & tempFolderPosix & quotedFolderName & "/'Note '" & j & "/'Attachment '{1.." & attachmentCount & "}")
-- Repeat with each attachment:
repeat with k from 1 to attachmentCount
set thisAttachment to item k of myAttachments
-- Put together a specifier for a file in which to save this attachment.
set thisFile to (tempFolderPath & thisFolderName & ":Note " & j & ":Attachment " & k & ":" & thisAttachment's name) as «class furl»
-- Create the file before trying to save to it. (Suggested by Yvan Koenig.)
close access (open for access thisFile)
-- Save the attachment to it.
save thisAttachment in thisFile -- Now it works! Thanks, Yvan!
-- Store the file specifier for the retrieval of the attachment below.
set end of attachmentFiles to thisFile
end repeat
end if
end tell
tell application "Evernote"
set myNote to create note with text myTitle title myTitle notebook "Imported From Notes" tags ["imported_from_notes"]
set the HTML content of myNote to myText
repeat with thisFile in attachmentFiles
tell myNote to append attachment thisFile
end repeat
set the creation date of myNote to myCreateDate
set the modification date of myNote to myModDate
end tell
end repeat
end repeat
end main

27 апр. 2018 г.

SSH Agent auto add keys

Когда количество ssh-ключей начинает расти, жонглировать ими становится печально. Случайно на реддите нашелся замечательный лайфхак, как удобно работать с множеством ключей, не заморачиваясь ручным добавлением их в ssh-agent:
Host *
UseKeychain yes
AddKeysToAgent yes
IdentityFile ~/.ssh/id_rsa
IdentityFile ~/.ssh/id_25519
Один раз перечисляем все нужные ключи в начале ~/.ssh/config, и все. 

14 февр. 2018 г.

MacOS X High Sierra soft from unknown sources

В свежей макоси, которая High Sierra, из настроек безопасности (Системные настройки - Защита и безопасность - Основные - Разрешить использование программ, загруженных из:) убрали возможность установки ПО из неизвестных источников. Вернуть можно консольной командочкой: 
sudo spctl --master-disable

7 февр. 2018 г.

QEMU\KVM: virtio-blk vs virtio-scsi

Искал не так давно, а написали вот совсем недавно: отличная статейка по сабжу. Последний абзац процитирую:
Looking at the advantages of virtio-scsi, I believe it’s the correct choice as a default VM disk interface in oVirt. For optimized VMs, there is always the choice of manually switching to virtio-blk (or IDE, if you’re optimizing for slowness… or compatibility). For now, adding IO thread may cause more harm than good, therefore we’ll leave that for the future.