Pinned toot
Pinned toot
Pinned toot

I wonder what the roads would be like if dangerous driving was treated the same way as attempted murder.

Motivation for this toot brought to you buy the massive arsehole with the noisy car that's been speeding up and down the road all day.

TIL about the `nl` command that can add pretty line numbers to what you pass through to it.

Best feeling is writing something that feels extremely fragile and watching it working perfectly.

Markdown parser in 7 lines of sed (cw regex, not screenreader friendly) 

Slightly more permanent version to reference: paste.sr.ht/~otheb/c062b1951e2

I feel like I just went to 1970 and back.

Show thread

Markdown parser in 7 lines of sed (cw regex, not screenreader friendly) 

Note: only does italics, bold, monospace, and links, but handles escaped characters and '<' and '>' in the output.

Show thread

Markdown parser in 7 lines of sed (cw regex, not screenreader friendly) 

s#<#\&lt;
s#>#\&gt;
s#([^\\])\*\*(([^*]|\\\*)+)\*\*#\1<b>\2</b>
s#([^\\])\*(([^*]|\\\*)+)\*#\1<i>\2</i>
s#([^\\])`(([^`]|\\`)+)`#\1<strong>\2</strong>
s#([^\\])\[(([^]]|\\])*)\]\((([^)]|\\\))*)\)#\1<a href="\4">\2</a>
s#\\(.)#\1#g

Use `tr` to swap "\n" for "\r" before and reverse after to have it work across lines. Example:

tr "\n" "\r" < file.md | sed -r -f thing.sed | tr "\r" "\n"

So the downside is that I can approximate my massive horrible program with one shell command.

The upside is that I can't get the shell command to handle escaped asterisks in the middle of stuff, so all the code wasn't entirely in vain.

Show thread

So uh... I just spent most of today fucking with writing a toy markdown parser (I know I have written one before) and decided that for my use case I could safely leave it only parsing bold/italic/monospace and links.

Then I re-implemented the entire ~150 line program in this single (messy) shell command...

... ffs.

Just realised I can comma separate values in case statements in so I don't need to have this everywhere:

case 1 : case 2 : case 3 : //....

So this was a nice little project that only took the morning and a bit.

Now I can use this to add syntax highlighting to any future blog posts I make.

git.sr.ht/~otheb/hl

If you wanted to create some kind of domain-specific language for encoding syntax highlighting information with plain text source code in a human-readable (and human-editable) manner, how (vaguely) would you want it to look?

Came up with a fancy error-handling thing today that I'm pretty proud of.

Idea behind it is that I don't want to need to pass a bunch of information down into every part of the compiler like filenames, so I want the next layer up to be able to add that information in.

So I have this template that provides all the needed stuff, then you just `mixin Errors` which is funny to read and it handles it all in the background.

paste.sr.ht/~otheb/cc8ebcfe9a6

Because D's syntax lets me put constructors and methods in structs, classes just feel like bloated structs with inheritance (ignoring how one is a value type and the other is a reference type).

So I've fallen into this weird pattern of using structs everywhere and going "eeeewww" every time I realise I need to use an interface or something.

So this all looks interesting: github.com/dlang/DIPs/pull/186

Hope this gets accepted because filling writeln with a bunch of variadic arguments is getting old.

terrible idea 

Service that can send you a bunch of fake emails on demand to obfuscate your inbox for when you're screen sharing and will need to open your email client and don't want people looking at your actual emails - also as a practical joke.

Like imagine being on a call and the guy on the other end opens up his email client and it's just "your giant dildo has been shipped!" and "signup confirmation for veryillegaldrugs.com" etc. down the whole screen.

Me: *opens window to let some cool air in*

8 million semi-articulated lorries: "oh boy what a perfect time for a rev match"

I *guess* I could do a bunch of fuckery with interfaces, but that feels pretty eh.

Show thread

One thing I don't know how I'd do with D that I wish I could do is have template-generic variables (if that arbitrary term makes any sense). Like say I have some template T(A) with that parameter, but the code I'm writing doesn't care what A is, I want to be able to have a variable of type T where I can put in any instance of it (trivial) BUT be able to put in *different* instances of it, like it could be storing a T!int and I could put in a T!float or something.

Would make loads of stuff way easier.

Not leaning so far back it's all theory mind, because then it just becomes opaque, but the parts where he explains broadly what stuff is doing are the most helpful, then the stuff describing the approach to actually implementing it gets so tangled up in the code that I can't really use it unless I'm just implementing Yet Another Lox Interpreter ™️

Show thread
Show more
Mastodon for Tech Folks

This Mastodon instance is for people interested in technology. Discussions aren't limited to technology, because tech folks shouldn't be limited to technology either!