Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Doc Hawkins
Jun 15, 2010

Dashing? But I'm not even moving!


Bongo Bill posted:

Is there a shell that does have good syntax?

https://hackage.haskell.org/package/turtle

Adbot
ADBOT LOVES YOU

SardonicTyrant
Feb 26, 2016

BTICH IM A NEWT
熱くなれ夢みた明日を
必ずいつかつかまえる
走り出せ振り向くことなく
&



Eggnogium posted:

No, which is why you should write all your scripts in python. Sadly my org will never get on board with that.
That's something I'd love to do with our team. After the...other horrors.

ynohtna
Feb 16, 2007

backwoods compatible
Illegal Hen

Bongo Bill posted:

Is there a shell that does have good syntax?

emacs :devil:

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe

Bongo Bill posted:

Is there a shell that does have good syntax?

Comedy option: Perl. :v:

tyrelhill
Jul 30, 2006
I worked on a build system based on makefiles and Perl years ago... What a hosed language, hope I never use or see it again

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe

tyrelhill posted:

I worked on a build system based on makefiles and Perl years ago... What a hosed language, hope I never use or see it again

It is great at its original intended purpose, viz. text processing. You can replicate most of its capabilities using sed and awk, but not always and personally I'm bad at remembering how to use those tools. So, like, a one-liner to find things that look like email addresses, convert them to lowercase, and output them would look something like this:

code:
cat file.txt | perl -ne 'chomp; /\s([\w\d\.]+@[\w\d\.]+)\s/; print (lc $1) . "\n" if ($1)'
In this day and age though, there's a better option for pretty much anything you'd want to do with Perl that isn't commandline one-liners.

(And yeah, I know that regex is bad and that trying to recognize email addresses is a stupid-hard problem)

Nth Doctor
Sep 7, 2010

Darkrai used Dream Eater!
It's super effective!


TooMuchAbstraction posted:

I know that regex is bad
Ron Howard voice: No it isn't.

TooMuchAbstraction posted:

and that trying to recognize email addresses is a stupid-hard problem
Ron Howard voice: Yes it is.
code:
\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*
 |  "(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]
      |  \\[\x01-\x09\x0b\x0c\x0e-\x7f])*")
@ (?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?
  |  \[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}
       (?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:
          (?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]
          |  \\[\x01-\x09\x0b\x0c\x0e-\x7f])+)
     \])\z
:barf:

Nude
Nov 16, 2014

I have no idea what I'm doing.
:hfive:

Doom Mathematic
Sep 2, 2008
The email address regex is constructed by machines and consumed by other machines. The intermediate representation is unfit for human eyes but that's nothing unusual.

FlapYoJacks
Feb 12, 2009
If you are trying to solve a problem with regex, you now have two problems. :v:

Jeb Bush 2012
Apr 4, 2007

A mathematician, like a painter or poet, is a maker of patterns. If his patterns are more permanent than theirs, it is because they are made with ideas.

TooMuchAbstraction posted:

It is great at its original intended purpose, viz. text processing.

it's fine at that, but there's still no reason for someone without pre-existing perl experience to choose it for that purpose over python or ruby

you get some nice-ish syntactic sugar in exchange for the incoherent design that comes from taping together a dozen unix utilities and calling them a language

ToxicFrog
Apr 26, 2008


New Yorp New Yorp posted:

What's dumber is how it handles return types.

code:
function Foo {
param ($n) 

    Write-Output 'trace statement'
    return 1..$n
    
}
You'd expect that to return the range 1 to n. Except it doesn't. It returns an array, with the first element being 'trace statement'. Trace statements should be written with 'Write-Host', because Write-Output writes them to the output pipeline. It's yet another subtle gotcha that hurts people and causes stupid bugs.

This looks like they looked at the way functions in Bourne have to "return" anything that isn't a small integer by writing it to stdout and then capturing it with $(...) -- something that makes it very easy to get log output from your function or anything it calls mixed into your "return value" by accident -- and went "yes, this is awesome, we should replicate this behaviour in Powershell". :whoptc:

I've barely touched Powershell, but based on indirect exposure to it, it really looks like the high-level concept was "let's copy all the most awkward misfeatures from the Bourne family, but with much more verbose syntax for everything and perhaps stick a type system in there somewhere".

iospace
Jan 19, 2038



Needs a good text editor though.

The Fool
Oct 16, 2003


ToxicFrog posted:

