Useful when you have local Notes in iPhone/iPad & need to put it into iCloud or Gmail.
Requirements: SQLite db dump from /Root/User/Library/Notes/notes.sqlite
require 'rubygems' | |
require 'sqlite3' | |
require 'pony' | |
db = SQLite3::Database.new 'notes.db' | |
db.execute('select * from ZNOTEBODY order by Z_PK asc') do |row| | |
content = row[4] | |
title = content.sub(/\<(div|span|br)[^>]*>.*/, '') | |
title = content.sub(/\<\/(div)\>.*/, '').gsub(/<[^>]*>/ui,'') if title.empty? | |
Pony.mail(to: 'user@mail', | |
from: 'user@mail', | |
subject: title, | |
html_body: content, | |
via: :smtp, | |
via_options: { | |
address: 'smtp.gmail.com', | |
port: '587', | |
enable_starttls_auto: true, | |
user_name: 'usermail', | |
password: 'password', | |
authentication: :plain, | |
domain: 'localhost.localdomain' | |
}, | |
charset: 'utf-8', | |
headers: { 'X-Uniform-Type-Identifier' => 'com.apple.mail-note', | |
'X-Universally-Unique-Identifier' => row[0], | |
'Content-Transfer-Encoding' => 'quoted-printable', | |
'Mime-Version' => '1.0 (Mac OS X Notes 2.0 \(284\))' } ) | |
end |
# A sample Gemfile | |
source "https://rubygems.org" | |
gem 'sqlite3' | |
gem 'pony' |
/* | |
Target Server Type : SQLite | |
Target Server Version : 3008001 | |
File Encoding : utf-8 | |
Date: 01/23/2015 22:45:14 PM | |
*/ | |
PRAGMA foreign_keys = false; | |
-- ---------------------------- | |
-- Table structure for ZNOTEBODY | |
-- ---------------------------- | |
DROP TABLE IF EXISTS "ZNOTEBODY"; | |
CREATE TABLE ZNOTEBODY ( Z_PK INTEGER PRIMARY KEY, Z_ENT INTEGER, Z_OPT INTEGER, ZOWNER INTEGER, ZCONTENT VARCHAR, ZEXTERNALCONTENTREF VARCHAR, ZEXTERNALREPRESENTATION BLOB ); | |
-- ---------------------------- | |
-- Records of ZNOTEBODY | |
-- ---------------------------- | |
BEGIN; | |
INSERT INTO "ZNOTEBODY" VALUES (1, 4, 1, 1, 'FOO<div>BAR</div>', null, null); | |
COMMIT; | |
-- ---------------------------- | |
-- Indexes structure for table ZNOTEBODY | |
-- ---------------------------- | |
CREATE INDEX ZNOTEBODY_ZOWNER_INDEX ON ZNOTEBODY (ZOWNER); | |
PRAGMA foreign_keys = true; |