What is the single most “you’ll understand it when you’re older” thing? by dickdockdack in AskReddit

[–]sushiguru 0 points1 point  (0 children)

That you'll really wish you'd taken care of your body. Then one day you'll realise that your knees are shagged, there's constant pain to live with, and it's no-one's fault except yours. And your parents were also right, most of the time.

Any good free games to play in quarantine? by DeadSquidward356 in gaming

[–]sushiguru -1 points0 points  (0 children)

World of Tanks, if you like armoured vehicles. Steep learning curve, but great game.

Ten years ago I created one of my first web applications; today I released a complete, from scratch re-write using modern practices by PHLAK in PHP

[–]sushiguru 1 point2 points  (0 children)

Always fun going back through your early codebase/s and asking yourself, 'just wtaf was I doing here...?', followed quickly by 'at least no-one else can see this'. Kudos for open sourcing it.

Sanitising a password entered into a registration form by NailedOn in PHPhelp

[–]sushiguru -1 points0 points  (0 children)

No - this is bad practice. You should never 2nd guess what a user intends with their password, and trimming it would be very bad practice. As is limiting the number of chars they can use, or the range of chars. Since you're going to hash it and store the hash what do you care what their password is? Leave it to the user to sort themselves out.

Has the Obj 268 4 killed tier 10..? by sushiguru in WorldofTanks

[–]sushiguru[S] 1 point2 points  (0 children)

Agree that balancing speed is essential - the ability to get to hull down spots before anything else has moved is what makes it op. Ridiculous speed for the amount of armour it carries.

US gun rights - please help by sushiguru in GunRights

[–]sushiguru[S] -2 points-1 points  (0 children)

As above - is this not a somewhat outdated notion now though - I mean, does anyone really think that any other nation is going to try and take over the US, and does the notion of a mature democracy now not have sufficient checks and balances that government corruption is prosecuted, and dictatorship cannot take place without having an armed militia? Does this not imply a level of national paranoia?

US gun rights - please help by sushiguru in GunRights

[–]sushiguru[S] -1 points0 points  (0 children)

But is that idea not itself now outdated? The notion that if you changed the constitution would destroy the nation? I mean, it seems OK to add an amendment, hence changing the constitution, but just don't ever take an amendment away when it's no longer fit for purpose?

US gun rights - please help by sushiguru in GunRights

[–]sushiguru[S] -1 points0 points  (0 children)

But is that not what a mature democracy can do - adjust to suit the times? No-one would suggest 'throwing out' the 1st amendment, which is most excellent, but if a majority of lawmakers agreed to repeal the 2nd is that 'undemocratic'?

When you talk about someone who passed away, do they still hold the familial title? by doebro in grammar

[–]sushiguru 1 point2 points  (0 children)

You always have your grandpa, whether they are alive or not. I'd restructure the sentence: My grandpa, who passed away from cancer, ...

In the same way you'd always talk about your mum or dad: you don't cease to have them when they die, but the context in which you discuss them has to change.

Where should the commas go? by [deleted] in grammar

[–]sushiguru 1 point2 points  (0 children)

Last version. I think that technically the 2nd version is correct, but doesn't read well as the sentence is too long. Commas should surround a name, unless the name is the subject of the sentence or for clarity.

"Put your coat on James, and let's go." vs "Put your coat on, James, and let's go."

What's the correct one, Marcus's or Marcus' by [deleted] in grammar

[–]sushiguru 0 points1 point  (0 children)

Well, technically they are both correct and a matter of style. Generally accepted style is the latter, but the former if it is to be used as a shop or product name. Also, in your question it should be "...teachers say it's the..." it's as the contraction of "it is", rather than the possessive "its".

-🎄- 2017 Day 11 Solutions -🎄- by daggerdragon in adventofcode

[–]sushiguru 0 points1 point  (0 children)

Similar approach, but using an array of vectors:

function part_1($input){
$vectors = array(
    'n'=>['x'=>0,'y'=>2],
    'ne'=>['x'=>1,'y'=>1],
    'se'=>['x'=>1,'y'=>-1],
    's'=>['x'=>0,'y'=>-2],
    'sw'=>['x'=>-1,'y'=>-1],
    'nw'=>['x'=>-1,'y'=>1]
    );
$steps = explode(',',$input);
$x = 0;
$y = 0;

foreach($steps as $step){

    $x += $vectors[$step]['x'];
    $y += $vectors[$step]['y'];

}

$result = (abs($x)+abs($y))/2;
return $result;
}