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
king_kilr
May 25, 2007

Wheany posted:

$get = sqlInjectionProtect($_GET);

Pack it up, go home folks, this is the ultimate horror.

Adbot
ADBOT LOVES YOU

POKEMAN SAM
Jul 8, 2004

king_kilr posted:

Pack it up, go home folks, this is the ultimate horror.

Yeah, seriously, camel-case functions? *shudder*

ymgve
Jan 2, 2004


:dukedog:
Offensive Clock

Wheany posted:

$get = sqlInjectionProtect($_GET);

Might not be a horror (except for the fact that they're probably not used parameterized queries) - I assume the function does something like "Check if gpc_magic_quotes is enabled, if not, do manual escape of all variables."

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

ymgve posted:

Might not be a horror (except for the fact that they're probably not used parameterized queries) - I assume the function does something like "Check if gpc_magic_quotes is enabled, if not, do manual escape of all variables."

Something like that, yeah.

Then on the next row after calling that function: $thing = getAThingById($get["id"]);

Opinion Haver
Apr 9, 2007

Haskell's Text.Printf.printf manages to implement a variadic function in a strongly typed language without native variadic support. It also determines whether it's being called in the IO monad or not, and either returns an IO () (an 'action' that when executed, will do something IO-y and not return any useful value), or a String. It does all this through horrible typeclass (think instances) fuckery.

Munkeymon
Aug 14, 2003

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



pokeyman posted:

I think this ties for best in thread with Duff's Enigma.

I still think the string manipulation function I found at work is worse than Duff's, which is at least somewhat understandable.

edit: took me a while to find it
code:
function util_clearAllBlanks(str,intern) {
   var db, sss;
   var i,j,k;
   var out = "";

   if (str != "") {
      sss = str.toString();
      db = sss.split(" ");
      
      for (i=0; (i<db.length) && (db[i] == ""); i++) { }
      for (j=db.length-1; (j>=0) && (db[j] == ""); j--) { }
   
      for (k=i; k<=j; k++) {
         if (db[k] != "") {
            if (intern != 1 && out != "") out = out + " ";
            out = out + db[k];
         }
      }
   } else {
      out = str;
   }
   
   return(out);
}
Don't worry - it's still in use :)

Munkeymon fucked around with this message at 00:14 on Nov 10, 2010

bobthecheese
Jun 7, 2006
Although I've never met Martha Stewart, I'll probably never birth her child.
code:
<form name="GroupEditForm" action="<?=$currentscript?>" method="post" onsubmit="return checkGroupForm(this)">
<?
$t = new FormTable();
$t->add(new HiddenInput('action',$action));
$t->add(new HiddenInput('id',$id));
if ($formerror) {
    $t->addFormRow('',new Bold(new String($formerror)));
}	
$inputelement = new TextEntry('name', $name, 40);
if ($inputelement) $t->addFormRow('Name:',$inputelement);

...
An old C programmer learning php decided to "try out this object thing" by building an HTML abstraction layer. It doesn't do any HTML format checking, it just blindly produces strings of HTML. Strangely enough, he also used plain HTML (i.e. ignored his abstraction layer) about half the time.

Everything he did had a strange logic behind it, but due to his complete lack of commenting anything, this logic is often near impossible to figure out.

POKEMAN SAM
Jul 8, 2004

bobthecheese posted:

code:
<form name="GroupEditForm" action="<?=$currentscript?>" method="post" onsubmit="return checkGroupForm(this)">


This line itself is horror gold.

ToxicFrog
Apr 26, 2008


Argue posted:

:gonk:

Is this something that worked at some point in the past? Say, back in the day there was only one worker thread, and the socket pool was actually a queue, and then one day they decided to add more worker threads without paying attention to how sockets were matched up with requests?

Or has it been broken since day one?

Argue
Sep 29, 2005

I represent the Philippines
I wasn't around on day 1 and I'm pretty glad for that, but my guess is that since the text in the response doesn't have any identifying data, nobody noticed the flaw since they only test the cases where the operation was successful. That and the fact that they never tried doing more than one request at a time before we came in.

I think I mentioned this before, but they don't have unit tests, and their devs are not in the habit of committing code. Sometimes, they will make single giant commits to add a feature, not finding or fixing anything they break, and one guy doesn't even commit at all--he just deploys to production himself.

Since we're just contractors we can't really do anything about this; we tried teaching them how to at least write automated tests so that they don't have to wait for a team of humans to find bugs after several hours of manual testing. There are layers of management approval to go to before they start doing that though so I really doubt they ever will. I'm just glad that next week is our last at this nightmare.

Tad Naff
Jul 8, 2004

I told you you'd be sorry buying an emoticon, but no, you were hung over. Well look at you now. It's not catching on at all!
:backtowork:

Ugg boots posted:

This line itself is horror gold.

Eh, that's really garden-variety for PHP. Though I think validators don't like name attributes on <form>s anymore.

king_kilr
May 25, 2007

ymgve posted:

Might not be a horror (except for the fact that they're probably not used parameterized queries) - I assume the function does something like "Check if gpc_magic_quotes is enabled, if not, do manual escape of all variables."

Uhh, escaping on insertion is definitely a horror. You don't escape input data. Ever.

NotShadowStar
Sep 20, 2000

king_kilr posted:

Uhh, escaping on insertion is definitely a horror. You don't escape input data. Ever.

Sometimes you don't have a choice. I had to work on a RedHat Enterprise Linux box for a long time. Here's the thing about RedHat: they gently caress with standard libraries however they want so they're pretty much incompatible with anything outside of RedHat land. In this case, they had their own version of PHP 4.1 in which they EXPLICITLY DISABLED THE MYSQLI FUNCTIONS at compile time. I tried recompiling my own version of PHP but something else would randomly break on the system when I did so. So I couldn't do bound parameter statements and had to be stuck escaping SQL statements.

Goddamn I'm so glad to not have to deal with that ever again.

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

Munkeymon posted:

I still think the string manipulation function I found at work is worse than Duff's, which is at least somewhat understandable.

edit: took me a while to find it

:bang:

Don't worry - it's still in use :)

Wow, that's impressive. Here's some zingers from an app I just got told I have to "fix":

code:
try {
  !!appState.length && (currentState = appState[0]) != null;
} catch(e) {}
and then later...

code:
switch(currentState) {
 
  case "mpTabSelect":
    showTabs();
    if (currentState == "mpTabSelect") {
      // much code
    }
   break;

  // and it goes on like that... and on... and on...
}

king_kilr
May 25, 2007

NotShadowStar posted:

Sometimes you don't have a choice. I had to work on a RedHat Enterprise Linux box for a long time. Here's the thing about RedHat: they gently caress with standard libraries however they want so they're pretty much incompatible with anything outside of RedHat land. In this case, they had their own version of PHP 4.1 in which they EXPLICITLY DISABLED THE MYSQLI FUNCTIONS at compile time. I tried recompiling my own version of PHP but something else would randomly break on the system when I did so. So I couldn't do bound parameter statements and had to be stuck escaping SQL statements.

Goddamn I'm so glad to not have to deal with that ever again.

Oh my god, it's like a meta-horror.

seiken
Feb 7, 2005

hah ha ha

Lumpy posted:


code:
try {
  !!appState.length && (currentState = appState[0]) != null;
} catch(e) {}

Woah, why have I never thought of the !! operator before? Since it doesn't do anything you can pepper it around your code to indicate the important bits!

leterip
Aug 25, 2004

seiken posted:

Woah, why have I never thought of the !! operator before? Since it doesn't do anything you can pepper it around your code to indicate the important bits!

Why stop at !! when you can prefix the really important bits with !!!!!!!!!!!!

qntm
Jun 17, 2009

seiken posted:

Woah, why have I never thought of the !! operator before? Since it doesn't do anything you can pepper it around your code to indicate the important bits!

I guess !! is equivalent to a boolean cast? Like, if the input was appState.length, which is an integer from 0 upwards, !!appState.length will be FALSE if appState.length was 0 and TRUE if appState.length was greater than 0.

I've seen code where !!! was used to call special attention to negation operations.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
Oh man I just had a great idea! Instead of using confusing syntax like /**/ and // to add my comments, I could just create a class for commenting:
code:
public class CommentDispatchManagerModel {
  public static void makeAComment(String theComment) {
    if (theComment == null) {
      // throw a NullPointerException if the variable "theComment" is null!
      // I keep getting stack overflows when I use this method on itself; I dunno why!
      throw new NullPointerException("you forgot to leave a comment!!!");
    }
    else {
      return;
    }
  }
}
Then if you want to make a comment somewhere, you can just do this:

code:
public class foo extends CommentDispatchManagerModel {
	public void bar() {
		{{{ makeAComment("hey you guys"); }}}
	}
}

_aaron
Jul 24, 2007
The underscore is silent.

Internet Janitor posted:

Oh man I just had a great idea! Instead of using confusing syntax like /**/ and // to add my comments, I could just create a class for commenting:
No god drat way.

seiken
Feb 7, 2005

hah ha ha

qntm posted:

I guess !! is equivalent to a boolean cast? Like, if the input was appState.length, which is an integer from 0 upwards, !!appState.length will be FALSE if appState.length was 0 and TRUE if appState.length was greater than 0.

Yeah, of course, I was just thinking about with boolean expressions I guess

POKEMAN SAM
Jul 8, 2004

_aaron posted:

No god drat way.

This is awesome because it makes debugging so much easier. If you're in a debug build, have it print comments to the debug console so you know what's going on, in English!

Zombywuf
Mar 29, 2008

Internet Janitor posted:

Oh man I just had a great idea! Instead of using confusing syntax like /**/ and // to add my comments, I could just create a class for commenting:

I really hope you are being serious here and did not find this in someone's code.

raminasi
Jan 25, 2005

a last drink with no ice

seiken posted:

Woah, why have I never thought of the !! operator before? Since it doesn't do anything you can pepper it around your code to indicate the important bits!

With operator overloading, all bets are off. Unary ! could reformat your hard drive.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

GrumpyDoctor posted:

With operator overloading, all bets are off. Unary ! could reformat your hard drive.

So two of them should bring your hard drive right back.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

pokeyman posted:

So two of them should bring your hard drive right back.

Good point! Better stick another couple in just to be safe.

BigRedDot
Mar 6, 2008

Suddenly I want a '¡' operator:

code:
¡aye->dios(mio)!

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

BigRedDot posted:

Suddenly I want a '¡' operator:

code:
¡aye->dios(mio)!

Aw, I thought scala allowed ¡ as an operator but apparently not.

ToxicFrog
Apr 26, 2008


^ Weird, it supports ! and everything in unicode I've thrown at it.

NotShadowStar
Sep 20, 2000

BigRedDot posted:

Suddenly I want a '¡' operator:

code:
¡aye->dios(mio)!

You can't define operators in Ruby... well, official Ruby, Rubinius is turtles all the way down so you can do whatever the gently caress you want. But 1.9 is complete Unicode so you can start going to crazytown that will make Windows users hate you even more.

code:
def ¡(n)
  return !!n
end

puts ¡"farts".reverse!

    
Array.class_eval do
  alias :&#8704; :each
  
  def &#931;
    return self.reduce(0) {|k, i| k + i}
  end
  
  def &#8715;(obj)
    return !!self.find {|n| n == obj }
  end
    
end

&#960; = Math::PI
def &#8730;(n)
  return Math.sqrt(n)
end

def &#8704;(obj)
  obj.each {|e| yield e}
end

arr = [1, 2, 3]

&#8704;(arr) {|n| puts n } #=> 1 2 3
arr.&#8715; 2 #=> true
arr.push &#960;
arr.&#8715; &#960; #=> true
arr.&#931; #=>9.141592653589793

&#8730; &#960; #=>1.7724538509055159
Well, looks like VB vomits on Unicode as well.

tripwire
Nov 19, 2004

        ghost flow
Only in code tags though. I don't know if thats funny or not.

pre:
def ¡(n)
  return !!n
end

puts ¡"farts".reverse!

    
Array.class_eval do
  alias :∀ :each
  
  def Σ
    return self.reduce(0) {|k, i| k + i}
  end
  
  def ∋(obj)
    return !!self.find {|n| n == obj }
  end
    
end

π = Math::PI
def √(n)
  return Math.sqrt(n)
end

def ∀(obj)
  obj.each {|e| yield e}
end

arr = [1, 2, 3]

∀(arr) {|n| puts n } #=> 1 2 3
arr.∋ 2 #=> true
arr.push π
arr.∋ π #=> true
arr.Σ #=>9.141592653589793

√ π #=>1.7724538509055159

pseudorandom name
May 6, 2007

Looks like that Fortran replacement that Sun was working on and didn't go anywhere.

Or APL, for that matter.

tripwire
Nov 19, 2004

        ghost flow
I'd like to see you program the game of life more tersely!

Only registered members can see post attachments!

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."

tripwire posted:

I'd like to see you program the game of life more tersely!



That program probably legitimately usesd the "domino" character, but I couldn't help but laugh when an APL listing seemed to contain undisplayable characters, even in a screenshot.

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

pseudorandom name posted:

Looks like that Fortran replacement that Sun was working on and didn't go anywhere.

Or APL, for that matter.

Fortress is/was pretty cool. I'm sad that Oracle will probably vaporize it. Guy Steele had a bunch of cool slides on it, where its parallelism could be tweaked to match the execution environment. I don't know if it was programmatically or manually, but it seemed like a good step forward. Get rid of accumulators, get rid of cons'es, program intent and not implementation, `for` loops are bad, etc.

Also, lots of people used APL, but many more now use K or J which are derivatives of APL without the bullshit escape sequences. Their propensity to look like line noise goes way beyond Perl, but they are extremely powerful languages if you are working with arrays.

Munkeymon
Aug 14, 2003

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



pseudorandom name posted:

Looks like that Fortran replacement that Sun was working on and didn't go anywhere.

I read one of their articles about it and the part about development methodology was pretty funny. "We sat Fortran programmers down and had them design a language. Turns out - and this is just shocking - they pretty much came up with Fortran!"

Lonely Wolf
Jan 20, 2003

Will hawk false idols for heaps and heaps of dough.

Munkeymon posted:

I read one of their articles about it and the part about development methodology was pretty funny. "We sat Fortran programmers down and had them design a language. Turns out - and this is just shocking - they pretty much came up with Fortran!"

This is clearly evidence that Fortran is the best programming language.

feedmegin
Jul 30, 2008

Monkeyseesaw posted:

We need a language where the only data type is a string and when you do non-string operations like arithmetic it converts it to some internal representation, does the bit shuffling, and returns the result as a string. All functions are simply extending the string type.

But you still have to explicitly declare your variables as strings JUST TO MAKE SURE.

SNOBOL was pretty much literally this. It's right there in the name, 'String Oriented Symbolic Language'.

Quebec Bagnet
Apr 28, 2009

mess with the honk
you get the bonk
Lipstick Apathy

Monkeyseesaw posted:

We need a language where the only data type is a string and when you do non-string operations like arithmetic it converts it to some internal representation, does the bit shuffling, and returns the result as a string. All functions are simply extending the string type.

But you still have to explicitly declare your variables as strings JUST TO MAKE SURE.

Extend INTERCAL to support Unicode :pseudo:

Adbot
ADBOT LOVES YOU

zeekner
Jul 14, 2007

code:
Thread doSomething = new Thread(){
     public void run(){
          //stuff
          }

doSomething.run();
Huh, why is the UI thread blocking for so long? :downs:

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