12 ms·
Hello! Long-time lurker, and guilty dev behind the garage door. You can see the (broken) code I wrote here: https://github.com/wpearse/wemos-d1-garage-door-wif
by wpearse 8y ago
Hello! Long-time lurker, and guilty dev behind the garage door. You can see the (broken) code I wrote here:
https://github.com/wpearse/wemos-d1-garage-door-wifi https://github.com/wpearse/wemos-d1-garage-door-wifi
I'll get around to fixing it later this week.
Also, an apology: I should have used "side-effect-free" instead of "idempotent" in my tweets.
- wpearse 8y agoFixed now: https://github.com/wpearse/wemos-d1-garage-door-wifi/commit/fa6d1881857f32bb64b43a0192fcc435fa683afe https://github.com/wpearse/wemos-d1-garage-door-wifi/commit/... I think. edit: updated link because left creds in the commit :-/
- xbenjii 8y agoI hope that's not your real password!
- speps 8y agoEDIT: it's actually his address, I thought it was just a coincidence but you can the house on Street View... I removed the actual name as doxxing isn't great, sorry.
- wpearse 8y agoThanks. Not the address with the WiFi garage thankfully. I was actually thinking "better not commit that" ... before, y'know, I committed it :/
- dogma1138 8y agoWell looks like a nice neighborhood at least.
- jimktrains2 8y agogit add -p It will let you approve each hunk in a file to commit or not. git commit -e -v Will force you to edit the commit message and in the editor show you the diff of the commit against HEAD.
- Drdrdrq 8y agoThank you! I use 'git add -p' all the time, but didn't know the trick with commit. I am a sucker for nice commits so I will check every commit's diff multiple times. When I don't, I usually end up including pieces of code which is not ready yet, which is meant for debugging,...
- Kihashi 8y agoIt's possible to remove that from the history of your repo, although it breaks any forks. https://rtyley.github.io/bfg-repo-cleaner/ https://rtyley.github.io/bfg-repo-cleaner/
- wpearse 8y agoHeh. I think I did worse ... made a local copy of the repo, nuked it on GitHub, then re-created the three commits by hand ... less credentials. That looks like a much more useful tool, though.
- nothrabannosir 8y agoI got just the thing for you: https://gist.github.com/hraban/10c7f72ba6ec55247f2d https://gist.github.com/hraban/10c7f72ba6ec55247f2d Every time you write some code you need to remember removing before commit, surround it with a comment containing "NOCOMMIT". With this script as a pre-commit hook, git will echo an error message and fail. E.g.: print("debug: ", myval) becomes: print("debug: ", myval) # NOCOMMIT I end up relying on this every day I program. Can't go back.
- wpearse 8y agoThanks! I'm not sure how easy it would be to put the git hook on all my machines though? I have a collection of laptops (and one desktop) that I work on and I often don't use the same machine for a few weeks :-/ I ended up using a "env.h" file... is there a C-equivalent of the PHP (?) .env file?
- tty7 8y agohttps://direnv.net https://direnv.net Would be my recommendation
- dogma1138 8y agoWell according to Google it’s an address in Auckland NZ so I hope it’s not his address either.
- bjackman 8y agoAnything side-effect-free is idempotent too, I suppose
- someonewithpc 8y agoNo. A function which multiplies a number by two is side effect free, but is no idempotent.
- amelius 8y agoExcept if the domain is zero.
- falcor84 8y agoOr even a slightly more exotic case, such as Z mod 2 (a single binary digit)
- deleted 8y ago[deleted]
- mseebach 8y agoI think that is considered idempotent in the REST-sense of the word: you can multiply a number by two as many times as you like, the result will be the same (and no state is mutated). I looked it up, apparently there's a formal definition "denoting an element of a set which is unchanged in value when multiplied or otherwise operated on by itself", which does not seem to describe the REST usage very well, though.
- pletnes 8y agoNo side effects means no garage door opening or closing. I guess you wanted it to open or close in some cases at least?
- fahrradflucht 8y agoIsn't the point of this thread that the OT says that he shouldn't have used GET for this?
- inopinatus 8y ago> I should have used "side-effect-free" instead of "idempotent" in my tweets The HTTP term is "safe method". Although you weren't even wrong because section 4.2.2 of RFC7231 (i.e. HTTP) defines all safe methods, including GET, as idempotent. I think they use this language because nothing is truly side-effect free. In fact GETs can have side-effects, the most obvious of which is writing the fact of it to a logfile, and that's the most harmless side-effect of all, right until you run out of disk space. Being a language arse I think the high precision descriptor is actually nullipotent. https://en.wiktionary.org/wiki/nullipotent https://en.wiktionary.org/wiki/nullipotent but I'd never say it out loud.
- cmenge 8y ago'Side-effect free' means that doing it once, twice or n >= 3 times (with same parameters) yields the same result, i.e. what it returns doesn't depend on any remote state that is altered by the call itself. However, an idempotent HTTP call is certainly not a pure function which some people seem to be mixing up. Pure functions don't work with I/O. REST is bit more specific and explicitly requires GET to be nullipotent which really means "effect free" - it just reads and doesn't alter the state on the remote system at all. Side-effects like log files, rate-limiting, etc. will always exist, but they do belong to a different 'layer', so to speak. That is, these should be unobservable side-effects (also think about minuscule effects on the power grid, the fact that a request might write something to an ARP-cache, etc. - they all happen at different layers, so the quantum world state keeps changing, but that's not what this is about). Whether an X-Request-Count header violates the requirements or not depends on interpretation. From the garage door perspective, I wouldn't care...
- kiriakasis 8y ago> Pure functions don't work with I/O. there is a comment above that argue this point in better details. https://news.ycombinator.com/item?id=16966046 https://news.ycombinator.com/item?id=16966046 Basically it depends on the many nuances you have on "pure", "functions" and "idempotent"
- 8y ago
- lisper 8y agoPlease, for the love of all that is holy, don't post long-form content on Twitter.
- ChristianBundy 8y ago> Please, for the love of all that is holy, don't post on Twitter. FTFY
- wpearse 8y agoI'm sorry. This is the first time I've used a thread. I won't do it again!
- wpearse 8y agoActually, I think I actually wrote this story just so I could try out the "new" (months-old?) threading feature. I don't much twitter.