1. 2

    This is a great piece, thanks for writing & sharing!

    Python is one of those languages that I write infrequently enough that I don’t have an “innate” sense of what it means to write idiomatic Python code, whereas I do have that sense for other languages. That usually means for me that my Python scripts end up looking like the language I’ve been using most recently, and I’ve come across Python files I’ve written that feel like I’m reading Node, Swift, or even Rust in a strange dialect.

    One way to get better at writing idiomatic code would be to read articles like this one, compile all the individual tips, and reference those tips when writing new Python. It seems to me like a more sticky way to get better at writing idiomatic Python code would be to read idiomatic Python code, but whenever I sit myself down to read code I don’t have any stake in, I feel like it’s a waste of my time.

    Do other people incorporate “reading code” into their process? How?

    1. 2

      For me the “reading code” comes from the need to use big libraries extensively and understanding their inner workings. For example, I often have to dig into libs like requests or flask. So, I think you start reading more code as you use the language more.

    1. 2

      Working on a full-stack feature at work. Finished the backend bits early today (well, really late Friday, but I’d have been terrified to deploy late Friday) and starting on the frontend bits today. It’s my first time working on an end-to-end feature within my org like this and it’s really cool having the opportunity to do so!

      I’ve been working on Stork’s input handling. The program (ultra-fast WASM search plugin for static sites) really only deals in plain text files right now, but I’m working on parsing different file types, starting with HTML, Markdown, and files with arbitrary Frontmatter blocks. I haven’t really touched Stork in a bit and it’s exciting to get back to it.

      I’m taking piano lessons again for the first time in almost 10 years. I’m working on getting better at reading sight music, which was always somehow a skill I managed to avoid learning. It’s much more exhausting to play piano for 30 minutes than I expected – definitely feels like I’m exercising a new muscle.

      1. 3

        My wife and I picked up some houseplants that a neighbour was giving away. We’re repotting them as the roots are overgrown and escaping out the bottom. We’ll need to cut the pots in a few cases.

        I’m also trying to keep up with the pace of writing one article per week.

        1. 3

          What are you finding is the hardest part of writing an article each week?

          1. 1

            The hardest part is probably coming up with an idea that I believe in.

            I often come up with the title first. I try to think of something that I would click on 100% of the time — basically, writing what I want to read.

            Sometimes, I like writing articles for one person. If someone asks me a hard question, or if I’m mentoring someone who is building something, then I can write as if it’s a letter to that person on how to overcome their current obstacle.

        1. 1

          Continuing work on stork. I’ve rewritten the system that weights each search result; hopefully this weekend I’ll be able to look at each word in a search query and weight results based on how many words in the query a given result matches. I’m looking a lot at Rules for Autocomplete (2019) to have a sense of what I’m building towards.

          Continuing to quarantine. Work got busy all of a sudden. Watching Little Fires Everywhere on Hulu and remembering how much I liked the book.

          1. 1

            The stork link seems to not work for me…?

            1. 1

              Yup, I messed up the url of my own project. I meant to write

              https://stork-search.net

              (Although while I’m here, I should mention that I finished the new highlighting and sorting features I was hoping to get done!)

          1. 2

            I would be interested to see a comparison to the performance of other in-browser search index schemes, like lunr.js, flexsearch, fuse.js

            (@jil you might want to check your homepage design in WebKit browsers - on my iPhone 10 a lot of text was off the edge of the screen with no way to fix it!)

            1. 1

              Coming in kinda late, but just fixed the text on the site. Thanks again for alerting me.

              1. 1

                Same on Firefox Preview (Android)

                1. 1

                  Oh no! Thanks for letting me know. I had fixed a layout bug everywhere else… and must have accidentally borked things on mobile.

                  CSS is frustrating sometimes.

                1. 4

                  How does Stork compare to tinysearch, which was posted here recently? https://endler.dev/2019/tinysearch/

                  1. 3

                    Tinysearch is great! I was chatting with Matthias briefly after I realized we had been working on something similar. He put a lot more work into the data structure, doing some really cool work implementing a bloom filter to get the index size down. I focused on ease of integration, making it a fully hosted library. Eventually I want to borrow some of Matthias’ ideas for Stork!

                  1. 3

                    I also like adding a toggle interface on the page, which saves the value to localstorage in case the user prefers one or the other. At that point, I just override the prefers-color-scheme logic with the saved value in Javascript if needed.

                    Coincidentally, I did this to my blog yesterday – here’s the dark mode logic.

                    1. 2

                      Ah nice, thanks for this! I’ve been thinking about implementing something like this also. This will save me some time. :-)

                    1. 6

                      https://jameslittle.me.

                      It’s a Jekyll site hosted on Netlify. Soon it’ll be a Nuxt site hosted on Netlify. I feel like everyone found this out a while ago but I’m shocked by how natural it feels to write a site using a component-based architecture – now the default CSS paradigm of having a single, flat, global namespace feels so awkward.

                      1. 1

                        I really expected Notion to show up in one of these responses. Maybe it’s not quite the thing for the Lobsters crowd, but it seems to fit exactly this role: it apparently can set you up with a personal wiki, daily journaling, and project management stuff really well. I haven’t used it myself, but I keep hearing that it’s pretty good – I’m just kind of afraid of the total buy-in it seems to require.

                        1. 2

                          I’ve tried Notion before. Although I like the tool and constantly hear about it from others, I think it suffers the longevity problem (checkout the longevity statement from standard notes). Last i checked sync to a google drive or dropbox is missing, and their export to markdown is super basic at the moment with a lot of issues.

                          1. 2

                            For sure. That was part of my thinking when I was trying out Notion too – I have to take the time to set it up, and then I have to truly believe that it’ll be the right thing for me long-term. Evernote’s slow demise has sort of eroded my trust in proprietary brain-dump tools.

                            longevity statement from standard notes

                            Here’s the link for anyone who, like me, hadn’t heard of this before.

                        1. 1

                          I do this too. I ran git init in my home folder at some point.

                          I have the star at the top of my gitignore, but I’ve also forced certain files to be tracked like this:

                          *
                          !.gitignore
                          !.gitconfig
                          <and then like 12 more files or directories>
                          

                          There are some downsides to having your home directory being a git repository; namely, my bash prompt, which shows git status, always defaults to my home directory if I’m not in a different repo. Every once in a while I end up running git commands on a directory that isn’t itself a git repository, so I end up accidentally performing that action on my home directory instead. Oops.

                          1. 3

                            I did a git clean once too often on my home directory, so I decided to wrap git in a function that checks for the existence of a .git-noclean – if this file exists, then the clean command is ignored.

                            1. 1

                              This is a cool idea. Is the exact wrapper published somewhere?

                              1. 2

                                Nope, but here’s the function (in fish shell syntax):

                                # hub, also, put a belt-n-suspenders thing over our git-clean 
                                # susceptible homedir
                                function git
                                        if test $argv[1] = "clean"
                                                set git_base (git rev-parse --show-toplevel)
                                                set ignore_file $git_base/.git-noclean
                                                if test -f $ignore_file
                                                        echo "JFB: cannot clean $git_base (ignore file exists)"
                                                        return 1
                                                end
                                        end
                                        hub $argv
                                end
                                
                          1. 4

                            I recently finished and set up project that reminds me about saved Pinboard links with exponential backoff: link. Inspired by a talk by Andy Matuschak I saw recently where he talked about how he gets a lot out of journaling prompts that come up with a similar cadence, and how that helps him build up a library of his ideas around a topic.

                            I’m also working on a web search interface and indexer built with Rust and WebAssembly: link. It’s built for static sites with lots of different pages, and the idea is that the indexer precomputes a search index at the site’s build time, then the WASM part can search through that index really really quickly. This is a project I hope to capital-p-Publicize, and I’m hoping I can spend some time this week to polish it off beforehand!

                            Work is lots of docs cleanup and small bug fixes, etc.

                            1. 3
                              • Setting up a PiHole!
                              • Working on an iOS app for a side project.
                              • I got a bike with clipless pedals last weekend. I now need to go figure out how to use clipless pedals.
                              1. 5

                                love chunkwm! been using it for about 8 months now.

                                if you want to have focus follows mouse with autoraise, like x windows, use chunkwm in float mode. voila! beautiful, even if you don’t care about tiling window managers.

                                1. 2

                                  Does it work well with multiple monitors? I was exploring Phoenix recently and I don’t think there was a way to move a window from one monitor to another.

                                  1. 3

                                    it does! here’s my .skhdrc key bindings for moving windows around to monitors:

                                    shift + alt - 1 : chunkc tiling::window --send-to-desktop 1
                                    shift + alt - 2 : chunkc tiling::window --send-to-desktop 2
                                    shift + alt - 3 : chunkc tiling::window --send-to-desktop 3
                                    shift + alt - 4 : chunkc tiling::window --send-to-desktop 4
                                    shift + alt - 5 : chunkc tiling::window --send-to-desktop 5
                                    shift + alt - 6 : chunkc tiling::window --send-to-desktop 6
                                    
                                1. 3

                                  Jeffrey Way, a major contributor to the Laravel community, has been tweeting about this lately. I think his overarching point is that when we spend too much time thinking about how to write a perfect unit test for a given piece of code and not a perfect test overall, we get trapped in thinking about the specific boundaries between unit/functional/integration and not thinking about how best to test the code we write.

                                  1. 8

                                    The timed (or dynamic) wallpapers in macOS Mojave also use the azimuth of the sun to try to mimic the day/night cycle you see outside on your computer.

                                    Marcin Czachurski spent a lot of time (1, 2 and 3) reverse engineering the file format – it’s based on an HEIC container, I think.

                                    In my experience, it’s not all that accurate – the sun sets much faster outside than on my computer.

                                    1. 2

                                      That’s interesting. I guess the ultimate in wallpapers would be to raytrace the desktop wallpaper with accurate lighting as Earth rotates and revolves around the sun.

                                      1. 4

                                        I remember using xplanet to do something like that like 10 years ago. It would set my X background to a map with accurate day and night indication. I wish there was something like it for modern high resolution screens.

                                        1. 3

                                          I used xplanet to show me a view of Mars. I can’t remember whether it was rotating in realtime or not… I believe it was. Fascinating piece of software, which I don’t think ever made it off Linux.

                                          1. 3

                                            I’d forgotten all about xplanet. Thanks for that trip down amnesia lane!

                                          2. 3

                                            This sounds like a job for WebAssembly.

                                            I’m only half-joking. It sounds like a method that could work, compiling one of those business card raytracers into a program that draws your wallpaper without being able to do arbitrary I/O. Better than Windows .scr screensavers, which are literally just executable complete with the ability to do arbitrary system I/O (so many old viruses pretended to be screensavers…)

                                            1. 1

                                              There is a project offering 3D animated wallpapers, named livewallpaper.

                                              Check out the livewallpaper package if you are using Arch Linux.

                                        1. 2

                                          School starts back up again this week, lots of brainpower devoted to that.

                                          I’ve been working on a thesis about machine learning, and noticed a disappointing lack of tutorials for using the TensorFlow Object Detection API. I’m currently in the process of writing the tutorial that I wish already existed about the topic.

                                          1. 2

                                            The Refactoring UI link in the end of the article sums up the point nicely, while giving a different suggestion for how to generate color palettes for application design:

                                            It’s not uncommon to need as many as ten different colors with 5-10 shades each for a complex UI.

                                            He starts with grays, then identifies meaningful colors that should also be part of the palette (colors like red/green/blue that have semantic meaning associated).

                                            And while he spends the first part of the article railing against color scheme generators, it doesn’t seem like a terribly difficult challenge to build a color scheme generator based on the principles he presents: Pick a brand color, a tint of gray, and a few other hues and it generates a bunch of nicely aligned shades across the lightness spectrum.

                                            1. 2

                                              I’m working on a thesis about synthetic neural network training data for school. I spent the fall thinking about the theories and use cases of my project, and I’m planning on doing some actual synthetic vs. real training data comparisons in the spring. That means in the winter I get to figure out as much of TensorFlow as fits into my use case: this is proving to be tricker than anticipated. I have lots of time this week to learn, so I’ll be hunkered down studying.

                                              I’m also writing a Markdown to HTML transpiler in Swift (a language with complicated string behavior and limited regular expression abilities). I fixed some issues with my rules engine last week, and this week I want to knock out a few more individual rules.