19 votes

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 interesting about it? Are you having trouble with anything?

26 comments

  1. [4]
    Soptik
    Link
    I've made a debugger for sed! It's called desed (heh) and it's made in Rust. I was trying to get how this works for like fifth time and tried to mentally follow what sed does and what is in hold...

    I've made a debugger for sed! It's called desed (heh) and it's made in Rust.

    I was trying to get how this works for like fifth time and tried to mentally follow what sed does and what is in hold buffer and... I looked if there is a sed debugger out there. And it turned out there isn't (actually is, I can't search, but it's quite old). So I decided to brush up my Rust skills which have been getting quite rusty :) in the last few months.

    It turns out sed has a --debug flag which actually annotates what sed does in a nice way. But I wanted something a little bit more intuitive, so I hacked together TUI debugger in two days (and nights). It works by just parsing output of sed --debug, which is quite intuitive. Here's annotation of a simple sed program that decrements a positive number:

    decrement.sed
    SED PROGRAM:
      :decrement
      s/$/-;-90123456789/
      :decrement_inner_loop
      s/(.)-((-?.)*\\1)/\3\2/
      t decrement_inner_loop
      s/;.*//
    INPUT:   'number.txt' line 1
    PATTERN: 30
    COMMAND: :decrement
    COMMAND: s/$/-;-90123456789/
    MATCHED REGEX REGISTERS
      regex[0] = 2-2 ''
    PATTERN: 30-;-90123456789
    COMMAND: :decrement_inner_loop
    COMMAND: s/(.)-((-?.)*\\1)/\3\2/
    MATCHED REGEX REGISTERS
      regex[0] = 1-7 '0-;-90'
      regex[1] = 1-2 '0'
      regex[2] = 3-7 ';-90'
      regex[3] = 4-6 '-9'
    PATTERN: 3-9;-90123456789
    COMMAND: t decrement_inner_loop
    COMMAND: :decrement_inner_loop
    COMMAND: s/(.)-((-?.)*\\1)/\3\2/
    MATCHED REGEX REGISTERS
      regex[0] = 0-10 '3-9;-90123'
      regex[1] = 0-1 '3'
      regex[2] = 2-10 '9;-90123'
      regex[3] = 8-9 '2'
    PATTERN: 29;-90123456789
    COMMAND: t decrement_inner_loop
    COMMAND: :decrement_inner_loop
    COMMAND: s/(.)-((-?.)*\\1)/\3\2/
    PATTERN: 29;-90123456789
    COMMAND: t decrement_inner_loop
    COMMAND: s/;.*//
    MATCHED REGEX REGISTERS
      regex[0] = 2-15 ';-90123456789'
    PATTERN: 29
    END-OF-CYCLE:
    29
    

    So it turns out I can just parse it and load all states sed has ever been in into memory and then show them. This has a big advantage, besides that it's actually quite easy to do it, user can step the code both forwards and backwards. So you can setup breakpoint and then go back and see how did the code get to that breakpoint.

    The disadvantage is that sed doesn't tell me which line is it actually processing. So I had to implement a subset of sed in Rust (which wasn't without bugs, and I've only implemented like three commands), that I run in parallel while parsing the sed output, and pair each sed state with line number from source code.

    After I was done, I posted it to HN and Lobsters. I didn't expect anything, but I've actually gotten this to front page of Lobsters (which isn't any big achievement, if it isn't spam, everything makes it there) and, which I'm quite proud of, to the front page of HN! It was at the 10th place. So my git repo has over three hundred internet points. But most importantly, I've seen few people on twitter actually sharing it and they seemed to like it. It looks like I've actually made something that someone besides me will actually use sometimes. And that's the biggest achievement to me.

    11 votes
    1. [3]
      acdw
      Link Parent
      I saw this on those sites and I think it's so cool! I've been using a lot of awk lately, partially because I can't quite grok see, it's too terse and the pattern/hold space thing gets me. Your...

      I saw this on those sites and I think it's so cool! I've been using a lot of awk lately, partially because I can't quite grok see, it's too terse and the pattern/hold space thing gets me. Your program will hopefully help in that regard though!

      5 votes
      1. [2]
        Soptik
        Link Parent
        Thanks! I've been using mainly awk as well, sed was just too much for me to handle. This was actually written to force myself to learn sed properly :-) Btw this tutorial actually helped me a lot....

        Thanks! I've been using mainly awk as well, sed was just too much for me to handle. This was actually written to force myself to learn sed properly :-)

        Btw this tutorial actually helped me a lot. I still don't quite understand all the newline mess, but I can now write my own divide-by-two.sed, so I'm happy :-)

        3 votes
        1. acdw
          Link Parent
          Haha the newlines are so confusing. I wanted to write a sed command that would combine a line with the previous if it started with whitespace, and stop at the first blank line... Could not get...

          Haha the newlines are so confusing. I wanted to write a sed command that would combine a line with the previous if it started with whitespace, and stop at the first blank line... Could not get there! Just used awk.

          3 votes
  2. [4]
    Wren
    Link
    I'm starting work on a CLI resource monitor for Linux whose only real purpose is to look cooler than htop for unixporn-type purposes.

    I'm starting work on a CLI resource monitor for Linux whose only real purpose is to look cooler than htop for unixporn-type purposes.

    7 votes
    1. [4]
      Comment deleted by author
      Link Parent
      1. [3]
        unknown user
        Link Parent
        Is there a way to bring this stuff to my comfy Windows GUI-based existence without having to break out Linux for Dumbells? I, too, love the graphs and the imagery beyond what any rational need...

        Is there a way to bring this stuff to my comfy Windows GUI-based existence without having to break out Linux for Dumbells? I, too, love the graphs and the imagery beyond what any rational need would suggest.

        1 vote
        1. Turtle
          Link Parent
          Not a Windows user, so I don't know how convenient this is, but maybe look into WSL?

          Not a Windows user, so I don't know how convenient this is, but maybe look into WSL?

          2 votes
        2. [2]
          Comment deleted by author
          Link Parent
          1. unknown user
            Link Parent
            I want to! My laptop can't run Linux, for whatever reason. :( Tried three different distros: each runs perfectly off the Live USB, but completely fails to boot from the drive.

            Of course, you could always, you know... join the dark side.

            I want to! My laptop can't run Linux, for whatever reason. :(

            Tried three different distros: each runs perfectly off the Live USB, but completely fails to boot from the drive.

            1 vote
  3. [3]
    joplin
    Link
    When I was in my last semester of college I was working for the university's engineering network. One of the higher up full-time employees got an SGI Irix (I think?) workstation in. We all...

    When I was in my last semester of college I was working for the university's engineering network. One of the higher up full-time employees got an SGI Irix (I think?) workstation in. We all gathered around it one afternoon to see what kinds of cool things it could do. One of them was a simple 3D demo called "insect". It showed a little 6-legged computer generated bug that walked around a checkerboard what I recalled being a fairly realistic manner. I searched for a video of it but came up empty-handed.

    In any event, a friend found the source code for it on GitHub! It's written in IGL which is a proto-OpenGL graphics library. I converted it to Metal to run on my mac. (And I'll probably throw it up on my AppleTV later, too.) It was fascinating to see some of the old ways of doing "high end" graphics. For example, they precompute the lighting for every vertex when constructing the models rather than having it computed on the GPU. I of course moved that into a shader so I could have interactive lighting.

    The code was pre-C-89, so it was like reading olde English. I could understand it, but it just looked so weird. (K&R-style function arguments after the closing paren but before the function's opening brace, for example.) The other thing that stood out is how many things they did that we'd consider horrible engineering practices today. (I mean it was a demo so it's not like it mattered, it's just funny.) Global variables everywhere. The same variables declared in multiple places instead of making a header with externs. (Maybe they didn't exist back then? I'm not really sure.) Things like that. Overall, a really neat learning experience. Sort of like an archeological dig!

    5 votes
    1. [2]
      skybrian
      Link Parent
      I did an internship at a small graphics firm in college and it was similar. They used K&R C and ported their software to a variety of workstations. The one SGI machine they had was pretty cool....

      I did an internship at a small graphics firm in college and it was similar. They used K&R C and ported their software to a variety of workstations. The one SGI machine they had was pretty cool. They had several Apollos that had what seemed like a strange operating system.

      5 votes
      1. joplin
        Link Parent
        Oh man, we used the Apollos my first year of undergrad. They were very strange to me at the time, but they were also my first real exposure to using Unix so it may just be that I'd never used Unix...

        Oh man, we used the Apollos my first year of undergrad. They were very strange to me at the time, but they were also my first real exposure to using Unix so it may just be that I'd never used Unix before that. Everything we did with them was just some magic incantation to start the app we needed to use, with no understanding at all of how they actually worked. I think we were running Spice to do hardware simulations or something.

        2 votes
  4. acdw
    Link
    I'm trying to rewrite unk, my CMS -- still POSIX shell, for some godforsaken reason -- as grunk. So far, I'm just playing around with how far I can push sh past the red line, as it were.

    I'm trying to rewrite unk, my CMS -- still POSIX shell, for some godforsaken reason -- as grunk. So far, I'm just playing around with how far I can push sh past the red line, as it were.

    5 votes
  5. [6]
    unknown user
    Link
    password! Bringing mobile mode to it Soon™. Its code is scaffolding upon scaffolding, but it is very fun to work on. At the end of the day, after I'm done, I have a thing I can have fun using....

    password! Bringing mobile mode to it Soon™.

    Its code is scaffolding upon scaffolding, but it is very fun to work on. At the end of the day, after I'm done, I have a thing I can have fun using.

    I've also made a mistake early on of promising features I wouldn't deliver in the timeframe promised, if at all. Zen mode etc. got postponed because they were not fun to work on in the current state of the game. Going deep – improving the quality of the gameplay and the visuals – instead of going wide – adding features – drives me the most.

    Apologies if you aren't seeing the features you'd like to see on the shortlist. I'll be more careful about promising things in the future.

    Currently, all of the new features – the updated UI, the fancy UX, pausing mid-round, and the upcoming mobile mode – are on the main branch. It hasn't been uploaded to the website yet. If you want to play it, you can clone/download the repository and run index.html.

    4 votes
    1. [5]
      cfabbro
      Link Parent
      I'm sure most people will be pretty understanding in that regard, especially since it's not like anyone is paying you to deliver on said promises. ;)

      I've also made a mistake early on of promising features I wouldn't deliver in the timeframe promised, if at all.

      I'm sure most people will be pretty understanding in that regard, especially since it's not like anyone is paying you to deliver on said promises. ;)

      1 vote
      1. [4]
        unknown user
        Link Parent
        Basic creator responsibility matters all the same. You set expectations. If you don't fulfill those expectations, people – naturally – become disappointed: they wanted one thing and got another,...

        Basic creator responsibility matters all the same. You set expectations. If you don't fulfill those expectations, people – naturally – become disappointed: they wanted one thing and got another, worse one. If I don't understand this now, it will be too late to learn when I'm making something a hundred people, or a thousand people, look forward to. It's hard enough when you disappoint one person enjoying your works.

        I made a promise, and I failed to keep it. Dealing with the consequences is now on me.

        It's why I don't share projects that haven't yet reached maturity: either you can use it once it's out, or you can learn from where it failed.

        1 vote
        1. [3]
          cfabbro
          Link Parent
          That way madness lies. IMO unless you are being paid for your work, there is absolutely no creator responsibility to anyone else whatsoever, and even if/when you are being payed, your health...

          That way madness lies. IMO unless you are being paid for your work, there is absolutely no creator responsibility to anyone else whatsoever, and even if/when you are being payed, your health (mental and physical) matters significantly more than anyone else's potential disappointment.

          2 votes
          1. [2]
            unknown user
            Link Parent
            Oh, I'm not flaggelating myself over it. I find strong work ethics meaningful. Keeping in line with it is important to me. There's also the element of keeping my name clean: coming out with the...

            Oh, I'm not flaggelating myself over it.

            I find strong work ethics meaningful. Keeping in line with it is important to me.

            There's also the element of keeping my name clean: coming out with the mistakes, making sure people know who they're working with, apologizing when damage is done, even if its impact is ultimately negligent. When people hear my name, they invoke an image; I want that image to be, at the very least, "not full of shit".

            2 votes
            1. cfabbro
              Link Parent
              Ah okay, fair enough. That makes sense. So long as you're not beating yourself up too much about it. :)

              Ah okay, fair enough. That makes sense. So long as you're not beating yourself up too much about it. :)

              1 vote
  6. latkins
    Link
    I have long found that research management tools are underwhelming, for a variety of reasons, so started building my own. Plan is (initially) to directly integrate with open journals / preprint...

    I have long found that research management tools are underwhelming, for a variety of reasons, so started building my own. Plan is (initially) to directly integrate with open journals / preprint servers. I am mostly concerned with discovering good papers in a timely fashion, so I want to integrate some of the features of things like arxiv-sanity-preserver, as well as looking for papers on social media etc.

    4 votes
  7. baruchel
    Link
    I have been spending some time on my lockdown for coding a multi-player text idle game for IRC. See: https://pink-dragon.surge.sh which is now running and playable. The key idea behind it is...

    I have been spending some time on my lockdown for coding a multi-player text idle game for IRC. See: https://pink-dragon.surge.sh which is now running and playable.
    The key idea behind it is displaying a stream of text events as part of the game: new quests as well as several kinds of random events occur from time to time and the player has to watch for them in order to select useful informations.

    4 votes
  8. archwizard
    Link
    Currently, I'm redoing a lot of the work I did for the 2019 Holiday Hack Challenge. I want to write up my favorite challenge, but I didn't take very detailed notes, so I'm basically starting over...

    Currently, I'm redoing a lot of the work I did for the 2019 Holiday Hack Challenge. I want to write up my favorite challenge, but I didn't take very detailed notes, so I'm basically starting over on it, which is a ton of fun.

    Basically, I was given an encrypted document and the program used to encrypt it plus debugging symbols for the program (no source code). I ended up discovering a weakness in the key generation as well as the encryption algorithm, and wrote a python program to decrypt the document.

    Basically, it's a walk down memory lane plus applying my technical skills in a way that allows me to write about what I did, which is difficult, but fulfilling.

    3 votes
  9. Gyrfalcon
    Link
    For me it's been Docker everywhere. Using it at work in an attempt to move away from some bloated virtual machine images that have been in use for a very long time. Using it at home for my little...

    For me it's been Docker everywhere. Using it at work in an attempt to move away from some bloated virtual machine images that have been in use for a very long time. Using it at home for my little utility turned first web app that I'm deciding if I actually want to make. I really like what containerization can do, so it's been a neat time, just not writing much code at the moment.

    3 votes
  10. Ephemere
    Link
    I've been (very slowly) working on a standalone device to take a picture of the analemma of the sun. The general plan is to have a raspberry pi zero w and camera, powered by a solar panel and a...

    I've been (very slowly) working on a standalone device to take a picture of the analemma of the sun. The general plan is to have a raspberry pi zero w and camera, powered by a solar panel and a battery. Of course a pi zero w consumes far too much power to be supported solely by a solar panel, so I'm looking to have an Amtega328P wake it up once daily to take the picture, and copy/SSH it to a combination server elsewhere.

    I have a testbed in current operation using a similar solar panel+battery using a nodemcu board, though it is sampling once every ten minutes and seems to lack the juice to keep going through extended series of cloudy days. It's been fun to play with, at least.

    3 votes
  11. kari
    Link
    I’ve been working on PintOS in my OS class. Our last project on it was setting up virtual memory, which was tough. The synchronization was a bitch and we ended up not being able to pass all the...

    I’ve been working on PintOS in my OS class. Our last project on it was setting up virtual memory, which was tough. The synchronization was a bitch and we ended up not being able to pass all the test cases. I learned a ton about how virtual memory works in computers though!

    2 votes
  12. [2]
    eve
    Link
    I've been trying to learn some python so right now I'm making a very small program that simply prints out a setup and a punchline for a joke. I would also like to preface this by saying that I...

    I've been trying to learn some python so right now I'm making a very small program that simply prints out a setup and a punchline for a joke. I would also like to preface this by saying that I have a very hard time learning programming. Like yeah people can say all they want that python is easy to learn but I fucking suck at learning coding. It's hard to find stuff that explains it in a way I understand? I'm also shit at math which isn't necessarily a total prerequisite for programming but it certainly helps. But I am making slow, slow, slow progress with the help of my SO. But to be honest sometimes he doesn't help and I get more confused or the way he explains things makes no sense :')

    2 votes
    1. [2]
      Comment deleted by author
      Link Parent
      1. eve
        Link Parent
        Thank you for the recommendation!! I'll look into it! And that's a big bonus with tildes, so many people are into programming and tech, if I ever get stuck I'm definitely comfortable posting here...

        Thank you for the recommendation!! I'll look into it! And that's a big bonus with tildes, so many people are into programming and tech, if I ever get stuck I'm definitely comfortable posting here and asking for help! I think the biggest thing for me is figuring out what I want to do with coding for fun and not just using it to buff up my resume and convince tech companies I'm worth the hire lol.

        2 votes