This looks like they looked at the way functions in Bourne have to "return" anything that isn't a small integer by writing it to stdout and then capturing it with $(...) -- something that makes it very easy to get log output from your function or anything it calls mixed into your "return value" by accident -- and went "yes, this is awesome, we should replicate this behaviour in Powershell". :whoptc:

I've barely touched Powershell, but based on indirect exposure to it, it really looks like the high-level concept was "let's copy all the most awkward misfeatures from the Bourne family, but with much more verbose syntax for everything and perhaps stick a type system in there somewhere".

That behavior happens because of how powershell treats the object pipeline and is perfectly logical if you understand the underlying concept.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

The Fool posted:

That behavior happens because of how powershell treats the object pipeline and is perfectly logical if you understand the underlying concept.

It's perfectly logical, but it's also totally counter to how someone coming from almost any other language would expect it to work.

code:
function bar {
    return 1
}

function foo {
    bar
    return 0
}

foo # returns @(1, 0)
Now, imagine bar is a function in a module with a side effect that returns an object that you're not capturing -- all you care about is the side effect, not the output. All I want to get back out of foo is my return value. Now imagine that bar returns output in some cases, but not all cases. Suddenly, I have a situation where whether my output is "0" or {unexpected poo poo,0} is totally unknown to me and I have to defensively code around this possibility, or just say "gently caress it" and not rely on returns and just set global variables.

I know you can pipe things to Out-Null so that this doesn't happen, but the bottom line is that it's awful, counterintuitive behavior. The way a powershell novice learns about these behaviors is by getting bitten by them.

New Yorp New Yorp fucked around with this message at 02:29 on Jun 25, 2018

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice

Doom Mathematic posted:

The email address regex is constructed by machines and consumed by other machines. The intermediate representation is unfit for human eyes but that's nothing unusual.

Almost all email regexes are wrong.

There is only one way to validate an email address: send an email to it.

Given how badly programmers usually handle names, mailing addresses, and similar things I’ll also take the opportunity to remind people not to attempt to “validate” those things either.

Polio Vax Scene
Apr 5, 2009



Simulated posted:

There is only one way to validate an email address: send an email to it.

If this is the only way, then I can safely assume there are zero ways to validate an email address.


v namaste v

Polio Vax Scene fucked around with this message at 19:36 on Jun 25, 2018

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Polio Vax Scene posted:

If this is the only way, then I can safely assume there are zero ways to validate an email address.

Then you have achieved enlightenment

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice
Is just checking for *@* the bare minimum? That's what I've used just to validate input. I assume all email addresses have the @.

Meat Beat Agent
Aug 5, 2007

felonious assault with a sproinging boner
"abc\@def.com" has an @, but it's also backslash-escaped, so it also doesn't.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
Useful email validations: does it have an @, does a call to getaddrinfo() on the thing to the right of the @ succeed.

redleader
Aug 18, 2005

Engage according to operational parameters

Meat Beat Agent posted:

"abc\@def.com" has an @, but it's also backslash-escaped, so it also doesn't.

This is one of those cases where whoever entered that email is deliberately out to cause trouble. My policy in that situation is "gently caress you".

I also check .+@.+\..+ because there are people who use the @google TLD, and they also fall into the above category.

ulmont
Sep 15, 2010

IF I EVER MISS VOTING IN AN ELECTION (EVEN AMERICAN IDOL) ,OR HAVE UNPAID PARKING TICKETS, PLEASE TAKE AWAY MY FRANCHISE

Plorkyeran posted:

Useful email validations: does it have an @, does a call to getaddrinfo() on the thing to the right of the @ succeed.

You can also do a fair amount of heuristics to suggest to a user that they may have made a mistake, but those aren't exactly validation.

