Hacker News new | past | comments | ask | show | jobs | submit | abcxjeb284's comments login

This one is based in security standards :( https://security.stackexchange.com/questions/45455/which-sec... (link talks about screen locking but similar vibe for app logout for various certification bodies)


At least this is based on "inactivity", compared to "authentication tokens must have a maximum lifespan of 15 minutes"


Great for expressivity of multi-level dicts (excuse the goofy example):

    state2name2visited = defaultdict(lambda: defaultdict(list))
     state2name2visited[“PA”][“Joe].append(“Pittsburgh”)


You can expand this a bit to make it n-level depth (until you blow the stack).

  def tree():
    return defaultdict(tree)

  >>> t = tree()
  >>> t['a']['b']['c'] = 10
  >>> t
  defaultdict(<function tree at 0x10c40df28>, {'a': 
  defaultdict(<function tree at 0x10c40df28>, {'b': 
  defaultdict(<function tree at 0x10c40df28>, {'c': 10})})})


Reminds me of perl's autovivification, where you can even mix and match dicts, arrays, and scalars:

    $M{hello}[4]{world}[0]++
gives you:

    {
        'hello' => [
            undef,
            undef,
            undef,
            undef,
            {
                'world' => [
                    1
                ]
            }
        ]
    }


This is really cool, I used it to implement a (very) basic trie:

    trie_struct: Callable = lambda: defaultdict(trie_struct)

    trie = trie_struct()

    for word in words:
        ref = trie
        for char in word:
            ref = ref[char]
It won't work with words that substring other words, but its interesting.


Nice! Very expressive way to do n-levels!


Python has too many ways to do it:

    >>> state2name2visited = {}
    >>> state2name2visited.setdefault("PA", {}).setdefault("Joe", []).append("Pittsburgh")
    >>> state2name2visited
    {'PA': {'Joe': ['Pittsburgh']}}


It’s really 2 ways to do it, and the defaultdict way (I believe) would have less allocations in a deeply nested loop (since this version has to create a {} and a [] every time).

Also setdefault causes confusion for less experienced users in a way that the defaultdict format does not.


I came across this once in Peter Norvig's Udacity CS 212 course - I think it was in the discussion forums for one of the lessons. My head promptly exploded.


And here I was thinking you could only pass a type.


oo nice. i haven't seen this before and was doing something similar in a much uglier fashion.


python-box does a pretty good job on this I find.


Great links in the article to read more, but strikes me that this style of working assumes everyone is already up to speed. How do you set aside time for mentoring? Teaching? Growth?


In hindsight, probably would’ve been way better to ship a `cryptography2` package and deprecate the old package.

That way you get the benefits of using rust without the anger about the sudden breakage of a transitive dependency.

In terms of floating versioning, I honestly think it’s not reasonable to ask packages to do this, because then you get into dependency hell with unfixable dependency conflicts.


Agreed, strict use of mypy with editor support is a game changer (particularly its union types and TypedDict)


Excellent points, I’d add the counterintuitive:

* Pedestrian traffic - busier streets with more people mean less likely to be mugged vs the empty side street.


It's counterintuitive for a reason, and to be honest I have bad (not necessarily direct) experiences in both cases, and can't conclude which one is the best. Does a busier street really mean less likely to be mugged? Why?


Bit of a miss on why “serverless” (though author & I have different definitions), possibly because of language / toolset.

Lambda / Step Functions make for an easy combo for easily understandable units that you can use without a bunch of servers. Combine it with AWS CDK and you end up with a low boilerplate, auto-completeable environment (with types!) that’s actually easy to unit test locally!

I agree that yaml config and figuring out how to wire things up sucks. I’m open to Smalltalk being better.

But we’ve been using Lambda / Step for a few years now and it’s been highly robust, easy to understand, monitoring / logging essentially free and - best of all - we haven’t had to manage any server upgrades / patches / etc the whole time. (And super easy to spin up stack per user)

Have a queue of items to work on? Combine lambda + sqs (just a few lines with cdk) and now you have code that auto scales linearly with how many entries are in your queue.

We did write our own tool to handle boilerplate of linking python functions to their lambda handlers (but again this is the beauty of actually being able to use programming language to define your stack)


> But Wintel will own business desktops for probably a decade, unfortunately.

Do you see this as being different from what was going on pre-M1?

Aside from shared math libraries, seems like most stuff required cross compilation just to work - I’m not clear that M1 adds more work on top of that.


I wouldn’t call your posts “self-promos”. You’re actually posting guides, not “2 lines of text now buy my product”. You’re already being a reasonable redditor.


I had my domain "banned" after arguing with a very self aggrandizing mod (and almost exclusively self promoting poster) in a particular sub.

My offense? An instructional blog about how to scrape commonly requested data by many members of the sub.


Your domain gets banned in that specific subreddit?


Thanks for saying this. Certainly how I feel, but I haven't read the rules...


Phillip - would you be open to using your platform for a non-profit art project? We don’t have many funds (see: COVID), but we are REALLY excited by the possibilities of the space you designed and the game maker map!! :)


Yup! Feel free to email us at hello@gather.town , and provide these details, and we'll figure something out.


Hi! I am not the OP, but just emailed you about a free online event I am organizing (Flutter Vikings).


Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: