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
invision
Mar 2, 2009

I DIDN'T GET ENOUGH RAPE LAST TIME, MAY I HAVE SOME MORE?
code:
public static extern int OpenProcess(uint dwDesiredAccess, bool bInheritHandle, int dwProcessId);
        public int Pointer(bool AddToImageAddress, int pOffset)
        {
            return this.rdInt(this.ImageAddress(pOffset));
        }

        public int Pointer(string Module, int pOffset)
        {
            return this.rdInt(this.DllImageAddress(Module) + pOffset);
        }

        public int Pointer(bool AddToImageAddress, int pOffset, int pOffset2)
        {
            
            if (AddToImageAddress)
                return (this.rdInt(this.ImageAddress() + pOffset) + pOffset2);
            else
                return (this.rdInt(pOffset) + pOffset2);
        }

        public int Pointer(string Module, int pOffset, int pOffset2)
        {
            return (this.rdInt(this.DllImageAddress(Module) + pOffset) + pOffset2);
        }

        public int Pointer(bool AddToImageAddress, int pOffset, int pOffset2, int pOffset3)
        {
            return (this.rdInt(this.rdInt(this.ImageAddress(pOffset)) + pOffset2) + pOffset3);
        }

        public int Pointer(string Module, int pOffset, int pOffset2, int pOffset3)
        {
            return (this.rdInt(this.rdInt(this.DllImageAddress(Module) + pOffset) + pOffset2) + pOffset3);
        }

        public int Pointer(bool AddToImageAddress, int pOffset, int pOffset2, int pOffset3, int pOffset4)
        {
            return (this.rdInt(this.rdInt(this.rdInt(this.ImageAddress(pOffset)) + pOffset2) + pOffset3) + pOffset4);
        }

        public int Pointer(string Module, int pOffset, int pOffset2, int pOffset3, int pOffset4)
        {
            return (this.rdInt(this.rdInt(this.rdInt(this.DllImageAddress(Module) + pOffset) + pOffset2) + pOffset3) + pOffset4);
        }

        public int Pointer(bool AddToImageAddress, int pOffset, int pOffset2, int pOffset3, int pOffset4, int pOffset5)
        {
            return (this.rdInt(this.rdInt(this.rdInt(this.rdInt(this.ImageAddress(pOffset)) + pOffset2) + pOffset3) + pOffset4) + pOffset5);
        }

        public int Pointer(string Module, int pOffset, int pOffset2, int pOffset3, int pOffset4, int pOffset5)
        {
            return (this.rdInt(this.rdInt(this.rdInt(this.rdInt(this.DllImageAddress(Module) + pOffset) + pOffset2) + pOffset3) + pOffset4) + pOffset5);
        }

        public int Pointer(bool AddToImageAddress, int pOffset, int pOffset2, int pOffset3, int pOffset4, int pOffset5, int pOffset6)
        {
            return (this.rdInt(this.rdInt(this.rdInt(this.rdInt(this.rdInt(this.ImageAddress(pOffset)) + pOffset2) + pOffset3) + pOffset4) + pOffset5) + pOffset6);
        }

        public int Pointer(string Module, int pOffset, int pOffset2, int pOffset3, int pOffset4, int pOffset5, int pOffset6)
        {
            return (this.rdInt(this.rdInt(this.rdInt(this.rdInt(this.rdInt(this.DllImageAddress(Module) + pOffset) + pOffset2) + pOffset3) + pOffset4) + pOffset5) + pOffset6);
        }

Adbot
ADBOT LOVES YOU

Athas
Aug 6, 2007

fuck that joker
Is that Hungarian Notation in C# or something?

ATM Machine
Aug 20, 2007

I paid $5 for this

Make it stop

e: any chance this just keeps going and you've cut it short for brevity?

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
Why is Pointer(bool, int, int) the only overload that actually checks the passed-in boolean? :psyduck:

loinburger
Jul 10, 2004
Sweet Sauce Jones

Volmarias posted:

:wtc:

So they were calling a third party system to figure out how to parse their data, and using reflection to do it? I'm not sure I can believe this.

I think what happened is that the back end used to be written in Ruby, then they got a new CTO who decided to have the back end rewritten in Scala - this resulted in a lot of Ruby developers programming in Scala until the CTO realized that they should probably hire some Scala (or in my case Java) developers.

dwazegek
Feb 11, 2005

WE CAN USE THIS :byodood:

FeloniousDrunk posted:

