blog.rcook.org
Richard's blog
https://blog.rcook.org/atom.xml
Richard Cook
2024-02-27T19:23:07+00:00
<p>My first karaoke video: <a href="https://youtu.be/S1jhgjq-JT0">Long Time Gone</a>. I
built this using <a href="https://reaper.fm/">REAPER</a> and <a href="https://moises.ai/">moises.ai</a>.</p>
Long Time Gone (karaoke)
https://blog.rcook.org/blog/2024/long-time-gone-karaoke/
2024-02-27T00:00:00+00:00
2024-02-27T00:00:00+00:00
<p>I recorded my first ever solo open mic. Last night—Sunday 21 January—I
played three songs at <a href="https://thehiddendoorbbq.com/">The Hidden Door</a> in Shoreline, WA:</p>
<iframe width="640" height="360" src="https://www.youtube.com/embed/oVCxRGBgcBs" title="Open mic at The Hidden Door (2024-01-21)" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen="">
</iframe>
Open mic at The Hidden Door
https://blog.rcook.org/blog/2024/the-hidden-door/
2024-01-22T00:00:00+00:00
2024-01-22T00:00:00+00:00
<p>Second post of 2024 and it’s a new recording from my band, Whisperite:
<a href="https://soundcloud.com/whisperite/by-the-fire">By the Fire</a>. I’m playing the drums on this one!</p>
By the Fire
https://blog.rcook.org/blog/2024/by-the-fire/
2024-01-11T00:00:00+00:00
2024-01-11T00:00:00+00:00
<p>First post of 2024 and it’s a new recording: <a href="https://soundcloud.com/richardthepeace/long-time-gone">Long Time Gone</a>.</p>
Long Time Gone
https://blog.rcook.org/blog/2024/long-time-gone/
2024-01-10T00:00:00+00:00
2024-01-10T00:00:00+00:00
<p>I plan to update the table in my <a href="/blog/2023/rust-strings/">String conversions in Rust</a>
post to include <code class="language-plaintext highlighter-rouge">Path</code> and <code class="language-plaintext highlighter-rouge">PathBuf</code> conversions eventually. In the
meantime, here’s a handy reference: <a href="https://nicholasbishop.github.io/rust-conversions/">Rust Conversions</a>.</p>
String conversions in Rust follow-up
https://blog.rcook.org/blog/2023/rust-strings-follow-up/
2023-05-18T00:00:00+00:00
2023-05-18T00:00:00+00:00
<p>Sources: <a href="https://gist.github.com/jimmychu0807/9a89355e642afad0d2aeda52e6ad2424">1</a> and <a href="https://profpatsch.de/notes/rust-string-conversions">2</a></p>
<div class="language-rust highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">let</span> <span class="n">s</span><span class="p">:</span> <span class="nb">String</span> <span class="o">=</span> <span class="o">...</span>
<span class="k">let</span> <span class="n">st</span><span class="p">:</span> <span class="o">&</span><span class="nb">str</span> <span class="o">=</span> <span class="o">...</span>
<span class="k">let</span> <span class="n">u</span><span class="p">:</span> <span class="o">&</span><span class="p">[</span><span class="nb">u8</span><span class="p">]</span> <span class="o">=</span> <span class="o">...</span>
<span class="k">let</span> <span class="n">b</span><span class="p">:</span> <span class="p">[</span><span class="nb">u8</span><span class="p">;</span> <span class="mi">3</span><span class="p">]</span> <span class="o">=</span> <span class="s">b"foo"</span>
<span class="k">let</span> <span class="n">v</span><span class="p">:</span> <span class="nb">Vec</span><span class="o"><</span><span class="nb">u8</span><span class="o">></span> <span class="o">=</span> <span class="o">...</span>
<span class="k">let</span> <span class="n">os</span><span class="p">:</span> <span class="n">OsString</span> <span class="o">=</span> <span class="o">...</span>
<span class="k">let</span> <span class="n">ost</span><span class="p">:</span> <span class="n">OsStr</span> <span class="o">=</span> <span class="o">...</span>
</code></pre></div></div>
<table>
<thead>
<tr>
<th>From</th>
<th>To</th>
<th>Use</th>
<th>Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td><code class="language-plaintext highlighter-rouge">&str</code></td>
<td><code class="language-plaintext highlighter-rouge">String</code></td>
<td><code class="language-plaintext highlighter-rouge">String::from(st)</code></td>
<td> </td>
</tr>
<tr>
<td><code class="language-plaintext highlighter-rouge">&str</code></td>
<td><code class="language-plaintext highlighter-rouge">&[u8]</code></td>
<td><code class="language-plaintext highlighter-rouge">st.as_bytes()</code></td>
<td> </td>
</tr>
<tr>
<td><code class="language-plaintext highlighter-rouge">&str</code></td>
<td><code class="language-plaintext highlighter-rouge">Vec<u8></code></td>
<td><code class="language-plaintext highlighter-rouge">st.as_bytes().to_owned()</code></td>
<td>via <code class="language-plaintext highlighter-rouge">&[u8]</code></td>
</tr>
<tr>
<td><code class="language-plaintext highlighter-rouge">&str</code></td>
<td><code class="language-plaintext highlighter-rouge">&OsStr</code></td>
<td><code class="language-plaintext highlighter-rouge">OsStr::new(st)</code></td>
<td> </td>
</tr>
</tbody>
<tbody>
<tr>
<td><code class="language-plaintext highlighter-rouge">String</code></td>
<td><code class="language-plaintext highlighter-rouge">&str</code></td>
<td><code class="language-plaintext highlighter-rouge">&s</code></td>
<td>or <code class="language-plaintext highlighter-rouge">s.as_str()</code></td>
</tr>
<tr>
<td><code class="language-plaintext highlighter-rouge">String</code></td>
<td><code class="language-plaintext highlighter-rouge">&[u8]</code></td>
<td><code class="language-plaintext highlighter-rouge">s.as_bytes()</code></td>
<td> </td>
</tr>
<tr>
<td><code class="language-plaintext highlighter-rouge">String</code></td>
<td><code class="language-plaintext highlighter-rouge">Vec<u8></code></td>
<td><code class="language-plaintext highlighter-rouge">s.into_bytes()</code></td>
<td> </td>
</tr>
<tr>
<td><code class="language-plaintext highlighter-rouge">String</code></td>
<td><code class="language-plaintext highlighter-rouge">OsString</code></td>
<td><code class="language-plaintext highlighter-rouge">OsString::from(s)</code></td>
<td> </td>
</tr>
</tbody>
<tbody>
<tr>
<td><code class="language-plaintext highlighter-rouge">&[u8]</code></td>
<td><code class="language-plaintext highlighter-rouge">&str</code></td>
<td><code class="language-plaintext highlighter-rouge">str::from_utf8(u).unwrap()</code></td>
<td> </td>
</tr>
<tr>
<td><code class="language-plaintext highlighter-rouge">&[u8]</code></td>
<td><code class="language-plaintext highlighter-rouge">String</code></td>
<td><code class="language-plaintext highlighter-rouge">String::from_utf8(u).unwrap()</code></td>
<td> </td>
</tr>
<tr>
<td><code class="language-plaintext highlighter-rouge">&[u8]</code></td>
<td><code class="language-plaintext highlighter-rouge">Vec<u8></code></td>
<td><code class="language-plaintext highlighter-rouge">u.to_owned()</code></td>
<td> </td>
</tr>
<tr>
<td><code class="language-plaintext highlighter-rouge">&[u8]</code></td>
<td><code class="language-plaintext highlighter-rouge">&OsStr</code></td>
<td><code class="language-plaintext highlighter-rouge">OsStr::from_bytes(u)</code></td>
<td><code class="language-plaintext highlighter-rouge">use std::os::unix::ffi::OsStrExt;</code></td>
</tr>
</tbody>
<tbody>
<tr>
<td><code class="language-plaintext highlighter-rouge">[u8; 3]</code></td>
<td><code class="language-plaintext highlighter-rouge">&[u8]</code></td>
<td><code class="language-plaintext highlighter-rouge">&b[..]</code></td>
<td>byte literal</td>
</tr>
<tr>
<td><code class="language-plaintext highlighter-rouge">[u8; 3]</code></td>
<td><code class="language-plaintext highlighter-rouge">&[u8]</code></td>
<td><code class="language-plaintext highlighter-rouge">"foo".as_bytes()</code></td>
<td>alternative via UTF-8 literal</td>
</tr>
</tbody>
<tbody>
<tr>
<td><code class="language-plaintext highlighter-rouge">Vec<u8></code></td>
<td><code class="language-plaintext highlighter-rouge">&str</code></td>
<td><code class="language-plaintext highlighter-rouge">str::from_utf8(&v).unwrap()</code></td>
<td>via &<code class="language-plaintext highlighter-rouge">[u8]</code></td>
</tr>
<tr>
<td><code class="language-plaintext highlighter-rouge">Vec<u8></code></td>
<td><code class="language-plaintext highlighter-rouge">String</code></td>
<td><code class="language-plaintext highlighter-rouge">String::from_utf8(v)</code></td>
<td> </td>
</tr>
<tr>
<td><code class="language-plaintext highlighter-rouge">Vec<u8></code></td>
<td><code class="language-plaintext highlighter-rouge">&[u8]</code></td>
<td><code class="language-plaintext highlighter-rouge">&v</code></td>
<td> </td>
</tr>
<tr>
<td><code class="language-plaintext highlighter-rouge">Vec<u8></code></td>
<td><code class="language-plaintext highlighter-rouge">OsString</code></td>
<td><code class="language-plaintext highlighter-rouge">OsString::from_vec(v)</code></td>
<td><code class="language-plaintext highlighter-rouge">use std::os::unix::ffi::OsStringExt;</code></td>
</tr>
</tbody>
<tbody>
<tr>
<td><code class="language-plaintext highlighter-rouge">&OsStr</code></td>
<td><code class="language-plaintext highlighter-rouge">&str</code></td>
<td><code class="language-plaintext highlighter-rouge">ost.to_str().unwrap()</code></td>
<td> </td>
</tr>
<tr>
<td><code class="language-plaintext highlighter-rouge">&OsStr</code></td>
<td><code class="language-plaintext highlighter-rouge">String</code></td>
<td><code class="language-plaintext highlighter-rouge">ost.to_os_string().into_string().unwrap()</code></td>
<td>via <code class="language-plaintext highlighter-rouge">OsString</code></td>
</tr>
<tr>
<td><code class="language-plaintext highlighter-rouge">&OsStr</code></td>
<td><code class="language-plaintext highlighter-rouge">Cow<str></code></td>
<td><code class="language-plaintext highlighter-rouge">ost.to_string_lossy()</code></td>
<td>Unicode replacement characters</td>
</tr>
<tr>
<td><code class="language-plaintext highlighter-rouge">&OsStr</code></td>
<td><code class="language-plaintext highlighter-rouge">OsString</code></td>
<td><code class="language-plaintext highlighter-rouge">ost.to_os_string()</code></td>
<td> </td>
</tr>
<tr>
<td><code class="language-plaintext highlighter-rouge">&OsStr</code></td>
<td><code class="language-plaintext highlighter-rouge">&[u8]</code></td>
<td><code class="language-plaintext highlighter-rouge">ost.as_bytes()</code></td>
<td><code class="language-plaintext highlighter-rouge">use std::os::unix::ffi::OsStringExt;</code></td>
</tr>
</tbody>
<tbody>
<tr>
<td><code class="language-plaintext highlighter-rouge">OsString</code></td>
<td><code class="language-plaintext highlighter-rouge">String</code></td>
<td><code class="language-plaintext highlighter-rouge">os.into_string().unwrap()</code></td>
<td>returns original <code class="language-plaintext highlighter-rouge">OsString</code> on failure</td>
</tr>
<tr>
<td><code class="language-plaintext highlighter-rouge">OsString</code></td>
<td><code class="language-plaintext highlighter-rouge">&str</code></td>
<td><code class="language-plaintext highlighter-rouge">os.to_str().unwrap()</code></td>
<td> </td>
</tr>
<tr>
<td><code class="language-plaintext highlighter-rouge">OsString</code></td>
<td><code class="language-plaintext highlighter-rouge">&OsStr</code></td>
<td><code class="language-plaintext highlighter-rouge">os.as_os_str()</code></td>
<td> </td>
</tr>
<tr>
<td><code class="language-plaintext highlighter-rouge">OsString</code></td>
<td><code class="language-plaintext highlighter-rouge">Vec<u8></code></td>
<td><code class="language-plaintext highlighter-rouge">os.into_vec()</code></td>
<td><code class="language-plaintext highlighter-rouge">use std::os::unix::ffi::OsStringExt;</code></td>
</tr>
</tbody>
</table>
<p><strong>Update: 2023-05-18</strong></p>
<p>See <a href="/blog/2023/rust-strings-follow-up/">String conversions in Rust follow-up</a> to
find out about conversions to/from <code class="language-plaintext highlighter-rouge">Path</code> and <code class="language-plaintext highlighter-rouge">PathBuf</code>.</p>
String conversions in Rust
https://blog.rcook.org/blog/2023/rust-strings/
2023-04-14T00:00:00+00:00
2023-04-14T00:00:00+00:00
<p>Ja! Tre hundre og sekstifem dager med å lære norsk!</p>
<p><img src="https://blog.rcook.org/assets/2023-03-24-tre-hundre-og-sekstifem-dager/365_day_streak.png" alt="Screenshot" /></p>
Tre hundre og sekstifem dager!
https://blog.rcook.org/blog/2023/tre-hundre-og-sekstifem-dager/
2023-03-24T00:00:00+00:00
2023-03-24T00:00:00+00:00
<p>Jeg legger igjen disse her så jeg ikke glemmer dem:</p>
<ul>
<li><em>Hjem til jul</em></li>
<li><em>Julestorm</em></li>
<li><em>Kongens nei</em></li>
<li><em>Narvik</em></li>
<li><em>Post mortem</em></li>
<li><em>Troll</em></li>
<li><em>Vikingane</em></li>
</ul>
<p>Jeg skal se alle disse på nytt til slutt.</p>
Norske TV-serier og filmer
https://blog.rcook.org/blog/2023/02-norske-tv-serier-og-filmer/
2023-02-23T00:00:00+00:00
2023-02-23T00:00:00+00:00
<p>Den norske reisen min fortsetter. Jeg har lært norsk ved hjelp av Duolingo
og andre ressurser i nesten ett år. Jeg leste <em>Mystery of Nils</em>, <em>Mysteriet
om Nils</em> og noen få noveller. Nå har jeg begynt på mitt Ibsen-eventyr
med <em>Et dukkehjem</em>. Teknisk er det skrevet på dansk-norsk—ikke
bokmål—men det er nærme nok for meg! Jeg vil til Norge. Litt Oslo,
litt Hurtigruten. Kanskje noe Nordens Paris. Eller noe Svalbard.</p>
Norsk fortsatte
https://blog.rcook.org/blog/2023/01-norsk-fortsatte/
2023-02-23T00:00:00+00:00
2023-02-23T00:00:00+00:00
<p>Jeg prøver noe forskjellig: Jeg lærer norsk. Nå snakker jeg dårlig norsk.</p>
Jeg lærer norsk
https://blog.rcook.org/blog/2022/norsk/
2022-04-16T00:00:00+00:00
2022-04-16T00:00:00+00:00