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
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:
php:
<?

    if(!$_POST){
        $_POST=&$_GET; // ughhhhhhhhh
    }
?>
Strangely, that wasn't my comment.

Adbot
ADBOT LOVES YOU

McGlockenshire
Dec 16, 2005

GOLLOCKS!
Oh yes, I know that pain. We have delightful nuggets like this one spread throughout our code.
php:
<?php
    $_GET['cat'] or $_GET['cat'] = $_POST['cat'];
    $_GET['cat'] or $_GET['cat'] = $_GET['id'];
    $_GET['cat'] or $_GET['cat'] = $_POST['id'];

This is what happens when your "lead" developer doesn't know what $_REQUEST is and writes new code without warnings and notices turned on.

MononcQc
May 29, 2007

McGlockenshire posted:

Oh yes, I know that pain. We have delightful nuggets like this one spread throughout our code.
php:
<?php
    $_GET['cat'] or $_GET['cat'] = $_POST['cat'];
    $_GET['cat'] or $_GET['cat'] = $_GET['id'];
    $_GET['cat'] or $_GET['cat'] = $_POST['id'];

This is what happens when your "lead" developer doesn't know what $_REQUEST is and writes new code without warnings and notices turned on.

to be fair, $_REQUEST also looks up in $_COOKIE and cookies are checked after $_POST. In certain cases it might be better to be explicit.

McGlockenshire
Dec 16, 2005

GOLLOCKS!

MononcQc posted:

to be fair, $_REQUEST also looks up in $_COOKIE and cookies are checked after $_POST. In certain cases it might be better to be explicit.
Oh yes, this is true. You should always be explicit when you know you want the data to come from the query string or from posted data, not caring is the #1 cause of CSRF... but when you don't care where the data comes from? Yeah, screw that copying bullshit.

Xenogenesis
Nov 8, 2005
Just saw this on some random website:

code:
  function makeArray() { 
      for (i = 0; i<makeArray.arguments.length; i++) 
  
  
  
 
         this[i + 1] = makeArray.arguments[i]; 
  } 
 
  function makeArray0() { 
      for (i = 0; i<makeArray0.arguments.length; i++) 
          this[i] = makeArray0.arguments[i]; 
  } 

McGlockenshire
Dec 16, 2005

GOLLOCKS!
Apparently this was needed because you couldn't directly invoke new Array objects in Javascript 1.0.

Javascript 1.1 was introduced in Netscape 3, released in 1996.

This is the problem with tutorial code. Inevitably, your code becomes obsolete and laughable and teaches people the now-wrong way to do things.

manero
Jan 30, 2006

Hey, does anyone know why everything on the page stopped worki