code:
catch (Exception e){
  e.printStackTrace();
  try{
     this.ct.close();
  }catch (SQLException e) {
     e.printStackTrace();
  }
}finally{
  try{
    this.ct.close();
  }catch (SQLException e) {
     e.printStackTrace();
  }
}

This is beside the point, and I realize that it might be the result of anonymization/simplification you applied.

Is it really possible to catch an Exception e in a catch block that already catches an Exception with the same name in Java?

If so, that seems like a horror to me.

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

dwazegek posted:

This is beside the point, and I realize that it might be the result of anonymization/simplification you applied.

Is it really possible to catch an Exception e in a catch block that already catches an Exception with the same name in Java?

If so, that seems like a horror to me.

Yeah. 'e' is just the name of a variable, so the nested 'e' shadows the outer 'e', so within the scope of the nested catch block only the nested 'e' is accessible. I don't think that's really different from scope for any other variable names in most languages.

edit: And as horrifying as that block might be, that's sadly exactly what they teach you to do at university these days. The professor that taught Java literally said "most of the time, when you catch an exception, the best you can do is dump a stack trace and carry on." No trying to fix the error condition, certainly not quitting since we now know the program's in an error state. Just print a stack trace and leave the user to be quietly hosed.

invision
Mar 2, 2009

I DIDN'T GET ENOUGH RAPE LAST TIME, MAY I HAVE SOME MORE?

ATM Machine posted:

Make it stop

e: any chance this just keeps going and you've cut it short for brevity?

100% chance.

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde
How does one extract the octets from a .NET IPAddress object? Very carefully.

C# code:
string[] array = address.ToString().Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries);

int[] octets = new int[] { int.Parse(array[0]), int.Parse(array[1]), int.Parse(array[2]), int.Parse(array[3]) };
e: Just found the stackoverflow question they copied the code from :bang:

Gazpacho fucked around with this message at 22:26 on Jun 5, 2015

dwazegek
Feb 11, 2005

WE CAN USE THIS :byodood:

Carefully, and with blind disregard for IPv6.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

loinburger posted:

I think what happened is that the back end used to be written in Ruby, then they got a new CTO who decided to have the back end rewritten in Scala - this resulted in a lot of Ruby developers programming in Scala until the CTO realized that they should probably hire some Scala (or in my case Java) developers.

Which IN NO TANGIBLE WAY excuses them from making a call to a third party webSITE (not even webservice) to figure out what the name of the class they want to invoke is, unless you're implying that Ruby programmers are objectively braindead. This ignores the fact that reflection requires a enough code to be used here that I cannot for the life of me figure out how they were able to correctly use it to do what they wanted while at the same time doing the whole thing so incredibly wrong!

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?

Volmarias posted:

Which IN NO TANGIBLE WAY excuses them from making a call to a third party webSITE (not even webservice) to figure out what the name of the class they want to invoke is, unless you're implying that Ruby programmers are objectively braindead. This ignores the fact that reflection requires a enough code to be used here that I cannot for the life of me figure out how they were able to correctly use it to do what they wanted while at the same time doing the whole thing so incredibly wrong!

That is seriously one of the best horrors to be posted here in a while. Someone not only floats that idea at a meeting, but everyone else agrees that it's the best solution? How does that even happen?

Pavlov
Oct 21, 2012

I've long been fascinated with how the alt-right develops elaborate and obscure dog whistles to try to communicate their meaning without having to say it out loud
Stepan Andreyevich Bandera being the most prominent example of that
Woah they were using the website? I thought they just downloaded the corpus. I've done that before in python. Your coworkers are loving nuts.

loinburger
Jul 10, 2004
Sweet Sauce Jones
They downloaded the corpus - no doubt they tried using the website at first, but then noticed that it was taking several seconds for every page to load.

On the first day at that job I was assigned the task of tracking down an infinite loop that had been plaguing them for over a month. That raised a few red flags, but whatever, they paid well.

Evil_Greven
Feb 20, 2007

Whadda I got to,
whadda I got to do
to wake ya up?

To shake ya up,
to break the structure up!?

loinburger posted:

I think what happened is that the back end used to be written in Ruby, then they got a new CTO who decided to have the back end rewritten in Scala - this resulted in a lot of Ruby developers programming in Scala until the CTO realized that they should probably hire some Scala (or in my case Java) developers.
Sounds about right. Though, the tech world is all about unnecessarily reinventing the wheel, creating self-inflicted problems, and forgetting learned knowledge.

Evil_Greven fucked around with this message at 01:46 on Jun 7, 2015

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

loinburger posted:

They downloaded the corpus - no doubt they tried using the website at first, but then noticed that it was taking several seconds for every page to load.

On the first day at that job I was assigned the task of tracking down an infinite loop that had been plaguing them for over a month. That raised a few red flags, but whatever, they paid well.

Oh. That wasn't clear, I just assumed the worst.

omeg
Sep 3, 2012

C++ code:
OVERLAPPED ov;
DWORD got_bytes;
ov.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
if (!WriteFile(c->fd, data, data_len, NULL, &ov)) {
    if (GetLastError() != ERROR_IO_PENDING) {
        perror("client write");
        CloseHandle(ov.hEvent);
        return 0;
    }
}
if (!GetOverlappedResult(c->fd, &ov, &got_bytes, TRUE)) {
    perror("client write");
    CloseHandle(ov.hEvent);
    return 0;
}
CloseHandle(ov.hEvent);
ret = got_bytes;
I guess that's the sort of Windows code you can expect from a Linux guy copy/pasting stuff or I just don't know :eng99:

For those not familiar with winapi, it's basically initiating an asynchronous write (to a pipe) and then... just waiting for the completion. It can be replaced with a single synchronous WriteFile() call.

Munkeymon
Aug 14, 2003

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



Just sat through a presentation on how we're going to abuse MEF to do DI on new projects :sigh:

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Munkeymon posted:

Just sat through a presentation on how we're going to abuse MEF to do DI on new projects :sigh:

Ugh. Has anyone tried to explain that mef is not for di?

Munkeymon
Aug 14, 2003

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



Ithaqua posted:

Ugh. Has anyone tried to explain that mef is not for di?

Yeah. It works so they don't care.

Mellow_
Sep 13, 2010

:frog:
Gross. Microsoft themselves have said MEF is NOT for DI.

TheBlackVegetable
Oct 29, 2006

Ithaqua posted:

Ugh. Has anyone tried to explain that mef is not for di?

What is it for? Ive never used it but when one the problems it says it "solves" is the need to modify source when making changes to an application, I'm skeptical.

Munkeymon
Aug 14, 2003

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



TheBlackVegetable posted:

What is it for? Ive never used it but when one the problems it says it "solves" is the need to modify source when making changes to an application, I'm skeptical.

Plugin discovery and loading, basically. The E is "Extensibility".

We're just using it to lazy-load dependencies. Oh, you'll have to remember not to use them until the event that tells you they're all loaded has fired because that's cool and good.

Here, have another horror:
C# code:
set
{
  var propertyName = PropertySupport.ExtractPropertyName<string>(() => this.Title);

  if (!this.IsNew && this.Initialized)
  {
    if (!_changedProperties.ContainsKey(propertyName))
    {
      _changedProperties.Add(propertyName, new PropertyValueState() { PropertyName = propertyName });
    }

    var originalTitle = !string.IsNullOrEmpty(this.Entity.Product.DisplayName) ?
                                             this.Entity.Product.DisplayName :
                                             this.Entity.Product.AliasName;
    _changedProperties[propertyName].IsValueChanged =
                            (string.Compare(originalTitle, value, StringComparison.CurrentCulture) != 0);
  }

  _title = value;

  this.SetIsDirtyFlag();

  this.RaisePropertyChanged(propertyName);
}
This pattern is pervasive. Gotta track all those non-changes and update the display just in case! Running the debugger on this thing is wearing out my F5 key.

I think I might post in the looking for a job thread soon :\

piratepilates
Mar 28, 2004

So I will learn to live with it. Because I can live with it. I can live with it.



Munkeymon posted:

Just sat through a presentation on how we're going to abuse MEF to do DI on new projects :sigh:

So what's their reasoning behind doing this and not just using one of the many DI frameworks?

Munkeymon
Aug 14, 2003

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



piratepilates posted:

So what's their reasoning behind doing this and not just using one of the many DI frameworks?

Unity is annoying to configure and manage because the config lives off in some XML files somewhere rather than in the code and it also throws annoyingly cryptic errors if something is missing. It actually isn't uncommon to have to hand-copy assemblies around to get a debug session working, but I'm betting that's actually our fault, too, because someone at some point read that using post-build command to copy required assemblies (instead of using a project reference like a normal person) was the way the cool kids were managing relationships when doing DI, so there are a bunch of straight-up broken projects. By that I mean I can't just check them out and hit Build or Run and expect it to work the first time. "Just build it again - it'll probably work the second or third time" is legit advice around here and it drives me nuts that it doesn't bother the guys who made the mess originally.

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

