Threads for csturtevant

  1. 9
    • there will be unexamined complexity behind any proposal that starts with “why don’t you just …”

    • ten lines is a sensible limit for anything written as a shell script (based on my experience, yours may vary)

    • mocks are a code smell

    Not saying all of these are universally true, but they have all served me well as heuristics.

    1. 1

      Do you have some good examples for how mocks are a code smell and example showing how to write effective code without them? I would like to write with less mocks.

      1. 2

        If I’m no allowed to show you the codebase I contribute to at $WORK (and I’m not) I think I’d have to go looking for them. My observation which leads to this rule of thumb is (1) that mocks are often (mis)used “to make the tests faster” - as standins for other objects which are outside the control/ownership of whoever wrote the mock, and (2) rarely is it that a mock is accompanied with a suitable contract test to ensure that the thing being mocked continues to behave in the way that the mock says it should behave.

        If you’re not sinning in either of those ways then this rule of thumb does not apply to you and you’ll have to look to other sources of inspiration for reducing your use of them[*] - and without seeing how you are using them, I can’t really advise what that is. A quick example , suppose you have something like a Rails controller - it transforms the parameters it gets from Rack (e.g. parses them from strings into meaningful values), calls a domain or service object method, transforms the result back. Instead of writing a test that mocks the service object to check it receives the expected transformed values, you could extract the transformations and test them in isolation - then the controller itself is so trivial that (I would argue) there is small value in even writing a test for it.

        [*] I mean, supposing you even need to. Statistically in my experience mocks are correlated with bad testing practices, but that doesn’t mean I think they are always misused.

        1. 1

          What about using Mocks to isolate your tests from the outside world (aka in place of db connections, filesystem or time calls)?

    1. 12

      Without JavaScript I get a blank page.

      1. 3

        Yes… I’m also not a fan of simple webpages that need JavaScript for everything. But it was faster for me to implement it this way. Eventually this will be improved.

        1. 4

          It’s.. just a list?

          1. 3

            Just guessing based on 1990’s era sites since I don’t do web dev. Tiled series of images, descriptions, and links that CSS could probably handle. Clicking one generates a page with a list of stuff on one side and something for exploration on the right similar to frames I used ages ago. There’s delays for the text on the left appearing. Unless the sources change fast, this could be done statically where each source is periodically scraped, results turned into standard HTML/CSS file for each, and main tiles link to that. It would likely load and render faster, esp from caches, with server-side utilization being lower.

            Again, it’s just me guessing based on stuff I did in DHTML days combined what this page looks like it’s trying to achieve. Some web dev people I read say they use JS frameworks for things like making it look right across all devices/OS’s. I don’t know how far vanilla CSS or CSS frameworks take you these days.

            1. 6

              Yes @nickpsecurity, what you say makes perfect sense.

              I implemented it this way simply because I didn’t want to have to maintain the jobs necessary to keep the website updated. I also wanted to be able to pick any GitHub link and replace “” with “” and get the page rendered with TOC, search and star/fork counters (which are the features I added).

              So for me, the advantage of having this hosted for free on GitHub Pages, not having to maintain a server, and being able to render any GitHub readme, is worth the delay of having to do everything on the client. But I’m sure many people disagree and would prefer a different implementation.

              Thanks for your thoughtful response.

              1. 2

                Those advantages make sense in your position. You’re also not going to see me gripe much since it’s volunteer work on your part. ;)

          2. 2

            How did you implement this?

            1. 4

              I used create-react-app, which is a tool that bootstraps the code necessary to use React for static websites. It’s simple but comes with some limitations that they highlight here. For the styling, I used TailwindCSS which is what’s called an utility-first CSS framework. It provides simple CSS classes that you can build upon.

              All the content comes from GitHub. The lists are curated by people and each one lives in its own repository. The descriptions and logos come from GitHub Explore which is also open source. The categories come from the “official” metalist.

              The client uses the GitHub API directly. I started by getting readmes in markdown and processing them with remark. There’s lot of plugins for it, including to generate TOCs and render using React components. There were some limitations that prevented the output to look 100% equal to GitHub so I ended up fetching already rendered HTML from GitHub instead (the GitHub API provides that option) and using htmr to convert to React components. That way I can for example pass a custom React component for rendering links, so I can easily show the number of stars and forks, convert relative links to absolute, etc.. It’s not the most performant solution for sure, but the code becomes simpler.

              That’s basically it, the source is available on GitHub:

        1. 4


          We’re starting some new data analysis projects. Right now it’s just in the research phase, which means I get to spend a bunch of time looking at a bunch of infrastructure stuff and forming completely unfounded opinions. May favorite way to spend my time :D

          The thing I’m more excited about is we’re in talks with a charity to see if we can do some pro-bono software work for them. It fits our company mission, is good publicity, and makes me feel a little less bad about not giving enough to charity.


          I’m giving a TLA+ talk on Friday!

          I also have this blog post on how Vim keystrokes (not VimL, just the keystrokes) are Turing complete. I have the example and everything already done, but I’ve been slacking on actually writing the article and stuff. I probably won’t get around to it this week, either, but I’ll tell myself I will and then feel bad when Friday rolls around.

          1. 1

            I’m now looking forward to the post on how Vim keystrokes are Turing complete.

          1. 1

            What is the stack behind this, and what was the road to get this working with Facebook Messenger?