Taggat web på Rasmus.krats.sehttps://rasmus.krats.se/tag/web.sv2023-02-05T23:25:08+00:00Skriverier då och då, på webben sedan 1994.Command line interface <code>url</code>https://rasmus.krats.se/2023/url-cli.en2023-02-05T23:25:08+00:00Rasmus Kajhttps://rasmus.krats.se/rkaj2023-02-05T23:25:08+00:00<p>I wrote a little command-line interface for sending a http request and
getting the response.
I call the package <a href="https://lib.rs/crates/url-cli" data-type='ReferenceUnknown'>url-cli</a>, and the command itself is <code>url</code>.
It has sub-commands for the different http methods.</p>
<p>If you have a rust toolchain installed, you can get it by cargo install.
I haven’t made any binary packages yet.</p>
<pre data-lang="sh"><span class="syhsource syhshell syhbash"><span class="syhmeta syhfunction-call syhshell"><span class="syhsupport syhfunction syhcolon syhshell">:</span></span><span class="syhkeyword syhoperator syhlogical syhcontinue syhshell">;</span> <span class="syhmeta syhfunction-call syhshell"><span class="syhvariable syhfunction syhshell">cargo</span></span><span class="syhmeta syhfunction-call syharguments syhshell"> install url-cli</span>
<span class="syhmeta syhfunction-call syhshell"><span class="syhvariable syhfunction syhshell">[...</span></span><span class="syhmeta syhfunction-call syharguments syhshell"> building, installing ...]</span>
<span class="syhmeta syhfunction-call syhshell"><span class="syhsupport syhfunction syhcolon syhshell">:</span></span><span class="syhkeyword syhoperator syhlogical syhcontinue syhshell">;</span> <span class="syhmeta syhfunction-call syhshell"><span class="syhvariable syhfunction syhshell">url</span></span><span class="syhmeta syhfunction-call syharguments syhshell"> get https://rasmus.krats.se/2023/url-cli.en</span>
<span class="syhmeta syhfunction-call syhshell"></span><span class="syhmeta syhfunction-call syharguments syhshell"><span class="syhkeyword syhoperator syhassignment syhredirection syhshell"><</span>!doctype html<span class="syhkeyword syhoperator syhassignment syhredirection syhshell">></span>
</span><span class="syhmeta syhfunction-call syhshell"><span class="syhvariable syhfunction syhshell">[...</span></span><span class="syhmeta syhfunction-call syharguments syhshell"> and all the rest of the html for this web page ...]</span>
</span></pre>
<p class='readmore'><a href='https://rasmus.krats.se/2023/url-cli.en'>Read whole <q>Command line interface <code>url</code></q> with 2 comments.</a></p>Light or dark?https://rasmus.krats.se/2022/theme.en2022-05-16T22:11:00+00:00Rasmus Kajhttps://rasmus.krats.se/rkaj2022-05-16T22:11:00+00:00<p>I’ve had a light and a dark theme on this site since <a href="/2022/r4s.en" data-type='Inline'>I switch from python
to rust</a>.
But until now I have only used css <code>@media</code> selection to enable the
dark theme, so it hasn’t been very discoverable.
If you have a browser that supports the <code>prefers-color-scheme</code> query <em>and</em>
you have found that setting and enabled dark mode, you have seen this site
in the dark theme (and may not know that it had a light theme), otherwise you have
seen the site in the light theme (and not known about the dark).</p>
<p class='readmore'><a href='https://rasmus.krats.se/2022/theme.en'>Read whole <q>Light or dark?</q>.</a></p>Tracker-free youtube embeddinghttps://rasmus.krats.se/2022/youtube.en2022-04-03T18:04:25+00:00Rasmus Kajhttps://rasmus.krats.se/rkaj2022-04-03T18:04:25+00:00<p>Sometimes I want to embed a video on my site.
Most of the videos I want to embed are on youtube.
Klicking “share” on a video and choosing embed, I get a bunch of html
code I can copy into a post.
Something like this, for example:</p>
<pre data-lang="html"><span class="syhtext syhhtml syhbasic"><span class="syhmeta syhtag syhblock syhany syhhtml"><span class="syhpunctuation syhdefinition syhtag syhbegin syhhtml"><</span><span class="syhentity syhname syhtag syhblock syhany syhhtml">iframe</span> <span class="syhmeta syhattribute-with-value syhhtml"><span class="syhentity syhother syhattribute-name syhhtml">width</span><span class="syhpunctuation syhseparator syhkey-value syhhtml">=</span></span><span class="syhmeta syhattribute-with-value syhhtml"><span class="syhstring syhquoted syhdouble syhhtml"><span class="syhpunctuation syhdefinition syhstring syhbegin syhhtml">"</span>560<span class="syhpunctuation syhdefinition syhstring syhend syhhtml">"</span></span></span> <span class="syhmeta syhattribute-with-value syhhtml"><span class="syhentity syhother syhattribute-name syhhtml">height</span><span class="syhpunctuation syhseparator syhkey-value syhhtml">=</span></span><span class="syhmeta syhattribute-with-value syhhtml"><span class="syhstring syhquoted syhdouble syhhtml"><span class="syhpunctuation syhdefinition syhstring syhbegin syhhtml">"</span>315<span class="syhpunctuation syhdefinition syhstring syhend syhhtml">"</span></span></span> <span class="syhmeta syhattribute-with-value syhhtml"><span class="syhentity syhother syhattribute-name syhhtml">src</span><span class="syhpunctuation syhseparator syhkey-value syhhtml">=</span></span><span class="syhmeta syhattribute-with-value syhhtml"><span class="syhstring syhquoted syhdouble syhhtml"><span class="syhpunctuation syhdefinition syhstring syhbegin syhhtml">"</span>https://www.youtube.com/embed/3St1CoH1rKU<span class="syhpunctuation syhdefinition syhstring syhend syhhtml">"</span></span></span>
<span class="syhmeta syhattribute-with-value syhhtml"><span class="syhentity syhother syhattribute-name syhhtml">title</span><span class="syhpunctuation syhseparator syhkey-value syhhtml">=</span></span><span class="syhmeta syhattribute-with-value syhhtml"><span class="syhstring syhquoted syhdouble syhhtml"><span class="syhpunctuation syhdefinition syhstring syhbegin syhhtml">"</span>YouTube video player<span class="syhpunctuation syhdefinition syhstring syhend syhhtml">"</span></span></span> <span class="syhmeta syhattribute-with-value syhhtml"><span class="syhentity syhother syhattribute-name syhhtml">frameborder</span><span class="syhpunctuation syhseparator syhkey-value syhhtml">=</span></span><span class="syhmeta syhattribute-with-value syhhtml"><span class="syhstring syhquoted syhdouble syhhtml"><span class="syhpunctuation syhdefinition syhstring syhbegin syhhtml">"</span>0<span class="syhpunctuation syhdefinition syhstring syhend syhhtml">"</span></span></span>
<span class="syhmeta syhattribute-with-value syhhtml"><span class="syhentity syhother syhattribute-name syhhtml">allow</span><span class="syhpunctuation syhseparator syhkey-value syhhtml">=</span></span><span class="syhmeta syhattribute-with-value syhhtml"><span class="syhstring syhquoted syhdouble syhhtml"><span class="syhpunctuation syhdefinition syhstring syhbegin syhhtml">"</span>accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture<span class="syhpunctuation syhdefinition syhstring syhend syhhtml">"</span></span></span>
<span class="syhentity syhother syhattribute-name syhhtml">allowfullscreen</span><span class="syhpunctuation syhdefinition syhtag syhend syhhtml">></span></span>
<span class="syhmeta syhtag syhblock syhany syhhtml"><span class="syhpunctuation syhdefinition syhtag syhbegin syhhtml"></</span><span class="syhentity syhname syhtag syhblock syhany syhhtml">iframe</span><span class="syhpunctuation syhdefinition syhtag syhend syhhtml">></span></span>
</span></pre>
<p class='readmore'><a href='https://rasmus.krats.se/2022/youtube.en'>Read whole <q>Tracker-free youtube embedding</q>.</a></p>Ny blogmjukvarahttps://rasmus.krats.se/2022/r4s.sv2022-01-16T22:07:00+00:00Rasmus Kajhttps://rasmus.krats.se/rkaj2022-01-16T22:07:00+00:00<figure class='sidebar front' data-type='ReferenceUnknown'><a href='https://img.krats.se/img/71847-m.jpg'><img src='https://img.krats.se/img/71847-s.jpg' alt='Fyrverkerier över tak' width='288' height='216'></a><figcaption>Nytt år, ny blogmotor </figcaption></figure>
<p>Jag har skrivit ny blogmjukvara igen!
Den förra hette <a href="https://github.com/kaj/r5" data-type='Inline'>r5</a>, som i Rasmus (utan 5
bokstäver). Den nya är skriven i Rust (källkodsfilerna heter <code>.rs</code>),
så det kändes naturligt att kalla den <a href="https://github.com/kaj/r4s" data-type='Inline'>r4s</a>,
också som i Rasmus (men utan 4 bokstäver 😎).</p>
<p>Nu får vi se om ett nytt kul blogprogram får mig att skriva fler blogposter.</p>
<p class='readmore'><a href='https://rasmus.krats.se/2022/r4s.sv'>Läs hela <q>Ny blogmjukvara</q> med 1 kommentarer.</a></p>Web frameworks in Rusthttps://rasmus.krats.se/2020/rustweb.en2020-09-09T20:48:00+00:00Rasmus Kajhttps://rasmus.krats.se/rkaj2020-09-09T20:48:00+00:00<p>When doing a web application server, one of the first things to decide
is which “web application framework” or “request handler library” to
use.
In Rust, there are more alternatives for that question than in most
programming languages, and anyone who has ported some code from tomcat
jsp to play framework or from flask to django may dread making the
wrong choice.
On the other hand, Rust being very strict on static typing makes it
very easy to do major refactorings, and I have switched existing
projects from iron to nickel to gotham to warp myself without too big
problems.</p>
<p class='readmore'><a href='https://rasmus.krats.se/2020/rustweb.en'>Read whole <q>Web frameworks in Rust</q>.</a></p>1500 Fantomentidningarhttps://rasmus.krats.se/2020/fantomen.sv2020-04-28T18:53:00+00:00Rasmus Kajhttps://rasmus.krats.se/rkaj2020-04-28T18:53:00+00:00<figure class='fa-cover sidebar'><a href='https://fantomenindex.krats.se/c/f2020-10.jpg'><img alt='Omslagsbild Fa 10-11/2020' src='https://fantomenindex.krats.se/c/f2020-10.jpg' width='150'/></a><figcaption>Fa 10-11/2020 Nummer 1667 i tryck och 1500 i mitt index </figcaption></figure>
<p>För dryg ett år sedan passerade
<a href="https://fantomenindex.krats.se/" data-type='Inline'>mitt fantomenindex</a> 1400 tidningar.
På det året har jag indexerat ytterligare 100 tidningar, så nu finns
1500 tidningar i indexet!
Antalet indexerade tidningar växer alltså klart snabbare än de
utgivna, så förr eller senare ska jag nog vara i kapp (som jag sa även
för ett år sedan).</p>
<p class='readmore'><a href='https://rasmus.krats.se/2020/fantomen.sv'>Läs hela <q>1500 Fantomentidningar</q> med 2 kommentarer.</a></p>1400 Fantomentidningarhttps://rasmus.krats.se/2019/fanrs.sv2019-03-17T21:45:00+00:00Rasmus Kajhttps://rasmus.krats.se/rkaj2019-03-17T21:45:00+00:00<p>För inte så länge sedan passerade
<a href="http://fantomenindex.krats.se/" data-type='Inline'>mitt fantomenindex</a> 1400 tidningar.
Sedan dess har visserligen nummer 1645 sedan starten publicerats,
men antalet indexerade tidningar växer i alla falla snabbare än
antalet utgivna, så förr eller senare ska jag nog vara i kapp.</p>
<p class='readmore'><a href='https://rasmus.krats.se/2019/fanrs.sv'>Läs hela <q>1400 Fantomentidningar</q> med 3 kommentarer.</a></p>Rust and me in 2019https://rasmus.krats.se/2019/rust2019.en2019-01-26T16:25:00+00:00Rasmus Kajhttps://rasmus.krats.se/rkaj2019-01-26T16:25:00+00:00<figure class='sidebar front' data-type='ReferenceUnknown'><a href='https://img.krats.se/img/63344-m.jpg'><img src='https://img.krats.se/img/63344-s.jpg' alt='Colored letters of code' width='288' height='216'></a><figcaption>Some rust code </figcaption></figure>
<p>There is <a href="https://blog.rust-lang.org/2018/12/06/call-for-rust-2019-roadmap-blogposts.html%22" data-type='Inline'>A Call for Community Blog
posts</a>
over at the
<a href="https://blog.rust-lang.org/" data-type='Inline'>Rust Programming Language Blog</a>.
This is my entry, briefly describing my hopes and expectations for
Rust, it’s eco-system and my own participation in 2019.</p>
<p class='readmore'><a href='https://rasmus.krats.se/2019/rust2019.en'>Read whole <q>Rust and me in 2019</q>.</a></p>Propagandacyklinghttps://rasmus.krats.se/2018/propagandacykling.sv2018-02-11T21:10:00+00:00Rasmus Kajhttps://rasmus.krats.se/rkaj2018-02-11T21:10:00+00:00<p>Jag har inte lagt upp någon propagandacykling här på bloggen på ganska
länge.
Naturligtvis cyklar jag fortfarande till jobbet de flesta av de dagar
jag inte jobbar hemifrån, och jag brukar ta en bild och
<a href="https://twitter.com/rasmus_kaj" data-type='Inline'>lägga ut på twitter</a>.</p>
<p>Men jag har <a href="https://github.com/kaj/rphotos" data-type='Inline'>ett projekt för att organisera mitt
bildarkiv</a> på gång också.</p>
<p>Det har kommit så långt att det är smidigare att lägga upp mina
bilder där än här.
Så <a href="https://img.krats.se/tag/propagandacykling" data-type='Inline'>vill du se mina samlade cykelbilder så finns de
där</a>!</p>
<p>Men jag får väl inkludera tre ganska färska bilder här också.</p>
<div class='gallery'><figure class='gallery' data-type='ReferenceUnknown'><a href='https://img.krats.se/img/59880-m.jpg'><img src='https://img.krats.se/img/59880-s.jpg' alt='' width='288' height='216'></a><figcaption> </figcaption></figure>
<figure class='gallery' data-type='ReferenceUnknown'><a href='https://img.krats.se/img/59995-m.jpg'><img src='https://img.krats.se/img/59995-s.jpg' alt='' width='288' height='216'></a><figcaption> </figcaption></figure>
<figure class='gallery' data-type='ReferenceUnknown'><a href='https://img.krats.se/img/60025-m.jpg'><img src='https://img.krats.se/img/60025-s.jpg' alt='' width='288' height='216'></a><figcaption> </figcaption></figure>
</div><!--gallery-->
<p class='readmore'><a href='https://rasmus.krats.se/2018/propagandacykling.sv'>Bli först att kommentera.</a></p>Rust and the web in 2018https://rasmus.krats.se/2018/rustweb.en2018-01-07T22:50:00+00:00Rasmus Kajhttps://rasmus.krats.se/rkaj2018-01-07T22:50:00+00:00<p>There is <a href="https://blog.rust-lang.org/2018/01/03/new-years-rust-a-call-for-community-blogposts.html" data-type='Inline'>A Call for Community Blogposts
</a>
over at the
<a href="https://blog.rust-lang.org/" data-type='Inline'>Rust Programming Language Blog</a>.
This is my entry.</p>
<p>I mainly do “server-based” web service development.
The server sends html, css, images, and javascript to the browser.
The javascript implements progressive enhancement for the content,
but the site should be usable and as nice as possible even with
javascript disabled.
So while I certainly do <a href="https://en.wikipedia.org/wiki/RESTful" title="Se RESTful på wikipedia" data-type='ReferenceUnknown'>RESTful</a> json API:s, I also do
server-side html templateing, css (and scss) minification, etc.
I think Rust has great potential here, partly because of optimization and
execution speed, but mainly because the type safety and fearless concurrency
make it easy to actually get things right and avoid unpleasant surprises at
runtime.</p>
<p class='readmore'><a href='https://rasmus.krats.se/2018/rustweb.en'>Read whole <q>Rust and the web in 2018</q>.</a></p>