Munkeymon posted:

Unity is annoying to configure and manage because the config lives off in some XML files somewhere rather than in the code

What? I've never used XML config with Unity (I'd probably kill someone if I had to use XML for wiring up DI), all of our configuration is in code. Also since it's in code, project dependencies "just work".

edit: Unless you're specifically trying to support late binding? You can't really do that in code.

Bognar fucked around with this message at 22:43 on Jun 8, 2015

Munkeymon
Aug 14, 2003

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



Bognar posted:

What? I've never used XML config with Unity (I'd probably kill someone if I had to use XML for wiring up DI), all of our configuration is in code. Also since it's in code, project dependencies "just work".

edit: Unless you're specifically trying to support late binding? You can't really do that in code.

Yeah there's a bunch of lazy/late binding because that's easier than working out a way to not have cycles in the dependency graph in all situations without repeating ourselves.

return0
Apr 11, 2007

SupSuper posted:

http://c2.com/cgi/wiki?StringlyTyped

It's sadly common in a lot of APIs. :eng99:

True story, my colleagues and I invented this term while working at a games company.

TheBlackVegetable
Oct 29, 2006

Munkeymon posted:

Yeah there's a bunch of lazy/late binding because that's easier than working out a way to not have cycles in the dependency graph in all situations without repeating ourselves.

It's horrors all the way down...

feedmegin
Jul 30, 2008

omeg posted:

For those not familiar with winapi, it's basically initiating an asynchronous write (to a pipe) and then... just waiting for the completion. It can be replaced with a single synchronous WriteFile() call.

Of course, the Linux/Unix-y way to do this is simply to call write() synchronously too, it's async i/o which would be weird and different :shobon:

Pollyanna
Mar 5, 2005

Milk's on them.


Rails by default compacts arrays when it munges incoming request parameters, which means that if you pass it a null value in an array it will silently remove it. :bang:

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."

Pollyanna posted:

Rails by default compacts arrays when it munges incoming request parameters, which means that if you pass it a null value in an array it will silently remove it. :bang:

Why on earth would this be considered desirable behavior?

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Internet Janitor posted:

Why on earth would this be considered desirable behavior?

~omakase~

xzzy
Mar 5, 2009

If you wanted it, you should have put a value in it. :colbert:

Pollyanna
Mar 5, 2005

Milk's on them.


Internet Janitor posted:

Why on earth would this be considered desirable behavior?

Ostensibly security, but in reality it doesn't matter cause the whole thing is a shitstorm anyway: https://github.com/rails/rails/issues/8832

No Safe Word
Feb 26, 2005

So, someone took a moderately objective and somewhat constructive view of the old classic bastion of coding horrors: TempleOS

http://www.codersnotes.com/notes/a-constructive-look-at-templeos

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction
Rails is bad. People who like it are neophytes or stockholmed. However when you're doing rails apps the "bad, because webdev" and "bad, because rails" all starts to blur together and after awhile it's easier to just go with the flow and get paid ¯\_(ツ)_/¯

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

No Safe Word posted:

So, someone took a moderately objective and somewhat constructive view of the old classic bastion of coding horrors: TempleOS

http://www.codersnotes.com/notes/a-constructive-look-at-templeos

I don't remember who called TempleOS "outsider art" but that seems like the most apt description of it, and when I saw it called that I immediately understood why my friend was so interested in the music I created before I knew anything about making music.

The dude created an entire OS from scratch by himself with tons of interesting features. He may be crazy but he is also a genius.

Dessert Rose fucked around with this message at 19:54 on Jun 9, 2015

Mogomra
Nov 5, 2005

simply having a wonderful time
Just found this and it made me laugh:

code:
responseObject.writeHead(400, {'Content-Type': 'text/plain'});
responseObject.write("404 Not Found\n");
:bravo:

Adbot
ADBOT LOVES YOU

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."

Pollyanna posted:

Ostensibly security, but in reality it doesn't matter cause the whole thing is a shitstorm anyway: https://github.com/rails/rails/issues/8832

I wandered around the related issues and I'm trying to understand how nils represent a security risk. It sounds like the Rails ORM uses arbitrary JSON requests to construct SQL queries and the logic underlying that is incapable of validating input structure in certain ways such that nils can result in queries which return more rows than desired, possibly leaking sensitive information. This seems like an inherently insecure architecture which places unnecessary trust in user input. Could anyone more familiar with the issue clarify?

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