Skip to main content

Ralsina.Me — Roberto Alsina's website

Posts about programming

Croupier v0.5.0 is out

A new release of Croupier my Crystal library for tasks and dataflow programming is out!

What's Changed

  • New TaskManager.auto_mode? property
  • Yield on spawn to make con­cur­ren­cy more use­ful
  • More ef­fi­cient in­put han­dling
  • Fix dead­lock­ing bug in par­al­lel run­ner
  • Warn or er­ror when tasks are next in line but not ready

Full Changel­og: v0.4.1...v0.5.0

Croupier v0.4.1 out

A new release of Croupier my Crystal library for tasks and dataflow programming is out!

What's new in v0.4.1?

  • Add mergeable flag for tasks (default true)
  • Added TaskManager.depends_on function

Croupier version v0.4.0 is out

A new release of Croupier my Crystal library for tasks and dataflow programming is out!

What's Changed

  • Sup­port key/­val­ue in ad­di­tion to files as in­put/out­put
  • Im­ple­ment a per­sis­tent k/v store
  • Im­ple­ment fast_­mode
  • au­to mode with kv

Full Changel­og: v0.3.4...v0.4.0

New Project: Shortcodes

One thing leads to an­oth­er. I want­ed to learn a new lan­guage and chose Crys­tal. To prac­tice, I rewrote my stan­dard prac­tice pro­jec­t, Nico­let­ta, a stat­ic site gen­er­a­tor.

That brought to mind doit a task/­dataflow li­brary, which made me want to im­ple­ment some­thing sim­i­lar, so I wrote Croupi­er which went well, so I said "Why not write a more se­ri­ous SS­G, which is Nicol­i­no which I think would not be com­plete with­out a fea­ture from Niko­la which I stole from Hugo, called short­codes. So I had to write a short­code pars­er.

What are short­codes?

Sort of macros for markdown. You want to do a <figure> but markdown doesn't have it, so you do this:

{{% figure src="http://whatever" %}}

And you end up with a fig­ure tag in your doc­u­men­t.

That is done by pass­ing da­ta like that "s­r­c" ar­gu­ment and the con­text of the doc­u­ment you are writ­ing in­to a tem­plate, which ren­ders a piece of HTM­L, that's in­sert­ed where the short­code was and bob's your un­cle.

There are vari­ants, and de­tail­s, and sub­tleties, but that's the ba­sic idea.

The bad news was that I was not the au­thor of Niko­la's cur­rent short­code parser, that was some­one else, and I re­al­ly don't un­der­stant their code.

So I want­ed to write it from scratch.

I have been want­ing to learn ragel for a bit, let's say 10 years. It's a thing that takes a fi­nite state ma­chine de­scrip­tion in a DSL and turns it in­to a pars­er in the lan­guage you wan­t.

As long as you want one of the lan­guages it likes, which is not Crys­tal, so I used it to gen­er­ate it in C. And wrapped that in Crys­tal.

So, that's a very long way to say that I wrote a Short­code pars­er li­brary that can be used from Crys­tal and from C, and since it can be used from C, it can be used from pret­ty much any lan­guage.

It does­n't im­ple­ment the whole short­code "spec­i­fi­ca­tion" (which is not a re­al thing that ex­ist­s) but it im­ple­ments the ba­sic­s.

Now, I just need to use it in Nicol­i­no, and even­tu­al­ly make it bet­ter as need­ed.

BTW: Ragel rocks.

Exposing Code-Server on a VPN

I have all my com­put­ers in a Tailscale VPN which means I can see them all as if I were di­rect­ly con­nect­ed to them.

Re­cent­ly I got a new desk­top com­put­er which is, for my stan­dard­s, ridicu­lous­ly fast. So, it makes sense to de­vel­op things in it even when I am not in front of it.

Since VS Code is ba­si­cal­ly a web ap­p, the idea is to use code serv­er run­ning in it and ac­cess it via VP­N.

Did it work? OH YES.

Per­for­mance is prac­ti­cal­ly the same as run­ning VS code lo­cal­ly, sim­i­lar to us­ing GitHub codespaces.

Did it need any spe­cial con­fig?

Just one. To make Chrome stop com­plain­ing about "in­se­cure con­tex­t", it needs to be ac­cessed via HTTP­S, even when it's done over a com­plete­ly en­crypt­ed tun­nel.

Luck­i­ly, it's very, very easy.

So, just get caddy, and use this Caddyfile:

mindy.tailABCDEF.ts.net

reverse_proxy :8088

Yes. Two lines. The ABCDEF part will be dif­fer­ent for each tailscale net­work.

And that's it. Ac­cess it us­ing http­s://­mindy.­tail­ABCDE­F.t­s.net and ... that's al­l. I am shocked at how well it worked, and how easy it was.


Contents © 2000-2023 Roberto Alsina