• Activity
  • Votes
  • Comments
  • New
  • All activity
    1. What programming/technical projects have you been working on?

      This is a recurring post to discuss programming or other technical projects that we've been working on. Tell us about one of your recent projects, either at work or personal projects. What's...

      This is a recurring post to discuss programming or other technical projects that we've been working on. Tell us about one of your recent projects, either at work or personal projects. What's interesting about it? Are you having trouble with anything?

      15 votes
    2. unique types in TypeScript using "branding"

      I'm doing a bit of Typescript programming and started using zod for input validation. It has a fair number of convenience methods, one of which is brand(). This creates a unique type, much like...

      I'm doing a bit of Typescript programming and started using zod for input validation. It has a fair number of convenience methods, one of which is brand(). This creates a unique type, much like the newtype operator in some languages. This is despite TypeScript not having unique types by default; TypeScript implements structural typing.

      The technique used to implement unique types has been known for a long time, but it's new to me. You can declare a type with an extra field that doesn't really exist.

      There seem to be several variations on how to do this. They seem to be mostly equivalent, but the ergonomics might differ. (Some might have better compiler errors that others?) The basic requirement is that the imaginary field doesn't get in the way in normal use, but it's incompatible with other types, causing a compiler error if they're mixed.

      One way goes like this:

      declare const brand: unique symbol;
      
      type Brand<T, TBrand extends string> = T & {
        [brand]: TBrand;
      }
      

      It can be used to declare branded types like this:

      type TopicId = Brand<bigint, "TopicId">;
      
      const myTopicId = 123n as TopicId;
      

      This trick relies on the fact that TypeScript's type checking is unsound. We can lie to the type checker. Intersecting T (in this case, bigint) creates a subtype of bigint with an imaginary field. The field's type is declared so the field requires a specific string, so it's going to be incompatible with just about any other type, unless you use Brand to give it the same name on purpose. (The field doesn't actually exist and no string is actually stored there.)

      To create a TopicId value, you use "as" to explicitly downcast bigints to TopicId's. Then you can use them just like a bigint, except that there will be compile errors if you use them wrong.

      A less strict approach is to make the imaginary field optional, described here as "flavoring" but I don't think that's in common use? Then you could assign bignums without doing a cast, but the type is still incompatible with other branded type. This reminds me of how types work in Go.

      11 votes
    3. What programming/technical projects have you been working on?

      This is a recurring post to discuss programming or other technical projects that we've been working on. Tell us about one of your recent projects, either at work or personal projects. What's...

      This is a recurring post to discuss programming or other technical projects that we've been working on. Tell us about one of your recent projects, either at work or personal projects. What's interesting about it? Are you having trouble with anything?

      9 votes
    4. Day 19: Aplenty

      Today's problem description: https://adventofcode.com/2023/day/19 Please post your solutions in your own top-level comment. Here's a template you can copy-paste into your comment to format it...

      Today's problem description: https://adventofcode.com/2023/day/19

      Please post your solutions in your own top-level comment. Here's a template you can copy-paste into your comment to format it nicely, with the code collapsed by default inside an expandable section with syntax highlighting (you can replace python with any of the "short names" listed in this page of supported languages):

      <details>
      <summary>Part 1</summary>
      
      ```python
      Your code here.
      ```
      
      </details>
      
      7 votes
    5. Just got a Microsoft Surface Pro 9, need help

      It's been years since I've had to use a an actual computer for anything serious and I want to regain my literacy with them. The height of my computer usage was the Windows XP/Vista era. I got it...

      It's been years since I've had to use a an actual computer for anything serious and I want to regain my literacy with them. The height of my computer usage was the Windows XP/Vista era. I got it because I wanted to throw myself into a couple of different programming/coding courses.
      I chose the Surface Pro because of the detachable keyboard/stylus setup and the fact that I don't have a good way to set up a desktop computer. Also I've always fantasized about being able to do work in a coffee shop or in a comfy chair by a lake lol.
      Can anyone share some tips/tricks that might be useful to me? Anything from hotkeys, task management related things, or just general quality of life things I should know about would be super helpful. I'm so used to smartphones being able to do everything and feel like I'm a little in over my head here. Thanks in advance.

      12 votes
    6. Is there a programming language that brings you joy?

      Just for a moment, forget all of the technical pros and cons, the static typing, just-in-time compilation, operator overloading, object orientation to the max... Is there a programming language...

      Just for a moment, forget all of the technical pros and cons, the static typing, just-in-time compilation, operator overloading, object orientation to the max...

      Is there a programming language that you've just found to be... fun?

      Is there one that you'd pick above all else for personal or company projects, if you had your druthers, because you would simply be so excited to use it?

      And then, is there something missing in that "fun" language that's preventing it from actually becoming a reality (i.e. small community, lack of libraries, maintenance ended in the 80s, etc.)?

      50 votes
    7. The morality of using AI-generated art in my web app

      Hey, good people of Tildes! I'm building a self-help web app, a small part of which I'd like to involve some pixel pets. I like pixel art and it'd be great if I could create some. Though, the...

      Hey, good people of Tildes!

      I'm building a self-help web app, a small part of which I'd like to involve some pixel pets. I like pixel art and it'd be great if I could create some. Though, the truth is, I can't draw for shit, I have little to no imagination, and I'm afraid even if I put the time and effort into it, I still may not produce something I'd call good enough to put on the website. I also lack the motivation to spend a lot of time learning how to create good pixel art, as I only need it for this project.

      I thought about paying some professional(s) to do it but that would probably break the bank for me, as I want to offer the users a lot of pixel pet options, which brings us to what I guess is the only remaining option.

      I found some services that offer AI-generated pixel art. This one in particular looks like what I'm looking for and also offers animations. While watching a demo of it on YouTube, I noticed a few comments voicing concern about the ethics of selling art that's generated using models trained off of unpaid artists' work. While this is not a new topic, I admittedly hadn't given it much thought before, as I've never used, or planned to use AI-generated art in a meaningful capacity.

      While I'm not sure whether it changes much, for what it's worth, I should note that my web app is going to be free, open-source, and ad-free forever.

      What are your thoughts? Also, I'd love to know if there are options that I missed!

      26 votes
    8. Day 25: Snowverload

      Today's problem description: https://adventofcode.com/2023/day/25 Please post your solutions in your own top-level comment. Here's a template you can copy-paste into your comment to format it...

      Today's problem description: https://adventofcode.com/2023/day/25

      Please post your solutions in your own top-level comment. Here's a template you can copy-paste into your comment to format it nicely, with the code collapsed by default inside an expandable section with syntax highlighting (you can replace python with any of the "short names" listed in this page of supported languages):

      <details>
      <summary>Part 1</summary>
      
      ```python
      Your code here.
      ```
      
      </details>
      
      8 votes
    9. Day 24: Never Tell Me The Odds

      Today's problem description: https://adventofcode.com/2023/day/24 Please post your solutions in your own top-level comment. Here's a template you can copy-paste into your comment to format it...

      Today's problem description: https://adventofcode.com/2023/day/24

      Please post your solutions in your own top-level comment. Here's a template you can copy-paste into your comment to format it nicely, with the code collapsed by default inside an expandable section with syntax highlighting (you can replace python with any of the "short names" listed in this page of supported languages):

      <details>
      <summary>Part 1</summary>
      
      ```python
      Your code here.
      ```
      
      </details>
      
      6 votes
    10. Does Linux From Scratch actually teach you anything?

      Two hours ago I randomly thought "hey, why not do LFS?", so I opened my laptop and started following the book. I've heard a lot of people say that LFS is great for learning how a Linux system...

      Two hours ago I randomly thought "hey, why not do LFS?", so I opened my laptop and started following the book. I've heard a lot of people say that LFS is great for learning how a Linux system works. However, so far it's just been a guide on how to compile different software and what autoconfig flags to use. I thought that maybe further chapters will have more information on how things work, but it seems like they all just contain a one-line description of a program and compilation instructions.

      If anyone here has done LFS, did you actually learn anything from it? Is it worth spending more time on?

      19 votes
    11. Day 23: A Long Walk

      Today's problem description: https://adventofcode.com/2023/day/23 Please post your solutions in your own top-level comment. Here's a template you can copy-paste into your comment to format it...

      Today's problem description: https://adventofcode.com/2023/day/23

      Please post your solutions in your own top-level comment. Here's a template you can copy-paste into your comment to format it nicely, with the code collapsed by default inside an expandable section with syntax highlighting (you can replace python with any of the "short names" listed in this page of supported languages):

      <details>
      <summary>Part 1</summary>
      
      ```python
      Your code here.
      ```
      
      </details>
      
      5 votes
    12. Day 16: The Floor Will Be Lava

      Today's problem description: https://adventofcode.com/2023/day/16 Please post your solutions in your own top-level comment. Here's a template you can copy-paste into your comment to format it...

      Today's problem description: https://adventofcode.com/2023/day/16

      Please post your solutions in your own top-level comment. Here's a template you can copy-paste into your comment to format it nicely, with the code collapsed by default inside an expandable section with syntax highlighting (you can replace python with any of the "short names" listed in this page of supported languages):

      <details>
      <summary>Part 1</summary>
      
      ```python
      Your code here.
      ```
      
      </details>
      
      9 votes
    13. I want to learn Android (with Kotlin) ... should I focus on Jetpack or the old XML style?

      I am an experienced programmer (mostly M$ stack -- C#, etc). I started learning mobile Android development a few months ago, learning both Kotlin and the larger Android development environment at...

      I am an experienced programmer (mostly M$ stack -- C#, etc).

      I started learning mobile Android development a few months ago, learning both Kotlin and the larger Android development environment at the same time. I got bogged down in tutorials and guides, because half of them teach Jetpack Compose methodology and half teach XML layout ... and, often enough, don't bother to mention which method they're using.

      Which should I learn first? I am initially interested in learning Android dev for my own hobby/fun/side projects, but I would--ultimately--like to be able to put "Android developer" on my resume.

      Jetpack definitely looks better, more modern, more OO, and I expect it will eventually become the new standard ... but that could still be many years down the road. Also, while it might be "better"--especially for larger projects--it also smells more complicated.

      So, ultimately, I guess I should learn both if I actually intend to become an Android dev ... but I should definitely get comfortable with one, first ... so, which one?

      11 votes
    14. Day 21: Step Counter

      Today's problem description: https://adventofcode.com/2023/day/21 Please post your solutions in your own top-level comment. Here's a template you can copy-paste into your comment to format it...

      Today's problem description: https://adventofcode.com/2023/day/21

      Please post your solutions in your own top-level comment. Here's a template you can copy-paste into your comment to format it nicely, with the code collapsed by default inside an expandable section with syntax highlighting (you can replace python with any of the "short names" listed in this page of supported languages):

      <details>
      <summary>Part 1</summary>
      
      ```python
      Your code here.
      ```
      
      </details>
      
      6 votes
    15. Day 2: Cube Conundrum

      Today's problem description: https://adventofcode.com/2023/day/2 Please post your solutions in your own top-level comment. Here's a template you can copy-paste into your comment to format it...

      Today's problem description: https://adventofcode.com/2023/day/2

      Please post your solutions in your own top-level comment. Here's a template you can copy-paste into your comment to format it nicely, with the code collapsed by default inside an expandable section with syntax highlighting (you can replace python with any of the "short names" listed in this page of supported languages):

      <details>
      <summary>Part 1</summary>
      
      ```python
      Your code here.
      ```
      
      </details>
      
      12 votes
    16. Cheap options(?) to run local AI models

      I have been having fun learning about generative AI. All in the cloud -- I got some models on hugging face to work, tried out Colab Pro, and found another cloud provider that runs SD models...

      I have been having fun learning about generative AI. All in the cloud -- I got some models on hugging face to work, tried out Colab Pro, and found another cloud provider that runs SD models (dreamlook.ai if anyone is interested).

      It's got me curious about trying to run something locally (mostly stable diffusion/dreambooth, possibly ollama).
      I currently have a Thinkpad T490 with 16 gb ram and the base-level graphics card. I haven't actually tried to run anything locally, on the assumption that it would be extremely slow. I saw that you can get an external GPU, though I also saw some reports of headaches trying to get external GPUs up and running.

      I am curious what a workstation might cost that could do a reasonable job running local models. I am not a huge gamer or have any other high performance needs that are not currently served by the Thinkpad; not sure I can justify a $3000 workstation just to make a few jpgs.

      I would be happy to buy something secondhand, like if there was a good source of off-lease workstations.

      Alternatively-- if you have a similar computer to the T490 and do run models locally, what sort of performance is reasonable to expect? Would it be enough to buy some more RAM for this laptop?

      Thanks for any advice!

      13 votes
    17. Day 20: Pulse Propagation

      Today's problem description: https://adventofcode.com/2023/day/20 Please post your solutions in your own top-level comment. Here's a template you can copy-paste into your comment to format it...

      Today's problem description: https://adventofcode.com/2023/day/20

      Please post your solutions in your own top-level comment. Here's a template you can copy-paste into your comment to format it nicely, with the code collapsed by default inside an expandable section with syntax highlighting (you can replace python with any of the "short names" listed in this page of supported languages):

      <details>
      <summary>Part 1</summary>
      
      ```python
      Your code here.
      ```
      
      </details>
      
      6 votes
    18. What programming/technical projects have you been working on?

      This is a recurring post to discuss programming or other technical projects that we've been working on. Tell us about one of your recent projects, either at work or personal projects. What's...

      This is a recurring post to discuss programming or other technical projects that we've been working on. Tell us about one of your recent projects, either at work or personal projects. What's interesting about it? Are you having trouble with anything?

      11 votes
    19. Day 14: Reflector Dish

      Today's problem description: https://adventofcode.com/2023/day/14 Please post your solutions in your own top-level comment. Here's a template you can copy-paste into your comment to format it...

      Today's problem description: https://adventofcode.com/2023/day/14

      Please post your solutions in your own top-level comment. Here's a template you can copy-paste into your comment to format it nicely, with the code collapsed by default inside an expandable section with syntax highlighting (you can replace python with any of the "short names" listed in this page of supported languages):

      <details>
      <summary>Part 1</summary>
      
      ```python
      Your code here.
      ```
      
      </details>
      
      9 votes
    20. Day 15: Lens Library

      Today's problem description: https://adventofcode.com/2023/day/15 Please post your solutions in your own top-level comment. Here's a template you can copy-paste into your comment to format it...

      Today's problem description: https://adventofcode.com/2023/day/15

      Please post your solutions in your own top-level comment. Here's a template you can copy-paste into your comment to format it nicely, with the code collapsed by default inside an expandable section with syntax highlighting (you can replace python with any of the "short names" listed in this page of supported languages):

      <details>
      <summary>Part 1</summary>
      
      ```python
      Your code here.
      ```
      
      </details>
      
      8 votes
    21. Day 18: Lavaduct Lagoon

      Today's problem description: https://adventofcode.com/2023/day/18 Please post your solutions in your own top-level comment. Here's a template you can copy-paste into your comment to format it...

      Today's problem description: https://adventofcode.com/2023/day/18

      Please post your solutions in your own top-level comment. Here's a template you can copy-paste into your comment to format it nicely, with the code collapsed by default inside an expandable section with syntax highlighting (you can replace python with any of the "short names" listed in this page of supported languages):

      <details>
      <summary>Part 1</summary>
      
      ```python
      Your code here.
      ```
      
      </details>
      
      8 votes
    22. Have you tried Fossil scm, an alternative to git?

      Have any of you tried out fossil as an alternative to git? I have been using it for about a week, and I think I am in love. I have used git for years, since having some sort of source control is...

      Have any of you tried out fossil as an alternative to git? I have been using it for about a week, and I think I am in love. I have used git for years, since having some sort of source control is absolutely essential in programming. But I never liked git or felt comfortable using it. Within a week of messing with fossil, I feel like I understand it and can use it without a guide or external tools. It also has an issue tracker, forums, and a wiki built in.

      Fossil Versus Git

      I recommend reading all of that, especially section 2.5. Their description of cathedral style development lines up much more closely to everything I have worked on than git's bazaar style. Another thing I love is the ability to have the same repo open in multiple different folders at the same time. Basically everything about fossil lines up much more closely with what I think a source control program should be, at least for my use.

      24 votes
    23. Day 17: Clumsy Crucible

      Today's problem description: https://adventofcode.com/2023/day/17 Please post your solutions in your own top-level comment. Here's a template you can copy-paste into your comment to format it...

      Today's problem description: https://adventofcode.com/2023/day/17

      Please post your solutions in your own top-level comment. Here's a template you can copy-paste into your comment to format it nicely, with the code collapsed by default inside an expandable section with syntax highlighting (you can replace python with any of the "short names" listed in this page of supported languages):

      <details>
      <summary>Part 1</summary>
      
      ```python
      Your code here.
      ```
      
      </details>
      
      10 votes
    24. File structure difference between NAS and cloud storage

      I have a NAS with a ton of photos and documents that have remained untouched for around 6 years. I uploaded all that stuff to OneDrive. Tidied it up and kept using OneDrive mostly. But I also sent...

      I have a NAS with a ton of photos and documents that have remained untouched for around 6 years. I uploaded all that stuff to OneDrive. Tidied it up and kept using OneDrive mostly. But I also sent stuff to the NAS. They have diverged.

      I'm thinking about ways of restructuring/sorting my NAS to match my OneDrive so that I can then sync the two. I thought about making a python script that would just match on file names and move them to the correct location.

      Figured before I did I'd ask if anyone else had any other suggestions

      12 votes
    25. What programming/technical projects have you been working on?

      This is a recurring post to discuss programming or other technical projects that we've been working on. Tell us about one of your recent projects, either at work or personal projects. What's...

      This is a recurring post to discuss programming or other technical projects that we've been working on. Tell us about one of your recent projects, either at work or personal projects. What's interesting about it? Are you having trouble with anything?

      10 votes
    26. What programming/technical projects have you been working on?

      This is a recurring post to discuss programming or other technical projects that we've been working on. Tell us about one of your recent projects, either at work or personal projects. What's...

      This is a recurring post to discuss programming or other technical projects that we've been working on. Tell us about one of your recent projects, either at work or personal projects. What's interesting about it? Are you having trouble with anything?

      16 votes
    27. Day 12: Hot Spring

      Today's problem description: https://adventofcode.com/2023/day/12 Please post your solutions in your own top-level comment. Here's a template you can copy-paste into your comment to format it...

      Today's problem description: https://adventofcode.com/2023/day/12

      Please post your solutions in your own top-level comment. Here's a template you can copy-paste into your comment to format it nicely, with the code collapsed by default inside an expandable section with syntax highlighting (you can replace python with any of the "short names" listed in this page of supported languages):

      <details>
      <summary>Part 1</summary>
      
      ```python
      Your code here.
      ```
      
      </details>
      
      9 votes
    28. Day 13: Point of Incidence

      Today's problem description: https://adventofcode.com/2023/day/13 Please post your solutions in your own top-level comment. Here's a template you can copy-paste into your comment to format it...

      Today's problem description: https://adventofcode.com/2023/day/13

      Please post your solutions in your own top-level comment. Here's a template you can copy-paste into your comment to format it nicely, with the code collapsed by default inside an expandable section with syntax highlighting (you can replace python with any of the "short names" listed in this page of supported languages):

      <details>
      <summary>Part 1</summary>
      
      ```python
      Your code here.
      ```
      
      </details>
      
      8 votes