-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfeed.xml
498 lines (338 loc) · 48.8 KB
/
feed.xml
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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Unleash Your Server</title>
<description>Unleash Your Server LTD is the professional playground of Juan Matthys Uys.
</description>
<link>http://essays.uys.io/</link>
<atom:link href="http://essays.uys.io/feed.xml" rel="self" type="application/rss+xml"/>
<pubDate>Mon, 04 Apr 2016 15:04:24 +0000</pubDate>
<lastBuildDate>Mon, 04 Apr 2016 15:04:24 +0000</lastBuildDate>
<generator>Jekyll v3.0.1</generator>
<item>
<title>Using Clojure with Unity3D inside Docker</title>
<description><p>I braced myself for a thorough hack to get Clojure working in Unity3D, and found that it’s <a href="https://github.com/arcadia-unity/Arcadia">already been done</a>.</p>
<p>So, I instead spent my time implementing a subset of Flappy Bird.</p>
<p><img src="/assets/flappy.gif" alt="flappy bird" /></p>
<p>When using Unity3D, I can imagine most of the work going into asset creation, story/level progression and play testing. This is the only real code I wrote:</p>
<h2 id="a-bird">A bird</h2>
<figure class="highlight"><pre><code class="language-clojure" data-lang="clojure"><span class="p">(</span><span class="nf">defcomponent</span> <span class="nv">Bird</span> <span class="p">[</span><span class="o">^</span><span class="nv">Vector2</span> <span class="nv">force</span><span class="p">]</span>
<span class="p">(</span><span class="nf">Start</span> <span class="p">[</span><span class="nv">this</span><span class="p">]</span>
<span class="p">(</span><span class="nf">reset!</span> <span class="nv">score</span> <span class="mi">0</span><span class="p">))</span>
<span class="p">(</span><span class="nf">Update</span> <span class="p">[</span><span class="nv">this</span><span class="p">]</span>
<span class="p">(</span><span class="nf">swap!</span> <span class="nv">score</span> <span class="p">(</span><span class="k">fn </span><span class="p">[</span><span class="nv">n</span><span class="p">]</span> <span class="p">(</span><span class="nb">+ </span><span class="nv">n</span> <span class="nv">Time/deltaTime</span><span class="p">)))</span>
<span class="p">(</span><span class="k">if </span><span class="p">(</span><span class="nf">Input/anyKeyDown</span><span class="p">)</span>
<span class="p">(</span><span class="nb">.. </span><span class="nv">this</span> <span class="p">(</span><span class="nf">GetComponent</span> <span class="nv">Rigidbody2D</span><span class="p">)</span>
<span class="c1">;; flap yer wings, bud!</span>
<span class="p">(</span><span class="nf">AddForce</span> <span class="nv">force</span> <span class="nv">ForceMode2D/Impulse</span><span class="p">))))</span>
<span class="p">(</span><span class="nf">OnCollisionEnter2D</span> <span class="p">[</span><span class="nv">this</span> <span class="nv">collision</span><span class="p">]</span>
<span class="p">(</span><span class="k">if </span><span class="p">(</span><span class="nb">= </span><span class="p">(</span><span class="nb">.. </span><span class="nv">collision</span> <span class="nv">gameObject</span> <span class="nv">tag</span><span class="p">)</span> <span class="s">&quot;Boundary&quot;</span><span class="p">)</span>
<span class="p">(</span><span class="nf">game-over</span><span class="p">))))</span></code></pre></figure>
<h2 id="move-some-pipes">Move some pipes</h2>
<figure class="highlight"><pre><code class="language-clojure" data-lang="clojure"><span class="p">(</span><span class="nf">defcomponent</span> <span class="nv">MovingPipe</span> <span class="p">[</span><span class="o">^</span><span class="nb">float </span><span class="nv">speed</span><span class="p">]</span>
<span class="p">(</span><span class="nf">Update</span> <span class="p">[</span><span class="nv">this</span><span class="p">]</span> <span class="p">(</span><span class="nf">pipe-update</span> <span class="nv">this</span><span class="p">)))</span>
<span class="p">(</span><span class="kd">defn </span><span class="nv">+-</span> <span class="p">[]</span>
<span class="p">(</span><span class="k">if </span><span class="p">(</span><span class="nb">= </span><span class="mi">0</span> <span class="p">(</span><span class="nb">rand-int </span><span class="mi">2</span><span class="p">))</span>
<span class="nv">+</span>
<span class="nv">-</span><span class="p">))</span>
<span class="p">(</span><span class="kd">defn </span><span class="nv">pipe-update</span> <span class="p">[</span><span class="o">^</span><span class="nv">MovingPipe</span> <span class="nv">this</span><span class="p">]</span>
<span class="p">(</span><span class="nb">.. </span><span class="nv">this</span> <span class="nv">transform</span> <span class="p">(</span><span class="nf">Translate</span> <span class="p">(</span><span class="nb">* </span><span class="p">(</span><span class="nf">.speed</span> <span class="nv">this</span><span class="p">)</span> <span class="nv">Time/deltaTime</span><span class="p">)</span>
<span class="mi">0</span>
<span class="mi">0</span><span class="p">))</span>
<span class="p">(</span><span class="k">if </span><span class="p">(</span><span class="nb">&lt; </span><span class="p">(</span><span class="nb">.. </span><span class="nv">this</span> <span class="nv">transform</span> <span class="nv">position</span> <span class="nv">x</span><span class="p">)</span>
<span class="mi">-1</span><span class="p">)</span>
<span class="p">(</span><span class="nf">set!</span> <span class="p">(</span><span class="nb">.. </span><span class="nv">this</span> <span class="nv">transform</span> <span class="nv">position</span><span class="p">)</span>
<span class="p">(</span><span class="nf">Vector3.</span> <span class="mi">1</span>
<span class="p">((</span><span class="nf">+-</span><span class="p">)</span> <span class="c1">; fluctuating pipe heights</span>
<span class="p">(</span><span class="nb">.. </span><span class="nv">this</span> <span class="nv">transform</span> <span class="nv">position</span> <span class="nv">y</span><span class="p">)</span>
<span class="p">(</span><span class="nb">* </span><span class="mf">0.3</span> <span class="p">(</span><span class="nf">rand</span><span class="p">)))</span>
<span class="mi">0</span><span class="p">))))</span></code></pre></figure>
<p>Oh, and I did mention that I’m doing all of this <a href="https://github.com/opyate/unity3d">inside Docker</a>.</p>
</description>
<pubDate>Tue, 29 Mar 2016 10:50:20 +0000</pubDate>
<link>http://essays.uys.io/2016/03/29/using-clojure-with-unity3d-inside-docker.html</link>
<guid isPermaLink="true">http://essays.uys.io/2016/03/29/using-clojure-with-unity3d-inside-docker.html</guid>
<category>unity3d</category>
<category>clojure</category>
<category>docker</category>
</item>
<item>
<title>Docker this, Docker that.</title>
<description><p>Ever since <a href="https://fir.sh/">Ben Firshman</a> introduced us to his <a href="http://www.fig.sh/">side project</a> back in 2013 at the Land Registry, I’ve been hooked on Docker.</p>
<p>Also, since treating myself to a new HDD for Xmas and installing Arch Linux, I felt the need to keep concerns separate, almost like <a href="http://appimage.org/">AppImage</a> promises to do. Docker to the rescue, naturally.</p>
<p>Here follows a non-exhaustive list of cool apps I’ve Dockerised or helped Dockerise.</p>
<h1 id="unity3d">Unity3D</h1>
<p><a href="https://github.com/opyate/unity3d">opyate/unity3d</a></p>
<p>Thanks to <a href="https://github.com/tommyoshaw">Thomas Shaw</a> for the head start. More fixes will come once I start Android/WebGL integration, but otherwise I’m really excited to use it more. In fact, I told <a href="https://github.com/rosejn">someone</a> for the first time today what my game idea is all about, and he nodded appreciatively. Note to self: enough <a href="http://tynansylvester.com/book/">reading</a>, and more coding!</p>
<h1 id="android-studio">Android Studio</h1>
<p><a href="https://github.com/tddpirate/androiddocker">tddpirate/androiddocker</a></p>
<p>Thanks to <a href="https://github.com/tddpirate">Omer Zak</a> for the head start. I discovered this repo 2 days after Omer made it public, and basically an email to-and-fro ensued, in which I suggested this and that. Apart from wiring the IoT, I think being able to program the one thing you have with you all day is quite valuable.</p>
<h1 id="github-leaderboard">Github Leaderboard</h1>
<p><a href="https://github.com/opyate/github-leaderboard-docker">opyate/github-leaderboard-docker</a></p>
<p>Thanks to <a href="https://github.com/eugef">Eugene Fidelin</a> for <a href="https://github.com/eugef/github-leaderboard">Github Leaderboard</a>! It’s Node/NPM, so I just had to contain(erise) this. (Be fhssre gur jengu bs n gubhfnaq yvggyr onqyl-ervairagrq jurryf yvggrevat lbhe uneq qevir…)</p>
<p>Turns out I had a good week.</p>
<p><img src="/assets/gl.png" alt="Github Leaderboard" /></p>
</description>
<pubDate>Thu, 10 Mar 2016 21:47:16 +0000</pubDate>
<link>http://essays.uys.io/2016/03/10/docker-this-docker-that.html</link>
<guid isPermaLink="true">http://essays.uys.io/2016/03/10/docker-this-docker-that.html</guid>
<category>docker</category>
<category>unity3d</category>
<category>android</category>
<category>github</category>
</item>
<item>
<title>Ajax: when was your first time? &#8482;</title>
<description><p>I reminisced with some friends about technology firsts the other day, like our first C or Perl-based CGI scripts, writing Basic on an Acorn, or this little gem from when I worked at <a href="http://beatthatquote.com/">beatthatquote.com</a> back in the day.</p>
<p><em>So, I’ll just email myself this Ajax magic so I can use it in my other projects…</em></p>
<p><img src="/assets/ajax.png" alt="Ajax magic" /></p>
</description>
<pubDate>Mon, 29 Feb 2016 19:56:24 +0000</pubDate>
<link>http://essays.uys.io/2016/02/29/ajax-when-was-your-first-time.html</link>
<guid isPermaLink="true">http://essays.uys.io/2016/02/29/ajax-when-was-your-first-time.html</guid>
<category>ajax</category>
<category>dinosaur</category>
</item>
<item>
<title>A Spacemacs layer for Pixie</title>
<description><p>A major mode for <a href="https://github.com/pixie-lang/pixie">Pixie</a> already <a href="https://github.com/johnwalker/pixie-mode">exists</a>, but I would like to use it in evil mode from <a href="https://github.com/syl20bnr/spacemacs">Spacemacs</a>. Hence, a <a href="https://github.com/UYSio/pixie-spacemacs-layer">custom layer</a>.</p>
<p>I repeat the steps I took here in a mini tutorial format.</p>
<h1 id="create-a-custom-layer-for-spacemacs">Create a custom layer for Spacemacs</h1>
<p>Start with creating the layer from within Spacemacs:</p>
<figure class="highlight"><pre><code class="language-console" data-lang="console"><span class="go">&lt;SPC&gt; : configuration-layer/create-layer &lt;RET&gt;</span></code></pre></figure>
<p>Press <code>&lt;RET&gt;</code> again to create the layer in the default directory <code>$HOME/.emacs.d/private</code>.</p>
<p>Choose a layer name, e.g. <code>pixie</code>.</p>
<p>Spacemacs then throws you into the <a href="https://github.com/syl20bnr/spacemacs/blob/696f2d461a81b2c0640ae7da113edf1374050ecd/core/templates/packages.template">packages.el</a> for your new layer.</p>
<p>Now is a good time to study <a href="https://github.com/syl20bnr/spacemacs/blob/master/doc/LAYERS.org">layers</a>, but the gist is this:</p>
<ul>
<li>hook in the modes you’re layering in <code>(setq &lt;your-layer&gt;-packages ...)</code></li>
<li>set the key combinations for your <a href="https://github.com/syl20bnr/spacemacs/blob/master/doc/DOCUMENTATION.org#evil-leader">Evil Leader</a> in the <code>(defun &lt;your-layer&gt;/init-&lt;your-layer&gt; () ...)</code> form</li>
<li>optionally define custom commands here and bind to them</li>
</ul>
<p>PS The Evil Leader in Spacemacs is <code>SPC</code> (YES! that’s where Spacemacs gets its name from).</p>
<h1 id="result">Result</h1>
<p>Here’s what I came up with for Pixie. At the moment, it offers bindings to start the REPL, and eval s-expressions (and an option to jump to the REPL after evaluation).</p>
<figure class="highlight"><pre><code class="language-elisp" data-lang="elisp"><span class="c1">;;; packages.el --- pixie Layer packages File for Spacemacs</span>
<span class="c1">;;</span>
<span class="c1">;; Copyright (c) 2012-2014 Sylvain Benner</span>
<span class="c1">;; Copyright (c) 2014-2015 Sylvain Benner &amp; Contributors</span>
<span class="c1">;;</span>
<span class="c1">;; Author: Sylvain Benner &lt;[email protected]&gt;</span>
<span class="c1">;; URL: https://github.com/syl20bnr/spacemacs</span>
<span class="c1">;;</span>
<span class="c1">;; This file is not part of GNU Emacs.</span>
<span class="c1">;;</span>
<span class="c1">;;; License: GPLv3</span>
<span class="c1">;; List of all packages to install and/or initialize. Built-in packages</span>
<span class="c1">;; which require an initialization must be listed explicitly in the list.</span>
<span class="p">(</span><span class="k">setq</span> <span class="nv">pixie-packages</span>
<span class="o">&#39;</span><span class="p">(</span>
<span class="c1">;; package names go here</span>
<span class="nv">inf-clojure</span>
<span class="nv">pixie-mode</span>
<span class="p">))</span>
<span class="c1">;; List of packages to exclude.</span>
<span class="p">(</span><span class="k">setq</span> <span class="nv">pixie-excluded-packages</span> <span class="o">&#39;</span><span class="p">())</span>
<span class="p">(</span><span class="nb">defun</span> <span class="nv">pixie/post-init-inf-clojure</span> <span class="p">()</span>
<span class="p">(</span><span class="nv">add-hook</span> <span class="ss">&#39;pixie-mode-hook</span> <span class="ss">&#39;inf-clojure-minor-mode</span><span class="p">))</span>
<span class="p">(</span><span class="nb">defun</span> <span class="nv">pixie/init-pixie-mode</span> <span class="p">()</span>
<span class="p">(</span><span class="nb">use-package</span> <span class="nv">pixie-mode</span>
<span class="ss">:defer</span> <span class="no">t</span>
<span class="ss">:config</span>
<span class="p">(</span><span class="k">progn</span>
<span class="p">(</span><span class="nb">defun</span> <span class="nv">spacemacs/pixie-eval-and-switch-to-repl</span> <span class="p">()</span>
<span class="s">&quot;Call `inf-clojure-eval-last-sexp&#39; and switch to REPL buffer in `insert state&#39;&quot;</span>
<span class="p">(</span><span class="nv">interactive</span><span class="p">)</span>
<span class="p">(</span><span class="nv">inf-clojure-eval-last-sexp</span><span class="p">)</span>
<span class="p">(</span><span class="nv">inf-clojure-switch-to-repl</span> <span class="no">t</span><span class="p">)</span>
<span class="p">(</span><span class="nv">evil-insert-state</span><span class="p">))</span>
<span class="p">(</span><span class="nv">evil-leader/set-key-for-mode</span> <span class="ss">&#39;pixie-mode</span>
<span class="c1">;; REPL</span>
<span class="s">&quot;msi&quot;</span> <span class="ss">&#39;inf-clojure-switch-to-repl</span>
<span class="s">&quot;msb&quot;</span> <span class="ss">&#39;inf-clojure-eval-last-sexp</span>
<span class="s">&quot;msB&quot;</span> <span class="ss">&#39;spacemacs/pixie-eval-and-switch-to-repl</span><span class="p">))))</span>
<span class="c1">;; For each package, define a function pixie/init-&lt;package-name&gt;</span>
<span class="c1">;;</span>
<span class="c1">;; (defun pixie/init-my-package ()</span>
<span class="c1">;; &quot;Initialize my package&quot;</span>
<span class="c1">;; )</span>
<span class="c1">;;</span>
<span class="c1">;; Often the body of an initialize function uses `use-package&#39;</span>
<span class="c1">;; For more info on `use-package&#39;, see readme:</span>
<span class="c1">;; https://github.com/jwiegley/use-package</span></code></pre></figure>
<p>It’s by no means complete, and I plan to implement basic functionality involving navigation, documentation, tests (Pixie test frameworks permitting), and evaluation of more forms.</p>
</description>
<pubDate>Sat, 17 Oct 2015 15:35:34 +0000</pubDate>
<link>http://essays.uys.io/2015/10/17/spacemacs-layer-for-pixie.html</link>
<guid isPermaLink="true">http://essays.uys.io/2015/10/17/spacemacs-layer-for-pixie.html</guid>
<category>pixie</category>
<category>spacemacs</category>
<category>emacs</category>
</item>
<item>
<title>Mandelbrot fractal with Pixie on Ubuntu</title>
<description><p>My friend <a href="http://www.arknoon.com/">Adam</a> introduced me to <a href="https://github.com/pixie-lang/pixie">Pixie</a> back in May, and I made a mental note to play with it a little bit. It was <a href="https://www.youtube.com/watch?v=1AjhFZVfB9c">Tim’s StrangeLoop talk</a>, however, which inspired me to push all my other little timewasty things to one side to check this out.</p>
<p>The Mandelbrot example in the talk was an especially tasty bit of script to play with, and I was about to type it all out from the video when I noticed that <a href="https://github.com/pixie-lang/pixie/commit/9990b235a186454e36171f84c78a0ebfb18ee5d1">Stuart Hinson had beaten me to the punch</a>.</p>
<pre><code>./pixie-vm examples/mandelbrot.pxi
</code></pre>
<p>A first run failed with this error:</p>
<figure class="highlight"><pre><code class="language-console" data-lang="console"><span class="go">/tmp/tmp.cpp: In function ‘int main(int, char**)’:</span>
<span class="go">/tmp/tmp.cpp:19:50: error: no matching function for call to ‘DumpValue(&lt;anonymous enum&gt;)’</span>
<span class="go"> PixieChecker::DumpValue(SDL_PIXELFORMAT_RGBA8888); </span>
<span class="go"> ^</span>
<span class="go">/tmp/tmp.cpp:19:50: note: candidate is:</span>
<span class="go">In file included from /tmp/tmp.cpp:2:0:</span>
<span class="go">/home/opyate/Code/pixie/pixie/PixieChecker.hpp:432:6: note: template&lt;class T&gt; void PixieChecker::DumpValue(T)</span>
<span class="go">void DumpValue(T t)</span>
<span class="go"> ^</span>
<span class="go">/home/opyate/Code/pixie/pixie/PixieChecker.hpp:432:6: note: template argument deduction/substitution failed:</span>
<span class="go">/tmp/tmp.cpp: In substitution of ‘template&lt;class T&gt; void PixieChecker::DumpValue(T) [with T = &lt;anonymous enum&gt;]’:</span>
<span class="go">/tmp/tmp.cpp:19:50: required from here</span>
<span class="go">/tmp/tmp.cpp:19:50: error: ‘&lt;anonymous enum&gt;’ is/uses anonymous type</span>
<span class="go"> PixieChecker::DumpValue(SDL_PIXELFORMAT_RGBA8888); </span>
<span class="go"> ^</span>
<span class="go">/tmp/tmp.cpp:19:50: error: trying to instantiate ‘template&lt;class T&gt; void PixieChecker::DumpValue(T)’</span>
<span class="go">Error: in internal function load-file</span>
<span class="go">in internal function load-reader</span>
<span class="go">Compiling: (with-config {:library SDL2, :cxx-flags [`sdl2-config --cflags`], :includes [SDL.h]} (defconst SDL_INIT_EVERYTHING) (defcfn SDL_Init) (defconst SDL_INIT_VIDEO) (defconst SDL_WINDOWPOS_UNDEFINED) (defcfn SDL_CreateWindow) (defcfn SDL_CreateRenderer) (defcfn SDL_CreateTexture) (defconst SDL_PIXELFORMAT_RGBA8888) (defconst SDL_TEXTUREACCESS_STREAMING) (defcfn SDL_UpdateTexture) (defcfn SDL_RenderClear) (defcfn SDL_RenderCopy) (defconst SDL_WINDOW_SHOWN) (defcfn SDL_RenderPresent) (defcfn SDL_LockSurface))</span>
<span class="go">in examples/mandelbrot.pxi at 10:1</span>
<span class="go">(with-config {:library &quot;SDL2&quot;</span>
<span class="go">^</span>
<span class="go">in pixie function with-config</span>
<span class="go">in /home/opyate/Code/pixie/pixie/ffi-infer.pxi at 212:10</span>
<span class="go"> ~(run-infer *config* @*bodies*))))</span>
<span class="go"> ^</span>
<span class="go">in pixie function run-infer</span>
<span class="go">in /home/opyate/Code/pixie/pixie/ffi-infer.pxi at 196:16</span>
<span class="go"> result (read-string (io/run-command cmd-str))</span>
<span class="go"> ^</span>
<span class="go">in internal function read-string</span>
<span class="go">RuntimeException: :pixie.stdlib/EOFWhileReadingException Unexpected EOF while reading</span>
<span class="go">&lt;/pre&gt;</span></code></pre></figure>
<p>The error</p>
<figure class="highlight"><pre><code class="language-console" data-lang="console"><span class="go">/tmp/tmp.cpp:19:50: error: no matching function for call to ‘DumpValue(&lt;anonymous enum&gt;)’</span>
<span class="go"> PixieChecker::DumpValue(SDL_PIXELFORMAT_RGBA8888); </span></code></pre></figure>
<p>can be worked around by ensuring the <a href="https://github.com/pixie-lang/pixie/blob/master/pixie/ffi-infer.pxi">FFI-infer</a> runs C++ with <code>-std=c++0x</code>, because this more recent spec lifts the limitation of unnamed types being used as template arguments.</p>
<p>Instead, I just installed <a href="http://clang.llvm.org/">Clang</a> and set up my <em>alternatives</em> to point to it:</p>
<figure class="highlight"><pre><code class="language-console" data-lang="console"><span class="go">sudo apt-get install clang</span>
<span class="go">sudo update-alternatives --set c++ /usr/bin/clang++</span></code></pre></figure>
<p>Et voilà!</p>
<p><img src="/assets/mandelbrot-pixie.png" alt="Mandelbrot with Pixie" /></p>
</description>
<pubDate>Sun, 11 Oct 2015 22:59:15 +0000</pubDate>
<link>http://essays.uys.io/2015/10/11/mandelbrot-fractal-with-pixie-on-ubuntu.html</link>
<guid isPermaLink="true">http://essays.uys.io/2015/10/11/mandelbrot-fractal-with-pixie-on-ubuntu.html</guid>
<category>pixie</category>
</item>
<item>
<title>N business days until</title>
<description><p>Communication at your business is key to levelling the knowledge landscape and eliminating surprises. One of my favourite tools for communicating KPIs and other important numbers are dashboards. Also, one of my favourite numbers when building a product is <strong>“business days until launch”</strong>.</p>
<p>Say today is mid September and your very important new website is launching next year January on the 11th. You can count on your fingers the full months in-between (October, November, December - that is 3) then roughly round September and January to make another month - that’s 4.</p>
<p>Now say <strong>“I have 4 months left until my website launches”</strong>.</p>
<p>But try this: calculate the actual business days until January 11th. Cut out weekends and public holidays.</p>
<p>Now say <strong>“I have 79 business days left until my website launches”</strong>.</p>
<p>It somehow feels like you have less time, doesn’t it?</p>
<p>This, for me, is such an important number to keep in mind, that I have created a small <a href="https://github.com/opyate/daysuntil">web app</a> for it to load up on your dashboards.</p>
<p>Here’s an <a href="http://bizdaysuntil.herokuapp.com/?year=2015&amp;month=12&amp;day=25&amp;what=Xmas&amp;size=24&amp;highlight=fefe55">example</a>:</p>
<p><img src="/assets/bizdaysuntil.png" alt="business days until Xmas" /></p>
</description>
<pubDate>Thu, 17 Sep 2015 19:55:31 +0000</pubDate>
<link>http://essays.uys.io/2015/09/17/n-business-days-until.html</link>
<guid isPermaLink="true">http://essays.uys.io/2015/09/17/n-business-days-until.html</guid>
<category>dashboards</category>
</item>
<item>
<title>Can you embed a secure IFRAME inside a secure container site?</title>
<description><p>In a <a href="/2015/09/10/security-considerations-of-using-a-secure-iframe-on-an-insecure-page.html">previous essay</a> I discussed the security implications of hosting an IFRAME on an insecure container page. The follow-up question is whether it’s actually possible to host a secure IFRAME inside a secure container page, and if all browsers will allow this.</p>
<p>My gut feeling said that this should be possible, because the IFRAME has its own <a href="http://www.w3.org/TR/html/browsers.html#nested-browsing-contexts">browsing context</a>. Browser support is a different question though, so I conducted a <a href="https://github.com/opyate/securesecure">quick experiment</a>.</p>
</description>
<pubDate>Tue, 15 Sep 2015 19:43:07 +0000</pubDate>
<link>http://essays.uys.io/2015/09/15/can-you-embed-a-secure-iframe-on-a-secure-site.html</link>
<guid isPermaLink="true">http://essays.uys.io/2015/09/15/can-you-embed-a-secure-iframe-on-a-secure-site.html</guid>
<category>security</category>
<category>web</category>
</item>
<item>
<title>Security considerations of using a secure IFRAME on an insecure page</title>
<description><p>In this essay I consider the information security implications around using a secure IFRAME (which, for example, hosts a payment or checkout page) on an insecure container page.</p>
<p>Some definitions:</p>
<ul>
<li>a “secure IFRAME” is one where its <code>src</code> attribute points to a domain over HTTPS, and any forms within the IFRAME submits to an HTTPS domain</li>
<li>an “insecure container page” is a “container” because it hosts the IFRAME (the HTML code for the page will have an <code>&lt;IFRAME&gt;</code> tag somewhere within it), and “insecure” because it was loaded over HTTP, not HTTPS.</li>
</ul>
<h1 id="opinions-in-the-wild">Opinions in the wild</h1>
<p><strong>TL;DR Regardless of how secure the IFRAME is, the container site can be compromised and render said security moot.</strong></p>
<p>Start typing “secure iframe” in Google, and note the suggestions:</p>
<ul>
<li><a href="https://www.google.co.uk/search?q=secure+iframe+in+non+secure+page">secure iframe in non secure page</a></li>
<li><a href="https://www.google.co.uk/search?q=secure%20iframe%20on%20unsecure%20page">secure iframe on unsecure page</a></li>
</ul>
<p>The search results point to related questions asked on the <a href="http://security.stackexchange.com/">Information Security Stack Exchange Q&amp;A site</a>, and a few blog posts by security experts have been written on the topic.</p>
<p>A non-exhaustive list of examples:</p>
<ul>
<li><a href="http://security.stackexchange.com/questions/38317/specific-risks-of-embedding-an-https-iframe-in-an-http-page">http://security.stackexchange.com/questions/38317/specific-risks-of-embedding-an-https-iframe-in-an-http-page</a></li>
<li><a href="http://security.stackexchange.com/questions/894/are-there-security-issues-with-embedding-an-https-iframe-on-an-http-page">http://security.stackexchange.com/questions/894/are-there-security-issues-with-embedding-an-https-iframe-on-an-http-page</a></li>
<li><a href="http://www.troyhunt.com/2014/11/does-insecure-website-compromise.html">http://www.troyhunt.com/2014/11/does-insecure-website-compromise.html</a></li>
<li><a href="http://stackoverflow.com/questions/3144986/http-and-https-iframe">http://stackoverflow.com/questions/3144986/http-and-https-iframe</a></li>
</ul>
<h1 id="mitm-primer">MITM primer</h1>
<p>MITM attack is a “man in the middle” attack.</p>
<p>When you sit in a coffeeshop, log on to their free Wifi, and frequent your favourite online shopping fix, your requests to see products and pay for products go through many “hops” before it actually reaches the destination: your browser connects to the Wifi access point, which connects to the coffee shop’s ISP via one hop or many, which connects to a common exchange somewhere in Britain via one hops or many, which connects to an exchange somewhere in another country via one hops or many (and almost definitely via a long undersea cable), which connects to the shopping site’s web server in a datacentre somewhere (and all together now!) via one hops or many.</p>
<p>Any of these “hops” can be compromised, but the typical scenario is for the attacker to host their own version of “free Wifi” right from their laptop with a legitimate-sounding name like “FreeHub”.</p>
<p>At this point the attacker’s laptop is just one more “hop” you’re totally oblivious to when you connect to “FreeHub”, letting your surfing activity through uninterrupted.</p>
<p>However, since the attacker now have access to the data stream between you and the outside world, she can now see the data. The crucial differentiator here is HTTP VS HTTPS: if you access a site directly via HTTPS, the attacker will see unintelligeble garbage. This is A Good Thing. If you access a site via HTTP, the attacker sees everything in the clear. Even if the website subsequently redirects to HTTPS, there’s an opportunity here for the attacker to spoof a TLS certificate.</p>
<p>Since the attacker now has a clear stream of data to intercept, the attacker can also change what your web browser sees (not you, necessarily).</p>
<h1 id="example-of-a-diy-mitm-attack">Example of a DIY MITM attack</h1>
<p>I’ll explore one example of exploiting an IFRAME (secure or not!) from an insecure container page. I’ll take some shortcuts in the sense that I won’t set up a compromised Wifi access point, or run software which injects malicious code into intercepted web traffic.</p>
<p>Clone <a href="https://gist.github.com/opyate/5dd65f5529d9508cf78e">this gist</a>, or follow these steps:</p>
<p>Create this simple index file:</p>
<figure class="highlight"><pre><code class="language-html" data-lang="html"><span class="nt">&lt;p&gt;</span>IFRAME below<span class="nt">&lt;/p&gt;</span>
<span class="nt">&lt;iframe</span> <span class="na">id=</span><span class="s">&quot;frame1&quot;</span> <span class="na">src=</span><span class="s">&quot;http://localhost:8000/i-dont-matter.html&quot;</span><span class="nt">&gt;&lt;/iframe&gt;</span></code></pre></figure>
<p>Create this simple form which will be loaded by the IFRAME:</p>
<figure class="highlight"><pre><code class="language-html" data-lang="html"><span class="nt">&lt;form</span> <span class="na">action=</span><span class="s">&quot;https://httpbin.org/post&quot;</span> <span class="na">method=</span><span class="s">&quot;POST&quot;</span><span class="nt">&gt;</span>
<span class="nt">&lt;input</span> <span class="na">name=</span><span class="s">&quot;secret&quot;</span> <span class="na">placeholder=</span><span class="s">&quot;Secret stuff here&quot;</span><span class="nt">&gt;</span>
<span class="nt">&lt;input</span> <span class="na">type=</span><span class="s">&quot;submit&quot;</span><span class="nt">&gt;</span>
<span class="nt">&lt;/form&gt;</span></code></pre></figure>
<p>Host the code locally with Python:</p>
<pre><code>python -m SimpleHTTPServer
</code></pre>
<p>Go to <a href="http://localhost:8000">http://localhost:8000</a> in your browser, and submit the form. <a href="http://httpbin.org/">HTTPBin</a> will echo back the payload.</p>
<p>Now, reload the page, but open your browser’s dev tools, and paste the code from the hack into the JavaScript console:</p>
<figure class="highlight"><pre><code class="language-javascript" data-lang="javascript"><span class="kd">var</span> <span class="nx">contents</span> <span class="o">=</span> <span class="s1">&#39;&lt;form action=&quot;https://httpbin.org/post&quot; method=&quot;POST&quot;&gt;&#39;</span><span class="p">;</span>
<span class="nx">contents</span> <span class="o">+=</span> <span class="s1">&#39;&lt;input name=&quot;secret&quot; placeholder=&quot;Secret stuff here&quot;&gt;&#39;</span><span class="p">;</span>
<span class="nx">contents</span> <span class="o">+=</span> <span class="s1">&#39;&lt;input type=&quot;submit&quot; onclick=&quot;return hack()&quot;&gt;&#39;</span><span class="p">;</span>
<span class="nx">contents</span> <span class="o">+=</span> <span class="s1">&#39;&lt;script type=&quot;text/javascript&quot;&gt;&#39;</span><span class="p">;</span>
<span class="nx">contents</span> <span class="o">+=</span> <span class="s1">&#39;function hack() { alert(&quot;h4x0rz&quot;); }&#39;</span><span class="p">;</span>
<span class="nx">contents</span> <span class="o">+=</span> <span class="s1">&#39;&lt;/script&gt;&#39;</span><span class="p">;</span>
<span class="nx">contents</span> <span class="o">+=</span> <span class="s1">&#39;&lt;/form&gt;&#39;</span><span class="p">;</span>
<span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">&#39;frame1&#39;</span><span class="p">).</span><span class="nx">src</span> <span class="o">=</span> <span class="s2">&quot;data:text/html;charset=utf-8,&quot;</span> <span class="o">+</span> <span class="nx">escape</span><span class="p">(</span><span class="nx">contents</span><span class="p">);</span></code></pre></figure>
<p>This is the MITM attack. This is what the attacker could do with the “in-the-clear data stream” we discussed before. The attacker simply matched on a known token (like the form submit button) and injected custom code with which to do evil.</p>
<p>Submit the form, and see the side effect.</p>
<p>Note that the IFRAME’s contents have been entirely modified. It was even made to look like the original content. The fact that the IFRAME’s <code>src</code> attribute previously loaded a secure site DOES NOT MATTER.</p>
<p>Consider yourself alerted.</p>
<h1 id="what-evil-side-effects-are-there">What evil side effects are there?</h1>
<p>OK, so the JavaScript <code>alert</code> you just saw is just for show, but consider this:</p>
<ul>
<li>the attacker sends the sensitive data you just submitted off to their own domain to be harvested à la <a href="http://www.fastcompany.com/1715575/tunisian-government-allegedly-hacking-facebook-gmail-accounts-dissidents-and-journalists">Tunisia</a></li>
<li>the attacker changes the delivery address for the expensive item you just bought to the unused address down their street</li>
</ul>
<h1 id="who-cares-about-my-site">Who cares about my site?</h1>
<p>Your insecure site might’nt accept sensitive input like payment details or sell valuable items, but your insecure site might be frequented by someone who does.</p>
<p>An attacker might know that a high profile (read: hack-worthy) individual called Bob Millionaire frequents your insecure pet discussion website. Let’s imagine for a second your forum software requires a login. <strong>Your insecure website has now become a target.</strong></p>
<p>The attacker will now trivially sniff for Bob Millionaire’s password on your insecure website, which she can replay against other more lucrative websites, if we can <a href="http://media.ofcom.org.uk/news/2013/uk-adults-taking-online-password-security-risks/">presume that Bob Millionaire re-uses his passwords</a>.</p>
<p>Even if you’re just the third party who owns the domain the IFRAME points to, you have to <strong>strongly consider if you want to be associated with the bad press which comes with your client’s website being exploited</strong> and having the IFRAME which was destined for your content being on the receiving end.</p>
<h1 id="the-solution">The solution</h1>
<p>Can we get to a better place by mandating all container sites to enforce TLS? I think we can. But this will just be a better place, not the ultimate secure place.</p>
<p>There’s a sliding scale, you see.</p>
<p>On the paranoid end you can presume every device and every network is compromised. No amount of TLS will help you. You can trust your own laptop as much as you do the web browser running on the old XP PC down the Internet cafe: you’ll think twice about what you do online, and where you do it. (yes, a modified version of any web browser can show a green padlock for anything)</p>
<p>On the naive end you can presume that you live in a free country, with devices built in secured facilities by known brands, and that the websites you frequent are hosted in secure datacentres, managed by security veterans who can be trusted.</p>
<p>Choose your position on the scale, and accept the risk that’s forthcoming.</p>
</description>
<pubDate>Thu, 10 Sep 2015 13:05:45 +0000</pubDate>
<link>http://essays.uys.io/2015/09/10/security-considerations-of-using-a-secure-iframe-on-an-insecure-page.html</link>
<guid isPermaLink="true">http://essays.uys.io/2015/09/10/security-considerations-of-using-a-secure-iframe-on-an-insecure-page.html</guid>
<category>security</category>
<category>web</category>
</item>
</channel>
</rss>