• The Week #50

    • It was Father's Day this week. I made chicken fajitas for the family and they were a hit. I was also able to talk with both of my dads (father/step-father) for about 2 hours total. It feels like it's been ages since I've been able to focus and talk with them. I always say I should do it more often, but for some reason, I don't.
    • I got the physical copy of Web+DB Press that includes my article on getting started with GraphQL and Django. It took a lot of work to edit the piece down to 8 pages, but in the end I believe we were able to whittle away the weaker parts of the article and I could say everything I wanted. Seeing your name in print never gets old.
    • Pete opened the first issue on Tanzawa not opened by me asking some questions. It made me realize that I should add screenshots and talk about Tanzawa supporting Micropub/Indieauth/Webmentions so you can post with whatever client you'd like.
    • I find myself wanting to use Email more. I don't really use it – in fact I can count the number of emails I've sent at work in the 4+ years I've been there: 0. Everything happens via Slack or some web interface. I wonder if there isn't a way for me to handle more of async tasks via email to standardize my workflows better?
    • Jacob (who seems to make a weekly appearance on this column) told me about this podcast where they asked the question "What if the newscycle was 100 years – what would the story be?".Β  Think, you get to ignore the politics of the day, what's the big story? Their answer was that it would likely be the doubling of the average human lifespan.

      This got me thinking – so much of our life seems to get lost in the daily battles. Often enough that we lose sight of the bigger trends over the weeks, years, decades. Does focusing on too small of a timescale make it difficult to achieve your goals? Would focusing purely on getting things right for the week/year/decade make each day more successful, on average?

      I think it might. We tell ourselves we need to do X everyday (run, eat better, whatever). But we slip up one day and beat ourselves up. Rather than focusing on the 5 days we were successful that week, we dwell on that time we messed up. It all gets you demotivated. I'll have to experiment with reframing things to longer timescapes over the coming weeks and see how it turns out.
  • How to Pipe Python stdout with xargs

    When writing instructions for getting started with Tanzawa, users needed a way to set a unique SECRET_KEY in their environment variable configuration file. Initially I had a secret key entry in the sample file with some instructions to "just modify it". But that felt like I was just passing the buck.

    What I wanted to do was to generate a unique secret_key and output it to the .env file. Outputting just the secret key is simple, you can just use >> and append output to an existing file. But I wanted to use my Python secret key output as an argument to another command.

    I did it as follows:

    python3 -c "import secrets; print(secrets.token_urlsafe())" | xargs -I{} -n1 echo SECRET_KEY={} >> .env

    1. Use the Python secrets module to generate a secure token.
    2. Pipe the output to xargs.
    3. -I is "replace string" and "{}" is the string we want xargs to replace. -n1 limits us to a single argument.
    4. xargs executes and takes our Python output as an argument and replaces the {} with it, giving us our desired string.

    Writing this now, I probably could have just used Python to include the SECRET_KEY= bit and forgone using xargs, but it was good practice anyways.
  • Response to The Thermal Printer Project: Part I

    A few days ago, I decided to purchase the Adafruit Thermal Printer, which was compatible with the Raspberry Pi. This thermal printer has been on my mind for a while but this week a reason for buying one came to mind (aside from the fun of experimenting with a thermal printer which was obvious to me).
    Really enjoyed this series from James about hooking a thermal printer to a cronjob that'll print his weather, webmentions, and news off in the mornings. Brilliant! I've got some Pi's laying around collecting dust, I should use them for something fun like this.
  • Expanded Tanzawa README instructions for running a local development version of Tanzawa using Docker. If you give them a whirl and they don't work or are confusing, let me know with a webmention, tweet, or opening an issue. πŸ™πŸ»
  • Got my Father’s Day present early! Woohoo β˜•οΈπŸŽ‰

    Cold Brew Coffee Maker
  • Writing Professionally in a Second Language

    I just finished an article that will be published in this month's Web+DB Press magazine, a monthly web-related programming magazine in Japan. The entire magazine, including my article, is in Japanese. I want to reflect on the process of writing professionally in a second language and contrast this with my first experience when writing the 2nd chapter of Professional Python Programming 3rd edition (PyPro3).


    Picking a Topic


    Unless you're writing for yourself, the general topic is going to be decided for you. The company I work for writes regularly for Web+DB Press. GraphQL's been gaining popularity lately, and since I've built a few projects with it, a co-worker asked if I was interested in writing an article about GraphQL. Remembering how difficult it was to write PyPro3, I was a bit hesitant at first, but thought it'd be a good test to see how much my Japanese had I'd improved over the years. I also wanted share what I'd learned building GraphQL APIs with Django.

    Outlining


    Outlining is the process where you set the scope and decide in in more detail what you want to write about and the general order that you'll write. Before you can start outlining you need to first decide roughly how long of an article you want to write. The length of a magazine article is often decided for you, so it's mostly a matter of figuring out what you can fit into the allocated space.

    My outline was fairly basic, just a bullet list to help guide me along as I wrote and the base idea for what we'd build in the article.

    Writing


    Writing in your first language is difficult enough. Writing in a second language maintains the challenges of writing in your first, but also adds an extra layer on top. Not all idioms or expressions in your native language can be expressed in eloquently or in a similar manner in a different language.

    Having a solid outline of what you're going to write about, including the order and main points you want to cover makes writing much easier. This applies to writing in your first language as well, but it's doubly important in a second language.

    When writing PyPro3, I could write and speak Japanese, but writing a narrative piece was difficult. Many of the words I was using weren't quite yet internalized and reading what I wrote 5 minutes prior was a challenge. So I ended up writing the gist of what I wanted to say in English, and then translating it as best as I could before a native speaker cleaned it up for me.

    This time around, 3 years later, my outline was in Japanese and I didn't write any of the article in English first and then translate. Writing was a lot quicker too as I had become used to explaining code and what it's doing from work. I made the quickest progress when I was focusing on writing for a specific co-worker and explaining GraphQL to them.

    Editing


    Editing in a second language is difficult. I won't say I'm useless, but I don't have that feeling when something sounds "off" like I do with English. Without that sense, it was difficult to know exactly how to fix feedback from internal reviews and the editor at the magazine.

    The actual process of editing this time around was much easier, however. A co-worker and I would pair edit, where I'd pull up the document on my screen via Zoom and we'd work through the comments together. This made it much easier to ask for advice or for clarification or a second opinion.Β 

    Beyond not having a native feel for the language, skimming is also much more difficult. This makes finding the paragraph a particular comment is referencing a bit slow. I got better as I practiced, but I also found that copying a snippet of the comment and using the Find feature of my editor helped immensely.Β 

    Conclusion


    Good writing in any language requires clear thinking and proper planning. Being able to stay in the same language for planning, drafting, and editing makes the entire process much easier. Having native speakers check and edit your workΒ  allows you to gain a better understanding of your second language, not only at the grammatical level, but with sentence patterns and flow as well.

    I'm grateful to have been given the opportunity to be published, especially in my non-native language and hope I'll have another chance in the future.
  • How to Process Tailwind / PostCSS with Webpack

    Usually when I work with webpack another tool I'm using generates the appropriate config for me and I can remain blissfully unaware of how it all works.

    With Tanzawa I've only been adding tooling when absolutely necessary. The other day I configured PostCSS and Tailwind with Webpack. It still required a bunch of searching and piecing together blog posts to get something that worked for me.

    Below is a list of facts that helped me figure out how to think about processing CSS with webpack.

    • As wrong as it feels, your entry point for processing your CSS should be a Javascript file.
    • Webpack by default does not output a separate stylesheet file. In order to output a plain CSS file, you must use the MiniCssExtractPlugin.
    • Despite wanting to output only CSS, and specifying the filename in the options (style.css), Webpack will create an empty Javascript file regardless. There isn't a way to prevent this unless you add another plugin. I'm adding it to .gitignore.
    • The "use" plugins have the following roles
      • MiniCssExtractPlugin: Exact built css to a dedicated css file.
      • css-loader: Allow you to import css from your entrypoint Javascript file
      • postcss-loader: Run postcss with yourΒ 

    // webpack.config.js
    const path = require('path');
    const MiniCssExtractPlugin = require('mini-css-extract-plugin');
    
    const tailwindConfig = {
      entry: "./css/index.js",
      output: {
        path: path.resolve(__dirname, "../static/tailwind/"),
      },
      plugins: [
        new MiniCssExtractPlugin({ 
            filename: "style.css"
        }),
      ],
      module: {
       rules: [
        {
          test: /\.css$/,
            use: [
              MiniCssExtractPlugin.loader,
              { loader: "css-loader", options: { importLoaders: 1 } },
              "postcss-loader",
            ],
        },
       ],
      },
    }
    module.exports = [tailwindConfig]

    In order for postcss to play well with Tailwind and webpack, I needed to update my config to pass the tailwind plugin the path for the tailwind.config.js. It simply imports (requires) the tailwind config and immediately passes the path.

    // postcss.config.js
    module.exports = {
      plugins: [
        require("tailwindcss")("./tailwind.config.js"),
        require("autoprefixer"),
      ]
    }

    Finally to run this all for production, I execute via webpack as follows. I still need to figure out how to get the NODE_ENV environment variable set via with the webpack --production flag, so for now it's a bit redundant.

    // package.json
    {
      ...
      "scripts": {
        "build": "NODE_ENV=production webpack --mode=production"
      }
      ...
    }
  • The Week #49

    • This week's been a good week. A tiring week, but a good week, so I'll dive right in.
    • I realized that Tanzawa was never going to be "good enough" or "finished enough" for me to release it. It's the first project I've made public in a very long time. The last big project I worked on was Kwoosh, a project management app I was building with my mate Jacob around 4 or 5 years ago. Making it public is a huge relief, not just because "it's out there", but it will force me to document and follow proper development workflows (no more committing directly on main πŸ™ƒ)
    • The article I wrote for Web+DB Press has been officially announced in the upcoming issue. It's an 8-page introduction on using graphene-django to build GraphQL APIs with Django. It's my second time having my writing published in Japanese, but the first time being credited by name. It was also much easier to write in Japanese this time about, as I've had the past 4 years read/writing Japanese everyday at work.
    • My father-in-law's appointment for his first shot got moved up to the 22nd of this month and my mother-in-law got an appointment for the first week of next month. Super happy they'll be vaccinated soon.Β 
    • Yokohama, feeling pressure from Kawasaki is going to start sending vaccination vouchers out to people under 65 starting mid-June (so...this week?)!Β  I think it might be a bit tight to get fully vaccinated before the Olympics, but maybe I'll be able to get my first shot and a bit of time for my immune system to do its thing before then. I remain optimistic.
    • Thanks for FindADocJp.org, I was able to find a clinic nearby in Totsuka that's doing reservations for people, regardless of age/vaccination voucher to get left-over shots in the case of cancellations. We had started building a sheet on the HN Tokyo Slack for this kind of information, but open forms on 'net let more people participate. Hats off to @TheYokohamaLife for building it.
    • Leo's going through a papa-phase been sticking to me like glue from the moment he wakes until he goes to sleep. I'm happy to spend time with him, as I know this won't last forever, but boy is it tiring.
  • He explained that since most people are not given the power to directly change these policies, the most effective way to bring about change would be to make a statement to those running the economy by becoming self-sufficient through boycotting corporations, growing one's own vegetables, and making one's own clothes.Β 

    The quote above is from his Wikipedia entry, but I knew there was a reason I liked Manu Chao.  ✊
  • Checkin to Costco (γ‚³γ‚Ήγƒˆγ‚³)

    in Zama-shi, Kanagawa, Japan
    密でーす
1 of 60 Next