code:
  jQuery("a").click(function(event) {
   event.preventDefault();
   ...

Coffee Mugshot
Jun 26, 2010

by Lowtax

manero posted:

Hey, does anyone know why everything on the page stopped worki

code:
  jQuery("a").click(function(event) {
   event.preventDefault();
   ...

This is dedicated trolling.

indulgenthipster
Mar 16, 2004
Make that a pour over
I once worked on revamping a website where the guy had all the config files in a web-readable directory, .ini format. After poking around for a little bit I found that using the password "letmein" with ANY username allowed you full administrative access to the website.

manero
Jan 30, 2006

Rainbow Pony Deluxe posted:

This is dedicated trolling.

I wish I were ;(

Murodese
Mar 6, 2007

Think you've got what it takes?
We're looking for fine Men & Women to help Protect the Australian Way of Life.

Become part of the Legend. Defence Jobs.

VerySolidSnake posted:

I once worked on revamping a website where the guy had all the config files in a web-readable directory, .ini format. After poking around for a little bit I found that using the password "letmein" with ANY username allowed you full administrative access to the website.

One of the jobs we picked up a while ago that handled credit card donations for a charitable organisation would accept any username and/or password combo to get access to plaintext credit card details.

Opinion Haver
Apr 9, 2007

Topological sort in Perl using the garbage collector as the sorter.

Also, $[. $[ sets the index of the first element of arrays. So if $[ = 1, you get 1-indexed arrays. Mysteriously, however, $x[0] will always refer to the first element of the array if $[ is positive. If $[ is negative, then it refers to whatever element you'd get if you started counting from $[. And if $[ is negative, there's no way to get the last element, because -1 will be a valid index. Yeaaaah.

Also, you know those perl magic variables that have names like $^H (that's a literal carat followed by an H)? Well,
code:
$ perl
print $^H, "\n"; # again, literal carat H
print ${chr 8}; # the variable whose name is the backspace control character
256
256

Opinion Haver fucked around with this message at 09:51 on Dec 31, 2010

The Reaganomicon
Oct 14, 2010

by Lowtax
I think Perl qualifies in its entirety.

Opinion Haver
Apr 9, 2007

The Reaganomicon posted:

I think Perl qualifies in its entirety.

Hey, it's perfectly possible to write good Perl. It's just really easy to write crimes against humanity.

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip
There are a lot better things in Perl to complain about than poo poo you shouldn't even be poking at

perldoc perlvar posted:

$^H

WARNING: This variable is strictly for internal use only. Its availability, behavior, and contents are subject to change without notice.

Vino
Aug 11, 2010
Many times the people who complain about C/C++ being too easily abusable are the same ones who hide behind their perl script.

I once had the thought, "Why don't they have an International Obfuscated Perl Coding Contest" ? And then I realized, "It would be too easy."

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip
Perl golf is close enough to that really (although I guess golfing in any language tends to be unreadable, and completely inscrutable to folks who aren't adepts of that language).

quiggy
Aug 7, 2010

[in Russian] Oof.


Vino posted:

Many times the people who complain about C/C++ being too easily abusable are the same ones who hide behind their perl script.

I once had the thought, "Why don't they have an International Obfuscated Perl Coding Contest" ? And then I realized, "It would be too easy."

http://en.wikipedia.org/wiki/Obfuscated_Perl_Contest

Edit: Actually, just noticed that apparently it stopped in 2000. Oh well, it still did exist for a bit.

The Reaganomicon
Oct 14, 2010

by Lowtax

Vino posted:

Many times the people who complain about C/C++ being too easily abusable are the same ones who hide behind their perl script.

I once had the thought, "Why don't they have an International Obfuscated Perl Coding Contest" ? And then I realized, "It would be too easy."

pre:
                                                       #
                                                   sub j(\$){($
                     P,$V)=                      @_;while($$P=~s:^
                 ([()])::x){                    $V+=('('eq$1)?-32:31
           }$V+=ord(  substr(                 $$P,0,1,""))-74} sub a{
          my($I,$K,$  J,$L)=@_               ;$I=int($I*$M/$Z);$K=int(
         $K*$M/$Z);$J=int($J*$M             /$Z);$L=int($L*$M/$Z); $G=$
         J-$I;$F=$L-$K;$E=(abs($          G)>=abs($F))?$G:$F;($E<0) and($
          I,$K)=($J,$L);$E||=.01       ;for($i=0;$i<=abs$E;$i++ ){ $D->{$K
                  +int($i*$F/$E)      }->{$I+int($i*$G/$E)}=1}}sub p{$D={};$
                 Z=$z||.01;map{    $H=$_;$I=$N=j$H;$K=$O=j$H;while($H){$q=ord
                substr($H,0,1,"" );if(42==$q){$J=j$H;$L=j$H}else{$q-=43;$L =$q
              %9;$J=($q-$L)/9;$L=$q-9*$J-4;$J-=4}$J+=$I;$L+=$K;a($I,$K,$J,$ L);
              ($I,$K)=($J,$L)}a($I,$K,$N,$O)}@_;my$T;map{$y=$_;map{ $T.=$D->{$y}
              ->{$_}?$\:' '}(-59..59);$T.="\n"}(-23..23);print"\e[H$T"}$w= eval{
              require Win32::Console::ANSI};$b=$w?'1;7;':"";($j,$u,$s,$t,$a,$n,$o
              ,$h,$c,$k,$p,$e,$r,$l,$C)=split/}/,'Tw*JSK8IAg*PJ[*J@wR}*JR]*QJ[*J'.
               'BA*JQK8I*JC}KUz]BAIJT]*QJ[R?-R[e]\RI'.'}Tn*JQ]wRAI*JDnR8QAU}wT8KT'.
               ']n*JEI*EJR*QJ]*JR*DJ@IQ[}*JSe*JD[n]*JPe*'.'JBI/KI}T8@?PcdnfgVCBRcP'.
                '?ABKV]]}*JWe*JD[n]*JPe*JC?8B*JE};Vq*OJQ/IP['.'wQ}*JWeOe{n*EERk8;'.
                  'J*JC}/U*OJd[OI@*BJ*JXn*J>w]U}CWq*OJc8KJ?O[e]U/T*QJP?}*JSe*JCnTe'.
                   'QIAKJR}*JV]wRAI*J?}T]*RJcJI[\]3;U]Uq*PM[wV]W]WCT*DM*SJ'.  'ZP[Z'.
                      'PZa[\]UKVgogK9K*QJ[\]n[RI@*EH@IddR[Q[]T]T]T3o[dk*JE'.  '[Z\U'.
                        '{T]*JPKTKK]*OJ[QIO[PIQIO[[gUKU\k*JE+J+J5R5AI*EJ00'.  'BCB*'.
                             'DMKKJIR[Q+*EJ0*EK';sub h{$\ = qw(% & @ x)[int    rand
                              4];map{printf  "\e[$b;%dm",int(rand 6)+101-60*   ($w
                               ||0);system(  "cls")if$w ;($A,$S)=    ($_[1],   $
                                _[0]);($M,   @,)= split  '}';for(     $z=256
                                ;$z>0; $z   -=$S){$S*=   $A;p @,}      sleep$_
                                [2];while   ($_[3]&&($    z+=$ S)       <=256){
                                p@,}}("".   "32}7D$j"     ."}AG".       "$u}OG"
                                ."$s}WG"    ."$t",""      ."24}("        ."IJ$a"
                                ."}1G$n"    ."}CO$o"     ."}GG$t"        ."}QC"
                                 ."$h}"      ."^G$e"    ."})IG"          ."$r",
                                 "32}?"       ."H$p}FG$e}QG$r".          "}ZC"
                                 ."$l",          "28}(LC" .""            ."".
                                 "$h}:"           ."J$a}EG".             "$c"
                                 ."}M"             ."C$k}ZG".            "$e"
                                 ."}"             ."dG$r","18"          ."}("
                                ."D;"            ."$C"  )}{h(16         ,1,1,0
                               );h(8,          .98,0,0   );h(16         ,1,1,1)
                               ;h(8.0         ,0.98,0,     1);         redo}###
                             #written                                 060204 by
                           #liverpole                                  @@@@@@@
                        #@@@@@@@@@@@

evensevenone
May 12, 2001
Glass is a solid.
I'm fairly sure at least one of the IOCCC entries was also valid perl. Possibly more than one.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
A program that is valid in a number of languages simultaneously is called a polyglot. Here's a quine that is valid C, Ruby, Python, Perl and Brainfuck.

Parantumaton
Jan 29, 2009


The OnLy ThInG
i LoVe MoRe
ThAn ChUgGiNg SeMeN
iS gEtTiNg PaId To Be A
sOcIaL MeDiA sHiLl
FoR mIcRoSoFt
AnD nOkIa

Internet Janitor posted:

A program that is valid in a number of languages simultaneously is called a polyglot. Here's a quine that is valid C, Ruby, Python, Perl and Brainfuck.

That's nice. I think this one's nice too: http://d.hatena.ne.jp/ku-ma-me/20090916/p1

It's a quine that produces a valid program in another programming language eleven times - each being an unique language - and then finally when it reaches the last one, it jumps back to the original quine meaning that the compile&run loop is infinite. Example of execution:

code:
ruby QuineRelay.rb > QuineRelay.py
python QuineRelay.py > QuineRelay.pl
perl QuineRelay.pl > QuineRelay.lua
lua QuineRelay.lua > QuineRelay.ml
ocaml QuineRelay.ml > QuineRelay.hs
runghc QuineRelay.hs > QuineRelay.c
gcc -Wall -o QuineRelay QuineRelay.c && ./QuineRelay > QuineRelay.java
javac QuineRelay.java && java QuineRelay > QuineRelay.bf
beef QuineRelay.bf > QuineRelay.ws
wspace QuineRelay.ws > QuineRelay.unl
unlambda QuineRelay.unl > QuineRelay2.rb

Qwertycoatl
Dec 31, 2008

There was an extremely short polyglot quine in an IOCCC entry a while back:
Description
code:

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
How am I not surprised an MIT student submitted the null program to IOCCC with a smarmy writeup?

edit: VVV Alright, fine, I wasn't paying close enough attention to which parts came from the judges and what was the original submission. While "clever", the whole thing is still pretty low-effort by IOCC standards.

Internet Janitor fucked around with this message at 20:06 on Jan 1, 2011

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
Is this really so smarmy?

quote:

The world's smallest self-replicating program. Guaranteed. Produces a listing of itself on stdout.

Zombywuf
Mar 29, 2008

Internet Janitor posted:

edit: VVV Alright, fine, I wasn't paying close enough attention to which parts came from the judges and what was the original submission. While "clever", the whole thing is still pretty low-effort by IOCC standards.

Thankfully the competition is judged on cleverness and not effort. It's a competition for showing off how clever you are for Knuth's sake, lighten up.

Also I always liked:
code:
#include </dev/tty>

quote:

The program's capabilities are only limited by the abilities of the person compiling it.

Zombywuf fucked around with this message at 21:02 on Jan 1, 2011

ErIog
Jul 11, 2001

:nsacloud:
I don't think I saw this posted here, but it definitely fits with the recent discussion topics. Sony completely hosed up their crypto on the PS3 by not using a random salt with their ECDSA algorithm to sign their binaries, and the code that was implemented to update their binary rights revocation list ended up allowing hackers to copy anything they might want into part of one of the boot loaders.

There's quite a lot more to it than that, but those are definitely the highlights of this talk.

There's a very interesting business lesson here somewhere about how good customer relations strategies are more important to battling piracy than technical bells and whistles. When they get done with their talk you wonder how the PS3 wasn't hacked on day 1 with all the weird little holes in their security system, but I think the argument that they gave hackers most of what they wanted by allowing them to install Linux has some weight to it.

ErIog fucked around with this message at 18:42 on Jan 2, 2011

tef
May 30, 2004

-> some l-system crap ->
pedant: it isn't a salt, it is a nonce.

and I still think the strcmp thing by nintendo was funnier :v:

pseudorandom name
May 6, 2007

The strncmp() bug was amusing, but there's no way you can squint at the Wii's security design and say, "Yes, that could've worked."

The PS3 ECDSA implementation is a monumental fuckup, and is much more amusing as a result.

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

ErIog posted:

the argument that they gave hackers most of what they wanted by allowing them to install Linux has some weight to it.

Yeah, I'm actually kind of surprised about this. Or actually the part about the guys wanting to play games for free not being clever or motivated enough to accomplish anything.

Before that talk, I was under the impression that Sony's security system was actually pretty good.

evensevenone
May 12, 2001
Glass is a solid.

Wheany posted:

Before that talk, I was under the impression that Sony's security system was actually pretty good.
It's always good until it's broken.

Parantumaton
Jan 29, 2009


The OnLy ThInG
i LoVe MoRe
ThAn ChUgGiNg SeMeN
iS gEtTiNg PaId To Be A
sOcIaL MeDiA sHiLl
FoR mIcRoSoFt
AnD nOkIa

evensevenone posted:

It's always good until it's broken.

Sort of a horror in itself, the Finnish law states that software algorithm reverse engineering is illegal if the algorithm is "complex enough". Since laws are pedantic, "algorithm that is complex enough" is specified as "algorithm that can't be reverse engineered".

The Reaganomicon
Oct 14, 2010

by Lowtax

Parantumaton posted:

Sort of a horror in itself, the Finnish law states that software algorithm reverse engineering is illegal if the algorithm is "complex enough". Since laws are pedantic, "algorithm that is complex enough" is specified as "algorithm that can't be reverse engineered".

Do they define "reverse engineering" with equal pedantry??

Parantumaton
Jan 29, 2009


The OnLy ThInG
i LoVe MoRe
ThAn ChUgGiNg SeMeN
iS gEtTiNg PaId To Be A
sOcIaL MeDiA sHiLl
FoR mIcRoSoFt
AnD nOkIa

The Reaganomicon posted:

Do they define "reverse engineering" with equal pedantry??

If I remember correctly that was just a lame explanation about observing how something works and then replicating it. Yes, practically the law is saying that you shouldn't look into how things work - it was lobbied in by the DRM pushers but since the only politician that actually was interested to push the law and had enough political power to do it was an ex beauty pageant, it didn't really go well at all :)

ErIog
Jul 11, 2001

:nsacloud:

tef posted:

pedant: it isn't a salt, it is a nonce.

and I still think the strcmp thing by nintendo was funnier :v:

Well rdist says it's specifically not a nonce. Though, it doesn't say what to call it instead. It sounds like it's supposed to be more like a secret unique initialization vector, but not strictly just a nonce or a salt.

ErIog fucked around with this message at 22:25 on Jan 2, 2011

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

Parantumaton posted:

Sort of a horror in itself, the Finnish law states that software algorithm reverse engineering is illegal if the algorithm is "complex enough". Since laws are pedantic, "algorithm that is complex enough" is specified as "algorithm that can't be reverse engineered".

I'm just going to quote Wikipedia:
http://en.wikipedia.org/wiki/Lex_Karpela#Prohibition_of_circumventing_copy_protection

quote:

Prohibition of circumventing copy protection

The section 50 a § of the new law prohibits copying works for personal use if the work is protected by an "effective technical measure". Even an effective protection may be circumvented to watch or listen to the work, though.

Isn't a technical measure that can be circumvented by definition not effective? :2bong:

Opinion Haver
Apr 9, 2007

NSAttributedString is not a subclass of NSString, and RegexKit doesn't implement anything for NSAttributedString. So if you have one, and you want to do regex operations while preserving formatting, you have to convert it to a NSString, do your regex operations, then figure out the indices your regex matched on and then manually extract them from the original attributed string. Ugh.

Xenogenesis
Nov 8, 2005
Behold Haml, Rails' elegant, beautiful templating solution:

MVC best man posted:

code:

#round_strokes
  - titles = ["Holes in One","Albatrosses or better","Eagles","Birdies","Pars","Bogies","Double Bogies","Triple Bogies or worse"]
  - max = 16
  - exp = ((width.to_f - 90) / (rem = 800))

  - fold_limit = base = chunk = skip = 0
  - all = trip.attendances.sort_by {|a| a.golfer_handle.capitalize }
  - rnds = all[0].rounds
  - step = (all_s = all.size) - 1
  - if (all_s) > max
    - folds = (fold_limit = ((all_s - 1) / max)) + 1
    - step = (all_s / folds) - 1
    - if (xtra =  all_s.modulo(folds)) > 0
      - skip = folds - xtra
      - step += 1

  - 0.upto(fold_limit) do |i|
    - base += chunk
    - chunk = step
    - chunk -= 1      if (pad = (skip > i))
    - ats = all[base..(base + chunk)]
    - col = ats.size
    - col += 1 if pad
    - col_w = col_width(rem, exp, col)
    - col_c = col_num(rem, exp, col)
    - chunk += 1
    - players = ""
    - players = " -  for Players: #{base + 1} - #{base + chunk}"     if fold_limit > 0

    - strks = strokes = []
    - tot = [0,0,0,0,0,0,0,0,0]
    - ats.each do |at| strokes << (strks = at.get_strokes(-1))
      - 0.upto(8) { |j| tot[j] += strks[j] }
-# about 90% of the "template" goes on like this

OddObserver
Apr 3, 2009
What are all the - for?

Adbot
ADBOT LOVES YOU

Xenogenesis
Nov 8, 2005
In Haml lines beginning with "-" are interpreted as plain Ruby, with the expression's result discarded. Basically the equivalent in ERB is <% some.ish %>

Basically the overwhelming majority of this partial (half the views/partials for this resource are as bad or worse than this, with random incomprehensible 2 letter variable names, sometimes imported from a parent view) is horrible and random logic and isn't actually *outputting* anything: it's like babby's first day with PHP, except worse and in a templating system that goes out of its way to make this BS difficult

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