11 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?

15 comments

  1. [3]
    mono
    Link
    I've been working on my bespoke IoT smart lighting system, based around the ESP32 microcontroller. I've been dabbling with it off and on for years, but I recently decided to start over from...

    I've been working on my bespoke IoT smart lighting system, based around the ESP32 microcontroller. I've been dabbling with it off and on for years, but I recently decided to start over from scratch, motivated by a desire to get rid of any and all dependency on the Arduino platform. I've been messing around with Arduinos for awhile, but my feelings toward it have really soured the past couple of years.

    I wouldn't hesitate to say my project is over-engineered, but I'm really learning a fuck-ton about embedded development and C++ (I'm primarily a web dev). I designed my own RGB LED strip driver circuits and had the PCBs manufactured, and they work great. The firmware is built on the official ESP32 development framework. I've got it working nicely in my IDE of choice, including the JTAG/OCD debugger (truly a godsend). The code - mostly minimal abstractions over the ESP32 framework that are more comfortable for me, as someone used to higher level languages - is organized into decoupled components and unit tested (fuck yeah).

    Even though I almost certainly won't ever utilize it as much to justify the work I'm putting into it, I've been working on a custom encoding scheme for the data communication that is (ideally) both fully featured and simple enough to decode and parse at as high a "frame" rate and as close to real-time as I can manage. There've been a dozen iterations, but the solution I'm at now I think is as good as I think it'll get. Basically, I make sure the the data is encoded exactly as the data structures are. The data is dumped into one of a rotating pool of buffers by the socket and it's queued for parsing on the ESP32's second core. I just cast the data inside the buffer as whatever structure the header byte determines. I don't have to do any manual arithmetic to decode or make intermediate copies of the data. I'm not experienced enough with C/C++ to say whether or not it's a clever or good solution, but I certainly feel clever for figuring out I could do it like that.

    All in all, even if the project is really unnecessary, I'm glad to be expanding my boundaries into lower-level software and proud of myself for striving for more professional standards in my personal projects.

    6 votes
    1. [2]
      helloworld
      Link Parent
      This sounds amazing! Do you have a repo somewhere I can refer?

      This sounds amazing! Do you have a repo somewhere I can refer?

      2 votes
      1. mono
        Link Parent
        Thanks! It's private for now, but I will work on changing that and will let you know when I do. In the meantime, if there are any specific ESP32 questions I can help you with, feel free to PM me!

        Thanks! It's private for now, but I will work on changing that and will let you know when I do. In the meantime, if there are any specific ESP32 questions I can help you with, feel free to PM me!

        3 votes
  2. [5]
    jgb
    Link
    I have been working on a lightweight imageboard. Right now it uses no Javascript at all, and although I may add a little in the future the intention is for the software to produce sites that are...

    I have been working on a lightweight imageboard.
    Right now it uses no Javascript at all, and although I may add a little in the future the intention is for the software to produce sites that are fully usable without Javascript and even in a text mode browser.
    https://github.com/jgbyrne/plainchant

    3 votes
    1. [4]
      krg
      Link Parent
      dope. I’m definitely gonna look through the code for some inspiration when I get home! by the way, at what point do you decide “okay, I got enough done to put this into a public Git repo.” ?

      dope. I’m definitely gonna look through the code for some inspiration when I get home!

      by the way, at what point do you decide “okay, I got enough done to put this into a public Git repo.” ?

      2 votes
      1. [3]
        jgb
        Link Parent
        I might be misremembering but I think I pushed to a public repo right from the initial commit, which as you can see is really nothing particularly substantial. If I was a 'bigger name' developer I...

        I might be misremembering but I think I pushed to a public repo right from the initial commit, which as you can see is really nothing particularly substantial. If I was a 'bigger name' developer I might approach this differently but to be honest I assume that a near negligible number of people are looking at my GitHub activity so I don't really worry too much about keeping up appearances. I might have to revise that attitude at some point as I am starting to embrace the 'social' side of GitHub a little more. That said, I think it's a little silly to be ultra self-conscious about this stuff because what project doesn't start out with a few half baked ideas scratched out in code :-)

        2 votes
        1. [2]
          netstx
          Link Parent
          Nice job. I wonder if you could integrated memcached after you switch to Postgres. That'd make it snappy and not rely on database so much. Thoughts?

          Nice job. I wonder if you could integrated memcached after you switch to Postgres. That'd make it snappy and not rely on database so much. Thoughts?

          1 vote
          1. jgb
            Link Parent
            I would love to learn about using tools like memcached (I am quite new to full-stack web development) but to be honest I think that it would not provide a huge speedup for the project as it is...

            I would love to learn about using tools like memcached (I am quite new to full-stack web development) but to be honest I think that it would not provide a huge speedup for the project as it is architected right now. As it stands, all the database-dependent pages are statically rendered and cached in memory, so there really are not that many database reads.

            2 votes
  3. Odpop
    Link
    Waiting for my exams to be over, will finally be free on 4th September. Have been stuck in tutorial hell for Django for a quite a while now; need to better my SQL, Python is solid, and am learning...

    Waiting for my exams to be over, will finally be free on 4th September. Have been stuck in tutorial hell for Django for a quite a while now; need to better my SQL, Python is solid, and am learning Javascript more for some basic frontend design with React and learning MERN. Might be split out a bit too much since I'm not really a programmer, have a non-CS major and have to focus on Stats on the side as well, but eh its all good fun.

    PS: I need to find a developer mentor from somewhere.. no idea where tho since all the good programmers in my country end up learning for better pay in Europe/America.

    2 votes
  4. krg
    (edited )
    Link
    Continuing to futz around with this little project. an early, naïve implementation of a polynomial data-structure. // the beginnings of a Polynomial. // I'll start with a vector of coefficents, //...

    Continuing to futz around with this little project.

    an early, naïve implementation of a polynomial data-structure.
    // the beginnings of a Polynomial.
    // I'll start with a vector of coefficents,
    // with the index of each coefficient
    // being equivalent to it's degree.
    //// NOTE: this assumes a single variable equation.
    #[derive(Debug)]
    struct Polynomial {
    	coefficients: Vec<f64>, 
    }
    
    impl Polynomial {
    	fn new(coefficients: Vec<f64>) -> Polynomial {
    		Polynomial { coefficients }
    	}
    
    	// given a single variable, solves the polynomial
    	fn solve(&self, x: f64) -> f64 {
    		let coeffs = &self.coefficients;
    		
    		coeffs.into_iter()
    			.enumerate()
    			.map(|(i, c)| c * x.powi(i.try_into().unwrap()))
    			.sum()
    	}
    
    	fn derivative(&self) -> Polynomial {
    		let coeffs = &self.coefficients;
    
    		// if the length is 1, the coefficient is constant.
    		// thus, the derivative is 0 (i think).
    		if coeffs.len() <= 1 {
    			return Polynomial {
    				coefficients: vec![0.0],
    			};
    		}
    
    		Polynomial::new(
    			coeffs[1..].into_iter()
    				.enumerate()
    				.map(|(i, c)| c * (i as f64 + 1.0))
    				.collect()
    		)
    	}
    }
    
    printing a single-variable polynomial.
    impl std::fmt::Display for Polynomial {
    	// writes "cx^i", where 'c' is the coefficent
    	// and 'i' is the degree.
    	// TODO: figure out a way to get superscript degrees,
    	// instead of the caret. 
    	fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
    		let coeffs = &self.coefficients;
    		let mut s = String::new();
    
    		for (i, c) in coeffs.into_iter().enumerate() {
    			s.push_str(&c.to_string());
    
    			if i > 0 {
    				s.push_str("x");
    
    				if i > 1 {
    					s.push_str("^");
    					s.push_str(&i.to_string());		
    				}
    			}
    				
    			if i < coeffs.len() - 1 {
    				s.push_str(" + ");
    			}
    		}
    		
    		write!(f, "{}", s)
    	}
    }
    

    If I continue writing out a polynomial along those lines, I think I can store a vector of vectors for variables and their degrees. E.g. ((1, 2, 4), (1, 3, 5), (2, 3, 4)) where the first variable (say, "x") exists in the 1st, 2nd, and 4th degrees, etc. So... the solve function would have to accept a vector of values that correspond with the length of the first dimension of the vars+degs vector, check to see at which degree that variable exists, and calculate accordingly.

    My first thoughts on how to do this, anyway. I'm sure (hope) I'll think of a better way to structure the data. But, it seems to work as intended at the moment, which is nice.

    I'll also think of a way to rewrite fmt in a more functional-style. But, again, works as intended.

    2 votes
  5. [3]
    helloworld
    Link
    I am trying out simple video game design with pygame, but finding it hard to wrap my head around the domain and terminology. I am referring to a couple of tutorials on YouTube, but any suggestions...

    I am trying out simple video game design with pygame, but finding it hard to wrap my head around the domain and terminology. I am referring to a couple of tutorials on YouTube, but any suggestions welcome!

    1 vote
    1. [2]
      Comment deleted by author
      Link Parent
      1. helloworld
        Link Parent
        Thanks! I work with Java at $DAYJOB and have worked with Python before but it has been all abstract logic with minimal input. You are right that lower level of pygame is making a few things...

        Thanks! I work with Java at $DAYJOB and have worked with Python before but it has been all abstract logic with minimal input. You are right that lower level of pygame is making a few things difficult, for example with significant boilerplate.

        Would you recommend Godot? Does it provide higher level abstractions that can make initial liftoff a bit easier?

        1 vote
    2. Apos
      Link Parent
      If you want to try MonoGame, it's really good to get started programming games. It's C# which is not too far from Java. If you want to code in Java though, something really cool is libgdx.

      If you want to try MonoGame, it's really good to get started programming games. It's C# which is not too far from Java.

      If you want to code in Java though, something really cool is libgdx.

      2 votes
  6. Micycle_the_Bichael
    Link
    Nothing super excited at the current moment. I've been kinda-sorta-half-assed learning Go for a while but with some recent changes in my current role I'm likely going to need to know it in the...

    Nothing super excited at the current moment. I've been kinda-sorta-half-assed learning Go for a while but with some recent changes in my current role I'm likely going to need to know it in the future so I'm building anything I can with Go. I'm not really good with hands-on learning from tutorials or examples, the practice problems never can hold my attention, so I've been re-writing some of my various code I've written at my job into Go. Re-writing scripts and then setting them up to be run using gorun, we have some super janky old webpages and api's in different languages that I'm building new versions of using buffalo (they really messed up calling it gobuffalo and not buffago in my opinion). All in all I'm having a hard time thinking of the last time I enjoyed programming this much. I spend a lot of time working in python2/3, bash, perl, and php, but I've found its been trivially easy to prove Go is as good if not better of a choice for all the situations, it has a low learning curve which is great because I'm going to have to teach it to all my team members eventually, and best of all is that IT ISN'T PYTHON!!!! :D nothing strictly against python, if you like the language and it works for you, keep using it. I personally find it to be one of the most frustrating languages to work with and every design decision is they made the opposite choice of what I would have chosen, whereas go is a lot more in line with me.

    1 vote
  7. netstx
    Link
    I used DarkSky for weather forecasts for quite a while, including the Android app. Apple has recently bought DarkSky, disabled the Android app and closed access to the API. I figured this was a...

    I used DarkSky for weather forecasts for quite a while, including the Android app. Apple has recently bought DarkSky, disabled the Android app and closed access to the API.

    I figured this was a great opportunity to play with a Python web scraper. Then, once that is done, my original plan was to create an API based off of the web scraper for personal use.

    Here is the output of the program, as it stands now:

    Now: 88˚ Humid. It feels like 95˚.
    High: 92˚
    Low: 70˚
    exec time 0.18 seconds

    1 vote