-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathios-sync.html
259 lines (212 loc) · 8.52 KB
/
ios-sync.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>iOS Sync</title>
<link rel="icon" href="crow.ico?" type="image/x-icon">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta property="og:type" content="article"/>
<meta property="og:title" content="iOS Sync"/>
<link rel="feed" type="application/rss+xml" title="Mineral Existence RSS Feed" href="https://mineralexistence.com/feed.xml">
<!-- the below sections enables syntax highlighting when js is enabled, and reverts to the default when it isn't -->
<noscript>
<style>
pre {
font-size:calc(0.5rem + 0.25vw);
line-height:2.3ex;
overflow-x:auto;
padding:2%;
color:var(--bg);
background-color:var(--text);
}
</style>
</noscript>
<script src="./assets/prism.js" defer></script>
<script>
var link = document.createElement("link");
link.rel="stylesheet";
link.href="./assets/prism.css";
link.type="text/css";
document.getElementsByTagName("head")[0].appendChild(link);
</script>
<style>
/* @import url('reset.css'); */
*, *::before, *::after {box-sizing: border-box;}
* {margin: 0;}
body {line-height: 1.5;-webkit-font-smoothing: antialiased;}
img, picture, video, canvas, svg {display: block;max-width: 100%;}
input, button, textarea, select {font: inherit;}
p, h1, h2, h3, h4, h5, h6 {overflow-wrap: break-word;}
#root, #__next {isolation: isolate;}
:root {
/* --text:#3A3738; */
/* --text:#472d30; */
--text:#654735;
/* --bg:#FBF0F0; */
/* --bg:#ffe1a8; */
--bg:#fbf1c7;
--bg-hl:#fcd297;
/* --hl:#80dec5; */
/* --hl:#c9cba3; */
--hl:#45707a;
--hl-orange:#c35e0a;
/* https://utopia.fyi/type/calculator?c=320,18,1.2,1240,20,1.333,3,0,&s=0.75|0.5|0.25,1.5|2|3|4|6,s-l&g=s,l,xl,12 */
--step-0: clamp(1.13rem, calc(1.08rem + 0.22vw), 1.25rem);
--step-1: clamp(1.35rem, calc(1.24rem + 0.55vw), 1.67rem);
--step-2: clamp(1.62rem, calc(1.41rem + 1.05vw), 2.22rem);
--step-3: clamp(1.94rem, calc(1.59rem + 1.77vw), 2.96rem);
/* @link https://utopia.fyi/space/calculator?c=320,18,1.2,1240,32,1.25,5,2,&s=,1.5|2,s-l&g=s,l,xl,12 */
--space-s: clamp(1.13rem, calc(0.82rem + 1.52vw), 2.00rem);
--space-m: clamp(1.69rem, calc(1.23rem + 2.28vw), 3.00rem);
--space-l: clamp(2.25rem, calc(1.64rem + 3.04vw), 4.00rem);
/* One-up pairs */
--space-s-m: clamp(1.13rem, calc(0.47rem + 3.26vw), 3.00rem);
--space-m-l: clamp(1.69rem, calc(0.88rem + 4.02vw), 4.00rem);
/* Custom pairs */
--space-s-l: clamp(1.13rem, calc(0.13rem + 5.00vw), 4.00rem);
}
body {
font-size:var(--step-0);
font-family:sans-serif;
max-width:72ch;
margin: var(--space-m-l);
/* padding: 0 1rem; */
line-height:1.6;
color:var(--text);
background-color:var(--bg);
}
/* * {border: 1px solid black;} */
main > *+* {margin-top: var(--space-s);}
h1,
h2,
h3,
h4,
h5,
h6 {
font-family: serif;
}
h1 { font-size: var(--step-3); }
h2 { font-size: var(--step-2); }
h3 { font-size: var(--step-1); }
/* header>h1 {display:inline-block;padding-right:.3em;} */
header {margin: 0 0 var(--space-l) 0;clear:both;}
mark {background-color:var(--hl);color:var(--bg);}
hr {height:1px;border-width:0;color:var(--text);background-color:var(--text)}
a {color:var(--hl);}
a:visited {color:var(--hl-orange);}
pre {
font-size:calc(var(--step-0) + 0.15rem);
line-height:2.3ex;
overflow-x:auto;
padding:2%;
color:var(--bg);
background-color:var(--text);
}
code {
font-family: monospace;
color:var(--bg);
background-color:var(--text);
font-size:calc(var(--step-0) + 0.15rem);
padding-left: 0.2em;
padding-right: 0.2em;
}
button {
border-radius: 8px;
border: 1px solid var(--text);
background: none;
padding: 0px 10px;
font-weight: bold;
font-family: sans;
color: var(--text);
font-size: 20px;
}
button:hover {color: var(--bg);background: var(--text);}
dd {margin-left:var(--space-s);}
details {padding-bottom:0ex;}
fieldset {border:1px solid;}
::selection {color: var(--bg);background-color: var(--text);}
footer {margin:var(--space-l) 0 0 0;clear:both}
footer>* {display:inline-block;}
footer img {margin:0 0 -10px 0;width:30px;}
/* .half {width: 50%; height: auto;} */
/* .left {margin-top: 0em;float: left;margin-right: 2em;clear: both;} */
/* .block {margin-top: 1em;margin-left: 0px;clear: both;} */
.third {width: 31%; height: auto;}
.container {padding: var(--space-s); border: solid 1px var(--text);border-radius: 5px;}
.row {display: flex;}
.column {flex: 50%;}
.listing > span {float: right;}
.box {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(256px, 1fr));
gap: 0.5em;
grid-auto-flow: dense;
}
ul[role=list] {
list-style: none;
margin: 0;
padding: 0;
}
.nav-main ul {
flex-flow: wrap;
justify-content: flex-start;
align-items: center;
gap: 5px 20px;
display: flex
}
.nav--main a {
text-decoration: none
}
.inline-img {
height: 33px;
display: inline-block;
border: 1px solid var(--text);
position: relative;
left: 0.25em;
top: 0.25ex;
}
*:not(footer)>a[href*=':']::before{content:"↗"}
</style>
</head>
<body>
<header>
<nav class="nav-main" role="navigation">
<ul role="list">
<li><h1><a href="home.html">Home</a></h1> </li>
<li><h1><a href="now.html">now</a></h1></li>
<li><h1><a href="wiki.html">wiki</a></h1></li>
<li><h1><a href="about.html">about</a></h1></li>
</ul>
</nav>
</header>
<main>
<h2>iOS Sync</h2>
<p>After way too long of sharing images from my iphone to my linux laptop with email, I finally hacked something together in shortcuts which can get a photo to my laptop much faster!</p>
<p>I made three versions, each one syncs different sizes</p>
<p>links: <a href="https://www.icloud.com/shortcuts/18c52dd5e2844ebb9d8f3a366988c722">sync1024</a> <a href="https://www.icloud.com/shortcuts/bce3987a2d1f453f9c3f83286a0b43b9">sync512</a> <a href="https://www.icloud.com/shortcuts/e811f91a32d84fa8b0f155d6b2be9d94">sync256</a></p>
<h3>Explanation</h3>
<p>Long story short the Shortcuts app on ios is totally borked, but we can do this:</p>
<ol>
<li>encode image as base64 string</li>
<li>ssh into server</li>
<li>echo string into file</li>
<li>decode file as image</li>
<li>pull file onto laptop with rsync alias</li>
</ol>
<p>Unfortunately, this least complicated example is hindered by the fact that if we try and send a full image as base64 text, we get an error as a result of the text being way too long and the process fails. To get around this I initially just resized the image down to a width of 256. This works very well if you want a small image, and with an alias (<code>pic="rsync -vazh benh@[$MX_IP]:/home/benh/pic.jpg ./ && feh ./pic.jpg"</code>) on the laptop end it's probably the fastest way to send an image using the shortcuts app. The 256 version of this shortcut is linked above, because neither of the other two come close to how fast this version is, and I still have a few usecases for it.</p>
<p>To solve the problem of syncing much larger images using this method, things get slightly more complicated.</p>
<p>For larger images the 1024 shortcut resizes the image to 1024 (this is sorta arbitrary) and iteratively crops the image in 10 pixel tall bars that span the width of the image. By moving these crops down the height of the image and sending each cropped image to the server separately, we can send all of the image data without exceding the character limit. Then we just tell the server to combine the images with an ImageMagick command, and we're done! It does take much longer than the 256 version because loops in the shortcuts app are <em>crazy</em> slow, but might be worth it if you need a larger image.</p>
<p>The third version, sync512, uses a combination of the two previous strategies. It's hardcoded to crop a 512-width image into 8 horizontal subsections, which means you don't get the (seemingly arbitrary?) slowdown of a loop. The smaller resolution is just a result of it being an absolute pain to write shortcuts, and 8 crops (each of which require 4 commands) was the limit I was willing to make.</p>
<p>If you actually end up using this - first of all, dear god why? - let me know! If you have problems, just send me a message and I'll be happy to help :></p>
<p><b>Incoming:</b> <a href=".html"></a> </p>
</main>
<footer>
<img loading="lazy" style="width:88px;height:31px;margin-left:0.5ex;" title="my homemade site banner!" alt="site banner" src="images/icon.gif"/>
<a href="mailto:[email protected]">email</a>
<a href="https://merveilles.town/@flbr">fedi</a>
<a href="https://webring.xxiivv.com/#icons">webring</a>
<span style="float: right;"><em>Last updated: 041923</em></span>
</footer>
</body>
</html>