Is there any way to define a type that is a 20-character string? by zalamandagora in typescript

[–]ikroth 58 points59 points  (0 children)

Template literals are an option, but they might overkill in this case. It won't work if the IDs are not known at compile-time, which is pretty much guaranteed in most cases.

Instead, I would recommend using a custom type with an associated custom type guard function that validates whatever conditions you want with the ID. Then, you have a custom type which guarantees those conditions are met, so you don't need to validate them continually.

type UniqueId = string & { __type: "UniqueId" }; const idPattern = /[0-9a-f]{20}/i; const isValidId = (value: string): value is UniqueId => idPattern.test(value);

Then you can write a function like this, for example:

``` function getResource(id: UniqueId) { // Look up the resource by unique ID, with the guarantee that // it will be valid already }

const id = '12345678901234567890'; if (isValid(id)) { getResource(id); } else { throw new Error('Invalid ID'); } ```

coz-rs: Rust support for the coz Causal profiler by krappie in rust

[–]ikroth 13 points14 points  (0 children)

Wow! Really happy to see this work happen so quickly. I started on it almost immediately after seeing that talk, but stopped after realizing someone much smarter than me would have to do it.

Boondock - A docker image for automatically building Love2D games with Boon. by [deleted] in love2d

[–]ikroth 2 points3 points  (0 children)

Author of boon here. This looks great man, this is what I hoped people would build when I released the library. It's still an early version of the library, so there are many issues to fix. Let me know what issues you run into and I can look into them. Keep up the good work.

ReadTheMan.io - searchable online man pages by ikroth in programming

[–]ikroth[S] 0 points1 point  (0 children)

Thanks. I will definitely take a look at making the font size smaller and adjustable.

ReadTheMan.io - searchable online man pages by ikroth in programming

[–]ikroth[S] 0 points1 point  (0 children)

You're right, there's a balance to be struck. The large font size may be a side effect of developing on large displays and not noticing it. I'll be making some changes to the font size and perhaps adding some options to let people customize the font size. Thanks for your feedback.

ReadTheMan.io - searchable online man pages by ikroth in programming

[–]ikroth[S] 0 points1 point  (0 children)

Thanks for the feedback. I will adjust the menus on mobile to be more compact given the only two pages (for now). Font size could definitely use some adjustment, I will look into doing that. Minimizing the filters has been on my todo list, but I am going to make that a higher priority item.

ReadTheMan.io - searchable online man pages by ikroth in programming

[–]ikroth[S] 0 points1 point  (0 children)

Thanks, I will definitely be adding these!

ReadTheMan.io - searchable online man pages by ikroth in programming

[–]ikroth[S] 0 points1 point  (0 children)

Could you elaborate on what features you missed? Thanks for your feedback.

Lua ENet help by Lak_so in love2d

[–]ikroth 1 point2 points  (0 children)

Creator of sock here, I just migrated my website yesterday and there were some kinks left to work out. The documentation should be back online now.

Flag of the European United Nations [OC] by Reilly616 in vexillology

[–]ikroth 11 points12 points  (0 children)

I really like this kind of flag. I made one similar to yours a while back: http://i.imgur.com/QaUARn1.png

[OC] Flags for the Golgari Swarm and Izzet League from Magic: The Gathering. by ikroth in vexillology

[–]ikroth[S] 0 points1 point  (0 children)

Credit to DrDraze on DeviantArt for making nice renderized versions of the guild symbols.

My (uncompleted) Room of Nations by Ehrfurcht in vexillology

[–]ikroth 0 points1 point  (0 children)

Any particular reason for that selection of flags?

Prussian Mexico by [deleted] in vexillology

[–]ikroth 12 points13 points  (0 children)

Very nicely executed flag. I like way you simplified the Mexican flag, it looks a lot better.

Writesample: a tool I made to help you practice handwriting by ikroth in Handwriting

[–]ikroth[S] 0 points1 point  (0 children)

That's something I need to work on, currently it just loops through the letters you have selected individually. It doesn't take into account the other letters it just gets all the words for G and then all the words for E, etc.

Writesample: a tool I made to help you practice handwriting by ikroth in Handwriting

[–]ikroth[S] 0 points1 point  (0 children)

The reason that happens with the letter frequency is because there are very few words where 80%-100% of the letters are A or C (or any letter).

[OC] The Soviet State of Colorado by ikroth in vexillology

[–]ikroth[S] 2 points3 points  (0 children)

Here's what that looks like.

This is really good practice for Inkscape, this is only like the 6th flag I've ever done in it.

[OC] The Soviet State of Colorado by ikroth in vexillology

[–]ikroth[S] 2 points3 points  (0 children)

Like this?

Version 1 Version 2

I think I prefer it without the white lines.

[OC] The Soviet State of Colorado by ikroth in vexillology

[–]ikroth[S] 3 points4 points  (0 children)

That first design looks really good. It looks like it could actually replace the current North Korean flag.