Your PIN can't be used because it is the smallest number not on our list of PINs that are too easy to guess for other reasons + the smallest previous number.
That reminds me of the story of the man who was ordered to be executed next week, but he is not allowed to know the day of his execution until the morning of.
He figures if by Friday morning he has not been told, then he will immediately know his execution is on Saturday, thus violating the Judge's order; therefore he cannot be executed on Saturday.
Knowing he can't be executed on Saturday, if on Thursday morning he has not been told, he knows he must be executed on Friday, thus violating the Judge's order. By induction it would violate the Judge's order to execute him on any day of the next week.
The following Tuesday he was thus completely surprised to be taken out to be executed.
Exceptions when opening a file has been chosen because they have the nice propery of encouraging a race condition free EAFP rather than a hard to get right LBYL.
It also fits nicely into the context manager pattern.
Besides, remember exceptions are cheap in python. So cheap that for loops are basically syntaxic sugar for a try/catch.
EAFP - Easier to ask for forgiveness than permission
LBYL - Look before you leap
They are opposite strategies, Python's preferred strategy is to do the first, just try the operation and throw an exception if it doesn't work. The second is to check a pre-condition before attempting an operation.
I've always known the second as exhibiting TOCTOU, otherwise known as a time-of-check vs time-of-use race condition.
But that is a false claim. It's not about being EAFP or LBYL: if the open API returns a handle to file or null, the open operation can still be atomic and therefore race-free.
Which is exactly how it's in all the programing languages and operating system calls which don't use exceptions for that.
It's just the question if one has to write try-catch for something as common as file not existing.
LBYL can easily be enforced by Maybe types, leaving exceptions for really exceptional things (which a nonexisting file definitely isn't). So we see how not having a real type system hurts and deforms a language in ways unrelated to types.
"As I’ve mentioned above, I like to use modules that expose groups of functions. These functions accept state and other dependencies. These modules tend to look like what my colleague Drew describes as the functional module pattern."
I dislike that.
When I see a class, I expect it exists because there is a central state around which the methods revolve, and are meant to expose or change it.
When I see a function, I expect it to be side effect free.
Sure you can use any paradigm to make any program, but I use paradigms, just like I use design patterns, to communicate intent. Solving the problem is half the battle. In a way, coding style is documentation. I think we should build boring API, and only use cleverness to find solutions, or make the API easier to use and more elegant.
I worked once on a code base that broke a lot of implicit expectations. Like, it could add objects in a registry when you instantiated some classes, get_stuff could set other stuff, do_stuff would not do stuff but actually_do_stuff would, etc.
It was a nightmare to work with, because anything could happen anywhere. You had to look at the code every single time and keep the whole system in your head, which had 900k lines of highly technical code.
If done properly as described, the functions accept state. This means they adjust state by adjusting input/output parameters, not by affecting some internal state. This is basically Dependency Injection extended to state. This is also how classes are implemented (see python's self parameter to all class functions).
Correct, but the effectiveness of the design is separate from its correctness. Latter of which is what I commented on.
For effectiveness, I think it reduces ancillary class members, and encourages (necessitates!) dependency injection.
For example, changing "delta t" in a game object update is trivial: update the one delta-t you have, and pass it into everything that needs it. With classes, there may be a temptation to have a delta-t member variable, which costs many updates. Stupid example, but a mistake which is not possible with Dependency Injection.
But really, proper scoping in typed languages (and naming in dynamic ones) can allude to input vs output parameters. In C/C++ this is passing by ref vs value. (In Google C++ style guide, they recommend use of pointers for "adjusted" or "output" parameters.) In MS C++ from back in the day, I think they had ways to explicitly specify parameters as input, output, or input+output. Does someone have an example of this?
It would be nice to group all the functions that operate on a piece of state together in the same place.
It would also be nice to prevent functions that are not in this group to make changes to that part of the state.
Then you could prefix all those functions with a name, so it's clear what's their scope.
Finally, in some cases it would be great if you could create multiple independent "instances" of the state, so you could manage more than one at a time without risking conflicts between the various copies.
I don't think you actually do state management in OOP, only manage a single level of abstractions.
In java, inheiretance is directional in a single way, but if you instantiate a singleton component, you can end up affecting the state of every other class that uses that same component. This is not wrong per se, it is a property of OOP in itself.
If this rubs you the wrong way, possibly you should be working in purely, monadic functions.
That is really my point. Isn't it better to just use a tool that limits what bad decisions you can make? Or at least make these bad decisions so hard that once you know how to implement them, you know better ways to write your code?
OOP has come to mean different things at different times. For a time, OOP definitely meant tightly coupling state and behavior. Same as inheritance, this practice seems to have been left behind some time ago.
These functions accept state and other dependencies
That "dependencies" term is very loaded. You need to define if you call "dependencies" what the functions in your module take as argument or you're talking about those other modules your module calls.
When I see a function, I expect it to be side effect free.
Why? though I think it's a commendable goal it's not a reasonable expectation from most languages.
When I read "these functions accept state and other dependencies," I took it to mean that "state and other dependencies" would be an ever-growing list of arguments to the function -- not that they'd necessarily be modifying external state.
I work on a project where I framed up both patterns, and ultimately decided that the hodgepodge^ pattern was preferable to repeating long lists of arguments.
^ kinda like the mixin pattern but I think it's been taken too far
Besides, it's a lose/lose proposition for the gov anyway.
If they do act, people will blame them for the cost of the action.
If they don't, people will blame then for the cost of not acting.
Nobody will pat them on the back, except a few intellectuals, for acting.
In fact, economically, the virus spreading is an opportunity to fire people you couldn't fire before, get rid of an old population costing money and have an excuse for a lot of things like passing certain types of law. People will not focus on that, their attention is elsewhere, and you can always invoke the circumstances if they do.
We have created a system in which it's not in the interest of the gov to solve the problem. And in which the population lives in a way that makes it hard to do the right thing by themselves.
More accurately, I think, we have let very cynical people take control of everything important. So in matters of policy it's reasonable to assume extreme cynicism.
The natural human instinct is to look to leadership during a crisis. This is why Bush’s competency in the eyes of the public was harmed after Katrina. This is why McCain’s “maverick” rep harmed him against “steady” Obama during the financial crisis.
If the coronavirus starts impacting the lives of Americans in a widespread manner (shuddered schools, closed offices, loss of jobs), the same instinct will kick in.
Given what the current POTUS has gotten away with, as with many others in power everywhere, I don't have much faith in the accountability we can expect.
The economy is going to be in shock, whatever you do.
Don't act, and you'll get a messup economy because of the panic and the sick people.
Act, and you'll get a messup economy because of the panic and the sick people, and the cost of tests+quarantines+curfew. Less people dead is the ethic thing to do, but power is not about morality.
This comment is a perfect example why we won't have the same containment as Japan or South Korea; we in the west, "know" that our government is evil/incompetent/selfish so even if they act, we will not heed their advice.
It's not like they don't have the same incentives in the other countries, the main difference is that we do not trust the government. Might be selection bias, but I do think we have been hammered with a stereotype on modern culture about the incompetent/evil bureaucrat getting in the way of the hero's solution.
At the risk of being down-voted, I'm not trying to start a political debate. I'd just like to know, as someone outside the USA, how this is affecting the election campaigns there.
Are personal costs of the pandemic encouraging people to support subsidised healthcare, and therefore a left-wing party?
Or is the xenophobic rhetoric of "blame China/Europe/travellers/etc" causing people to support a right-wing party?
I also haven't seen a full discussion of the chain of cause and effect. There was a shift from the primary sector to tertiary services, which led to urbanisation to find demand for services. Young people living in cities can make more friends than before, and this is good! It also means that there are more people living in close quarters, who can spread disease more effectively. I'm willing to face the risks of urban life instead of subsistence farming, but I wonder if other generations resent that.
I see a lot of what you mention on online mediums.
But it's usually quite different than what's really happening IRL.
People love to play the panic game online, but I've seen only quiet order around me.
Yesterday, my entire neighborhood has been evacuated because of a bomb, we were all grouped in an hospital, where we were questioned about possible fever.
In airports, I see people wearing masks, facing cancelled flights. I see stores with huge queues to buy stock of food.
It all happens in a calm and civil manner.
Maybe I'm optimistic, but I'm nicely surprised by the way people act right now, despite all the blame we want to place.
The long term impact on U.S. politics is hard to gauge. As a member of the Democratic party, I am in favor of emergency legislation that provides direct financial payments to impacted individuals. In particular, we have close to 30 million uninsured and they have a strong disincentive to get tested for Conrna virus due to unexpected/unknown costs.
This is likely the same segment of the population who have a strong incentive to go to work ignoring risks of community spread. They live pay check to pay check and can't afford to be sick and take time off.
As an emergency measure, the federal government should carry all costs associated with virus testing. Any individual who is quarantined or must stay home to care for those quarantined should receive direct cash transfers to off-set the immediate economic dislocations this causes.
The current federal administration's argument for suspending payroll taxes does nothing for those who are unemployed or work in the informal, cash economy.
Luckily, at the state and local level officials appear more competent placing the health related impacts above politics. As an example, the governor of New York took the unprecedented step of quarantining New Rochelle just outside New York city.
If there is any possibility of a silver lining from all of this, it would be how the U.S. electorate might see the true economic cost of allowing roughly 10% of the population to be uninsured. To me, it is immoral that the richest nation on earth permits those who are most vulnerable not having equal access to adequate healthcare.
Finally, as an indication of how the federal government continues to politicize the pandemic, the Secretary of State continues to call the Covid-19 pandemic, Wuhan virus, as an insult to China.
As a US citizen lucky enough to not be significantly impacted by all of this, I'm deeply embarrassed by such an outrageous insult from a federal official.
I don't know the answer to your question, but in addition to the mechanisms you mention there's at least one more: there's some evidence that fear in general, and fear of death in particular, tends to make people more supportive of right-wing authoritarian government.
(I don't mean to imply that right-wing = authoritarian; I pair them together because my recollection is that the research in question was specifically about right-wing authoritarianism and not about rightism generally or authoritarianism generally.)
So (1) to whatever extent the GOP is authoritarian as well as right-wing, or at least pushes the same psychological buttons that authoritarian rightists do, it might benefit from having a population that feels afraid, and (2) maybe Mr Trump would have done better politically with something along the lines of "This is a deadly epidemic, sweeping in from scary foreign countries, and only your strong President can protect you and keep you safe". I guess the restriction on air travel from Europe may be intended as a bit of a pivot in that direction.
I doubt it will affect elections directly. Looking around the world, there's mostly bad examples from all kinds of governments - right-wing (Trump in US, Johnson in the UK), centrist (Macron in France, Merkel in Germany), left-wing (Slovenia - was centre-left until a week ago, Denmark), totalitarian (Iran, China)...
Most people do not see any personal cost of healthcare and thus are not turning more left-wing. The left-wing party is pushing that view, but they are not changing anybodies mind.
There’s not much right vs left yet. It’s just the Democrats figuring out who their candidate will be. The pandemic has a very small effect on the US right now. Things are closing but mostly in anticipation of the near future. Almost none of it is in the middle where the right lives.
There’s been some yelling at trump over his poor handling but it’s mostly just virtue signaling at this point. When the elections come around for real we will probably see something of this if/when it has evolved into something more serious here.
I say this in Boston, just a few degrees of separation from some of the COVID confirmed individuals.
Yes, almost everyone does this. It's just opaque in most cases. I will say that, assuming they follow their adjustments literally, you do have some odd situations. Your ideal strategy to maximize comp vs. cost of living is to live in a state where the comp for the whole state is set by a relatively high CoL city but to live in a lower cost area in that state. (At least that was the case last time I looked.)
[ADDED: Although it looks as if they've made their calculator more granular so that high CoL city doesn't carry over to other areas as much.]
In France you can only get pills dosed at a very small 800 IU (international unit, see: http://www.nafwa.org/vitamind.php) without prescription, but in the US, you'll find some bottles dosing a single pill up to 10 000 IU.
The pills look all the same no matter the dose. They are minuscule yellow balls, but they can be very concentrated.
So "take a lot of Vitamin D" doesn't mean "take a lot of pills". Target an amount of IU, and take exactly what you need for that.
Vitamin D has been found toxic if you take more than 60 000 IU/day for 3 month. You'd have to be quite heavy in your dosing to reach this, but I'd rather share the info.
There is no overdose possible if you get it from the natural source: exposition from the sun. And it's healthier. But as a geek you may see the light of your monitor much more than the one from the sun, and D supplements are incredibly cheap for the huge benefit in energy and mood they provide in the winter.
I take 5 000 UI/day (as Cholecalciferol, so D3), and my doctor already thinks it's a lot since the daily recommended dose here is 200 IU.
Be careful about vitamins in the US though because the industry is entirely unregulated and many vitamin companies are pyramid schemes, so you have very little guarantee that what’s on the bottle is in the pills.
Naturemade is the only brand that comes to mind with external lab certification of ingredients and being free from contamination, but I’m sure there are others:
"Daily oral dosing of vitamin D3 using 5000 TO 50,000 international units a day in long-term hospitalized patients: Insights from a seven year experience."
When working from home, my first impulse 10 years ago was to make it "more comfy": working naked, no fixed time table, available for a chat if needed, etc.
It was a mistake.
You do need a schedule. That doesn't mean you can't break it if you need to, that's the perk, but it should be exceptional.
You do need to shower, dress up and be on time. Yeah you can have a few productive days without it. But you'll notice that after a while, the days you get back to the social conventions, you have more focus.
You do need to keep up your habitual defenses against distractions (for me, disabling all notifications and putting a lock on the door as my SO cannot integrate the concept of WFH).
Because humans are creatures of habit. Anything that is an habit is easy to keep up. Everything that is not is an effort. Everything that goes against an habit is a fight.
So working from home means less commute. A more cozy environment. The possibility of going off schedule from time to time.
> putting a lock on the door as my SO cannot integrate the concept of WFH
I basically had to give up WFH because of this. My family just did not understand at all. And putting a lock on the door is not socially acceptable. If you have a family, especially one of the age to be at home during the workday, it is very difficult to WFH unless they really understand it. A nearby office would have been so much better if I could have managed that.
> The number of death is so high because they count person who had other illness (cancer, heart disease, etc) and because we have lot of elder persons (the probability of dying is higher for over 75).
I don't know how the count is made, but since the pressure will affect the care for the other patients as well, it makes sense to at least take them in consideration in the stats.
Yes, it make sense.
The strange value is the one from Germany with more than 1000 cases and only 2 died. I suspect that the criteria for counting the death is not the same across different EU countries.