HN user

johncs

202 karma

https://johncs.com

Posts16
Comments23
View on HN

Basically the same as Python’s zipapps which have some niche use cases.

Before zipapp came out I built superzippy to do it. Needed to distribute some python tooling to users in a university where everyone was running Linux in lab computers. Worked perfectly for it.

Thank you! It’s the Solarized color scheme which is definitely a bit low-contrast. I probably don’t notice it only because I’ve been using the color scheme across apps for so long.

I do wish monospace designs were at least a _little_ trendier. My blog uses one, but honestly I feel like I should change it up since I'm looking for roles right now and I worry it doesn't _delight_ like modern designs right now.

I have been manually copying my resume source into ChatGPT for feedback

That’s what I started out doing as well. At some point I got tired of it, and after writing the script I realized the tighter feedback loop was really nice.

    Location: Portland, OR
    Remote: Yes
    Willing to relocate: Yes (Only to the Bay Area)
    Technologies: Most recently TypeScript, Python, React, PostgreSQL, GCP.
    Resume: https://resume.johncs.com
    Email: johnsullivan.pem@gmail.com
Full-stack engineer with professional experience in other areas including Unity, desktop, mobile, and set-top boxes. I've founded two small businesses with modest success but prefer the life of an IC.

I started programming 24 years ago when I was 7 and have been continuously loving and learning more about my craft since.

I've very recently started looking for a new IC role once again. I am interested in Senior/Staff roles that will allow me to continue expanding my knowledge.

In the common case where you trust your input entirely you can just interpret your string as JavaScript. Then you don't even need to use quotes for the key names.

    $ alias fooson="node --eval \"console.log(JSON.stringify(eval('(' + process.argv[1] + ')')))\""
    $ fooson "{time: $(date +%s), dir: '$HOME'}"
    {"time":1457195712,"dir":"/Users/jpm"}
It may be a bit nicer to place that JavaScript in your path as a node script instead of using an alias.
    #!/usr/bin/env node
    console.log(JSON.stringify(eval('(' + process.argv[2] + ')')))
Since fooson's argument is being interpreted as JavaScript, you can access your environment through process.env. But you could make a slightly easier syntax in various ways. Like with this script:
    #!/usr/bin/env node
    for(const [k, v] of Object.entries(process.env)) {
        if (!global.hasOwnProperty(k)) {
            global[k] = v;
        }
    }
    console.log(JSON.stringify(eval('(' + process.argv[2] + ')')))
Now environmental variables can be access as if they were JS variables. This can let you handle strings with annoying quoting.
    $ export BAR="\"'''\"\""
    $ fooson '{bar: BAR}'
    {"bar": "\"'''\"\""}
If you wanted to do this without trusting your input so much, a JSON dialect where you can use single-quoted strings would get you pretty far.
    $ fooson "{'time': $(date +%s), 'dir': '$HOME'}"
    {"time":1457195712,"dir":"/Users/jpm"}
If you taught the utility to expand env variables itself you'd be able to handle strings with mixed quoting as well.
    $ export BAR="\"'''\"\""
    $ fooson '{"bar": "$BAR"}'
    {"bar": "\"'''\"\""}
You'd only need small modifications to a JSON parser to make this work.

This pattern of access is simple and intuitive but causes huge problems in even small projects. Retrieving whole rows is hugely wasteful when only part of the row is required to resolve a user request.

Retrieving a whole row rather than just a single column from a database that's likely on a local network definitely doesn't seem "hugely wasteful", especially for smaller projects.

I set failglob: `shopt -s failglob`. Makes the whole command fail if there's no matches. That combined with `set -e` which aborts the script in the event of any command failing makes me feel somewhat safe.

Indeed I add the following two lines to every bash script I write:

    set -exu
    shopt -s failglob