Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
182 lines (180 loc) · 11.9 KB
/
Copy pathindex.html
File metadata and controls
182 lines (180 loc) · 11.9 KB
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
---
layout: null
title: Ryan Bigg
---
<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>Ryan Bigg</title>
<meta name="description" content="Lead developer working with AI, Ruby, React and TypeScript. Author, mentor and open source maintainer.">
<link rel="shortcut icon" href="/favicon.png" type="image/x-icon">
<link href="/feed.xml" rel="alternate" title="RyanBigg.com" type="application/atom+xml">
<meta property="og:title" content="Ryan Bigg">
<meta property="og:site_name" content="Ryan Bigg">
<meta property="og:url" content="https://ryanbigg.com/">
<meta property="og:type" content="website">
<meta property="og:image" content="https://ryanbigg.com/images/og.png">
<meta name="twitter:card" content="summary_large_image">
<style>
:root { --bg:#fafaf7; --fg:#1a1d1b; --muted:#7b8380; --line:#e3e6e1; --card:#fff; --hot:oklch(62% .2 150); --sel:#e9f7ed; }
@media (prefers-color-scheme: dark) { :root { --bg:#0e110f; --fg:#e3e8e4; --muted:#8a948e; --line:#252b27; --card:#151a17; --hot:oklch(80% .18 150); --sel:#16281c; } }
* { box-sizing:border-box; }
body { margin:0; min-height:100vh; background:var(--bg); color:var(--fg); font:17px/1.5 system-ui,-apple-system,sans-serif; display:grid; grid-template-columns:minmax(0,1fr); justify-items:center; align-items:start; padding:18vh 1rem 3rem; }
.box { width:100%; max-width:40rem; min-width:0; }
h1 { font-size:1rem; font-weight:600; letter-spacing:.02em; color:var(--muted); margin:0 0 .75rem .25rem; display:flex; align-items:center; justify-content:space-between; gap:.75rem; } h1 b { color:var(--hot); }
.duck { outline:none; -webkit-tap-highlight-color:transparent; cursor:pointer; flex:none; margin-right:.25rem; } .duck:hover { transform:rotate(-8deg); } .duck { transition:transform .15s; position:relative; z-index:0; } .field { position:relative; z-index:1; }
.field { background:var(--card); border:1px solid var(--line); border-radius:1rem; box-shadow:0 8px 30px rgba(0,0,0,.06); overflow:hidden; }
.field:focus-within { border-color:var(--hot); }
input { width:100%; border:0; outline:0; background:none; font:inherit; font-size:1.25rem; padding:1.1rem 1.25rem; color:inherit; }
input::placeholder { color:var(--muted); }
ul { list-style:none; margin:0; padding:0; border-top:1px solid var(--line); } ul:empty { display:none; }
li a { display:flex; align-items:baseline; gap:.75rem; padding:.7rem 1.25rem; color:inherit; text-decoration:none; }
li.sel a, li a:hover { background:var(--sel); }
li .k { font-size:.7rem; text-transform:uppercase; letter-spacing:.06em; color:var(--hot); width:8.5rem; flex:none; font-weight:700; white-space:nowrap; }
li .t { flex:1; } li .u { color:var(--muted); font-size:.8rem; white-space:nowrap; }
.say { padding:.8rem 1.25rem; font-size:.95rem; color:var(--muted); border-top:1px solid var(--line); } .say:empty { display:none; }
.foot { display:flex; justify-content:space-between; color:var(--muted); font-size:.8rem; padding:.7rem .25rem; }
.disclaimer { margin-top:2.5rem; text-align:center; color:var(--muted); font-size:.8rem; }
@media (max-width: 34rem) {
body { padding-top:8vh; }
li a { flex-wrap:wrap; gap:.1rem .75rem; padding:.65rem 1rem; }
li .k { width:auto; min-width:4.5rem; }
li .t { flex:1 1 0; min-width:0; }
li .u { flex-basis:100%; padding-left:0; white-space:normal; overflow-wrap:anywhere; font-size:.75rem; }
.foot { flex-direction:column; gap:.25rem; }
.say { padding:.8rem 1rem; }
}
kbd { font:inherit; border:1px solid var(--line); border-radius:.3rem; padding:0 .35rem; background:var(--card); }
.try { margin-top:1.5rem; display:flex; flex-wrap:wrap; gap:.5rem; }
.try button { all:unset; cursor:pointer; font-size:.85rem; color:var(--muted); border:1px solid var(--line); border-radius:2rem; padding:.25rem .8rem; } .try button:hover { color:var(--hot); border-color:var(--hot); }
</style></head><body>
<div class="box">
<h1><span><b>Ryan Bigg</b> · <span id="hello">what do you want to do?</span></span><svg class="duck" tabindex="0" role="button" viewBox="0 0 32 32" width="28" height="28" aria-label="Rubber duck: click to quack"><title>Quack</title><path d="M4 17c0-3 2-4.500 5-4.500 1 0 1.500-.300 1.500-1.500v-1c0-3.500 2.500-6 6-6s6 2.500 6 6c0 2-.800 3.300-2 4.200C25 15 28 16 28 20c0 4.500-4 8-10 8H11C6.500 28 4 24 4 17z" fill="#fbbf24"/><path d="M22.500 10.500h5c.800 0 1.200.800.700 1.400-.9 1-2.700 1.600-5.700 1.200z" fill="#f97316"/><circle cx="19" cy="9" r="1.200" fill="#1a1d1b"/><path d="M9 20c2.500 3 7 3 10 .500-2-.500-3.500-2-4-3.500-1.500 2-4 2.500-6 3z" fill="#f59e0b"/></svg></h1>
<div class="field">
<input id="q" autofocus autocomplete="off" spellcheck="false" placeholder="Read a post, read my books, watch a talk…">
<div class="say" id="say"></div>
<ul id="res"></ul>
</div>
<div class="foot"><span><kbd>↑</kbd> <kbd>↓</kbd> to choose · <kbd>Enter</kbd> to open</span><span>AI-powered search</span></div>
<div class="try" id="try"></div>
<p class="disclaimer">Ryan is human and can make mistakes.</p>
</div>
<script src="/js/intent.js"></script>
<script>
const q = document.getElementById('q'), res = document.getElementById('res'), say = document.getElementById('say');
const esc = s => s.replace(/[&<>]/g, c => ({'&':'&','<':'<','>':'>'}[c]));
let items = [], sel = 0;
// Greeting by the visitor's local day and time
function greeting(d = new Date()) {
const day = d.getDay(), h = d.getHours();
if (day === 6) return "Saturday. Shouldn't you be outside?";
if (day === 0) return "Sunday. Lovely day for clicking things.";
if (day === 1 && h < 12) return "New week. Fresh start, same inbox.";
if (day === 5 && h >= 12) return "Friday afternoon. Please don't deploy anything.";
if (day === 3 && h >= 9 && h < 17) return "Midweek. Hump day, as they say.";
if (h < 5 || h >= 23) return "It's late. Go to bed. After you've had a look around.";
if (h < 9) return "Up before the coffee? Same.";
if (h < 12) return "Coffee o'clock. What can I help with?";
if (h < 14) return "Lunch break browsing. Good choice.";
if (h < 17) return "Afternoon slump? Here, click something.";
if (h < 20) return "Good evening. Knocking off for the day?";
return "Evening. Still at the keyboard?";
}
document.getElementById('hello').textContent = greeting();
// Rubber duck squeak
const quacks = [1,2,3,4].map(n => { const a = new Audio(`/sounds/quack${n}.wav`); a.preload = 'auto'; return a; });
let lastQuack = -1;
function quack() {
let i; do { i = Math.floor(Math.random() * quacks.length); } while (i === lastQuack);
lastQuack = i;
const a = quacks[i];
a.playbackRate = 0.9 + Math.random() * 0.25;
a.currentTime = 0; a.play().catch(() => {});
}
const duck = document.querySelector('.duck');
const popSound = new Audio('/sounds/pop.mp3'); popSound.preload = 'auto';
const nextPop = () => 5 + Math.floor(Math.random() * 16);
let clicks = 0, popAt = nextPop();
function explode() {
if (matchMedia('(prefers-reduced-motion: reduce)').matches) return;
const r = duck.getBoundingClientRect(), dpr = window.devicePixelRatio || 1;
const cv = document.createElement('canvas');
cv.width = innerWidth * dpr; cv.height = innerHeight * dpr;
cv.style.cssText = 'position:fixed;inset:0;width:100%;height:100%;pointer-events:none;z-index:9';
document.body.appendChild(cv);
const ctx = cv.getContext('2d'); ctx.scale(dpr, dpr);
// Paint the duck's own SVG shapes onto a texture, then cut it into triangular pieces.
const T = 8, tex = document.createElement('canvas'), tc = tex.getContext('2d', { willReadFrequently: true });
tex.width = tex.height = 32 * T; tc.scale(T, T);
duck.querySelectorAll('path, circle').forEach(el => {
tc.fillStyle = el.getAttribute('fill');
if (el.tagName === 'circle') { tc.beginPath(); tc.arc(+el.getAttribute('cx'), +el.getAttribute('cy'), +el.getAttribute('r'), 0, Math.PI * 2); tc.fill(); }
else tc.fill(new Path2D(el.getAttribute('d')));
});
const k = r.width / 32 * 1.8, N = 4, cell = 32 / N, bits = [];
const cx = r.left + r.width / 2, cy = r.top + r.height / 2;
for (let gy = 0; gy < N; gy++) for (let gx = 0; gx < N; gx++) {
const x0 = gx * cell, y0 = gy * cell, x1 = x0 + cell, y1 = y0 + cell;
const tris = (gx + gy) % 2 ? [[[x0,y0],[x1,y0],[x1,y1]], [[x0,y0],[x1,y1],[x0,y1]]] : [[[x0,y0],[x1,y0],[x0,y1]], [[x1,y0],[x1,y1],[x0,y1]]];
for (const tri of tris) {
const mx = (tri[0][0] + tri[1][0] + tri[2][0]) / 3, my = (tri[0][1] + tri[1][1] + tri[2][1]) / 3;
if (!tc.getImageData(mx * T | 0, my * T | 0, 1, 1).data[3]) continue;
const ox = (mx - 16) * k, oy = (my - 16) * k, ang = Math.atan2(oy || .01, ox || .01) + (Math.random() - .5) * .8, v = 160 + Math.random() * 320;
bits.push({ tri, mx, my, x: cx + ox, y: cy + oy, vx: Math.cos(ang) * v, vy: Math.sin(ang) * v - 140, rot: 0, vr: (Math.random() - .5) * 14 });
}
}
let last = performance.now(), age = 0;
(function frame(now) {
const dt = Math.min((now - last) / 1000, .05); last = now; age += dt;
ctx.clearRect(0, 0, innerWidth, innerHeight);
const fade = Math.max(0, 1 - Math.max(0, age - .7) / .5);
for (const b of bits) {
b.vx *= Math.pow(.1, dt); b.vy = b.vy * Math.pow(.1, dt) + 900 * dt;
b.x += b.vx * dt; b.y += b.vy * dt; b.rot += b.vr * dt;
ctx.save(); ctx.translate(b.x, b.y); ctx.rotate(b.rot); ctx.scale(k, k); ctx.globalAlpha = fade;
ctx.beginPath(); b.tri.forEach(([px, py], i) => (i ? ctx.lineTo : ctx.moveTo).call(ctx, px - b.mx, py - b.my)); ctx.closePath(); ctx.clip();
ctx.drawImage(tex, -b.mx, -b.my, 32, 32); ctx.restore();
}
if (fade > 0) requestAnimationFrame(frame); else cv.remove();
})(last);
}
function pop() {
clicks = 0; popAt = nextPop();
popSound.currentTime = 0; popSound.play().catch(() => {});
// Explode the duck into shards, then slide a fresh one up from underneath the chat box.
const gone = duck.animate([{ opacity:1 }, { opacity:0 }], { duration:1, fill:'forwards' });
explode();
duck.style.pointerEvents = 'none';
setTimeout(() => {
gone.cancel();
duck.style.pointerEvents = '';
const dy = document.querySelector('.field').getBoundingClientRect().top + 4 - duck.getBoundingClientRect().top;
duck.animate([{ transform:`translateY(${dy}px)` }, { transform:'translateY(0)' }], { duration:650, easing:'cubic-bezier(.2,.9,.3,1.15)' });
}, 2000);
}
function duckClick() { if (++clicks >= popAt) pop(); else quack(); }
duck.onclick = duckClick;
duck.onkeydown = e => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); duckClick(); } };
SUGGESTIONS.forEach(s => {
const b = document.createElement('button');
b.textContent = s;
b.onclick = () => { q.value = s; update(); q.focus(); };
document.getElementById('try').append(b);
});
function update() {
const text = q.value; items = []; say.textContent = ''; sel = 0;
if (text.trim()) {
const g = guess(text);
if (g.intent) { say.textContent = g.intent.reply; g.intent.links.forEach(([t,u]) => items.push({k:g.intent.label.split(' ')[0], t, u})); }
g.posts.forEach(p => items.push({k:'Post', t:p.t, u:p.u}));
g.alts.forEach(a => items.push({k:'Maybe', t:a.label, u:a.links[0][1]}));
if (!items.length) { say.textContent = "No idea what that is. Try the blog, or just email me."; items = [{k:'Blog',t:'Browse the blog',u:'/blog'},{k:'Email',t:'me@ryanbigg.com',u:'mailto:me@ryanbigg.com'}]; }
}
render();
}
function render() { res.innerHTML = items.map((it,i) => `<li class="${i===sel?'sel':''}"><a href="${it.u}"><span class="k">${esc(it.k)}</span><span class="t">${esc(it.t)}</span><span class="u">${esc(it.u.replace(/^https?:\/\//,''))}</span></a></li>`).join(''); }
q.oninput = update;
q.onkeydown = e => {
if (e.key === 'ArrowDown') { e.preventDefault(); sel = Math.min(sel+1, items.length-1); render(); }
else if (e.key === 'ArrowUp') { e.preventDefault(); sel = Math.max(sel-1, 0); render(); }
else if (e.key === 'Enter' && items[sel]) location.href = items[sel].u;
};
</script></body></html>