By which I mean that you can detect, say, that in "ulmomt@yajoo.com" I may have made 2 typos, even if the domain exists (this one doesn't, but hey).

https://hackernoon.com/how-to-reduce-incorrect-email-addresses-df3b70cb15a9

xtal
Jan 9, 2011

by Fluffdaddy
There's an extension for postgresql to do an MX lookup on the domain name before allowing email types to be saved

Pollyanna
Mar 5, 2005

Milk's on them.


Just send an email and make them confirm the account :downs:

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe

Pollyanna posted:

Just send an email and make them confirm the account :downs:

ulmont's link is about pointing out that if the user typos a valid-looking email address, they'll never get the confirmation email and you just lost a customer. You can use some heuristics to try to detect typos; it's always going to be an imperfect science but you can probably catch ~99% of typos. Just let the user say "yeah actually I do use pollynaan@gmail.cmo".

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
The important part that a ton of web sites seem to forget is that you need to give the user the option to go "oops, actually sent a verification email to this different address" so that when they don't get a verification email due to a typo they can then fix the problem.

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?
More websites need verification emails so people stop signing up for poo poo with my email address

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Plorkyeran posted:

Useful email validations: does it have an @, does a call to getaddrinfo() on the thing to the right of the @ succeed.

I forget, does getaddrinfo() on untrusted input have any security concerns? I remember something being exploitable if you had an unusual nsswitch.conf module enabled.

b0lt
Apr 29, 2005

Suspicious Dish posted:

I forget, does getaddrinfo() on untrusted input have any security concerns? I remember something being exploitable if you had an unusual nsswitch.conf module enabled.

There was a stack overflow RCE exploit in glibc's getaddrinfo a few years ago: https://security.googleblog.com/2016/02/cve-2015-7547-glibc-getaddrinfo-stack.html

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

Suspicious Dish posted:

I forget, does getaddrinfo() on untrusted input have any security concerns? I remember something being exploitable if you had an unusual nsswitch.conf module enabled.

Obviously bugs can exist, but it is intended to be safe to call on untrusted input.

canis minor
May 4, 2011

code:
trait IdOrStringCheckTrait
{
    public function isString( $string )
    {
        return ( $this->isInteger( $string ) == false ) ? true : false;
    }

    public function isInteger( $string )
    {
        $string = trim($string);
        return is_numeric( $string ) && ctype_digit($string)? true : false;
    }
}
:v:

SardonicTyrant
Feb 26, 2016

BTICH IM A NEWT
熱くなれ夢みた明日を
必ずいつかつかまえる
走り出せ振り向くことなく
&



And so the nightmare realism continues. After re-writing the part of my project in which someone else used an unapproved third party library, legal chimed in to say they want a complete chinese wall rewrite of that part.

So. :v:

Mooey Cow
Jan 27, 2018

by Jeffrey of YOSPOS
Pillbug
Mayst I interest thee in two vectors? :heysexy:
code:
class FTwoVectors
{
public:
	FVector	v1;
	FVector	v2;

	FORCEINLINE	FTwoVectors() :
		v1(0.0f),
		v2(0.0f)
	{
	}
	FORCEINLINE	FTwoVectors(FVector In1, FVector In2) :
		v1(In1),
		v2(In2)
	{
	}

	...
};
Perhaps you wish to use it as a six-dimensional interleaved vector so the value you get out is different from the index of the values you sent in? We got you covered.
code:
    FLOAT& operator[](INT i)
	{
		check(i>-1);
		check(i<6);
		
		switch (i)
		{
		case 0:		return v1.X;
		case 1:		return v2.X;
		case 2:		return v1.Y;
		case 3:		return v2.Y;
		case 4:		return v1.Z;
		default:	return v2.Z;
		}
	}
Still haven't figured out what the christ the "F" prefix means. "hosed"?

csammis
Aug 26, 2003

Mental Institution
“Float”?

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

csammis posted:

“Float”?

as opposed to the super common integer vector

Mooey Cow
Jan 27, 2018

by Jeffrey of YOSPOS
Pillbug

csammis posted:

“Float”?

There's also a FuckedString and FuckedName, which don't seem to have anything to do with floats.

Absurd Alhazred
Mar 27, 2010

by Athanatos

Bruegels Fuckbooks posted:

as opposed to the super common integer vector

I don't know if you're being sarcastic, but e.g. GLM will have integer vectors. It's pretty common for placing things on grids, making parallel integer calculations, etc.

repiv
Aug 13, 2009

F was indeed originally for float: https://forums.unrealengine.com/dev...ructs-stand-for

It seems to have morphed into a catch-all prefix for anything that doesn't fit into their other prefixes though.

repiv fucked around with this message at 14:09 on Jun 28, 2018

Adbot
ADBOT LOVES YOU

Absurd Alhazred
Mar 27, 2010

by Athanatos

repiv posted:

F was indeed originally for float: https://forums.unrealengine.com/dev...ructs-stand-for

It seems to have morphed into a catch-all prefix for anything that doesn't fit into their other prefixes though.

"F" is for "gently caress it".

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply