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
Zombywuf
Mar 29, 2008

So I'm currently having to explain to people that killing Postgres processes will in fact slow down, rather than speed up, transaction rollbacks.

Adbot
ADBOT LOVES YOU

Polio Vax Scene
Apr 5, 2009



A new low has been reached.

The newest API-of-the-month that I am working with has a method that requires a "location id" that represents a place somewhere in the world. This API stores all it's possible locations in a gigantic gently caress-off xml tree that goes Planet -> Continent -> Country -> County -> 'Place'. So Orlando, Florida would be Planet Earth -> North America -> USA -> Orange County -> Orlando and the location id would be something like 32805. Yes, Planet Earth is the first loving node in this tree, but that isn't even the best part. In order to actually find the location id you are searching for, instead of doing something sane like accepting county/place/etc as inputs, you provide a location id to search from, and the api returns everything on that branch to you. So Planet Earth is 1 and USA is 99. So if your location is in the USA, you provide 99 as the parent location and every location in the USA is given back in an xml, and you are expected to search through it. Not in the USA? Hope you know your location code or have twenty minutes to spare while you download the entire god drat database.

McGlockenshire
Dec 16, 2005

GOLLOCKS!

Manslaughter posted:

So Orlando, Florida would be Planet Earth -> North America -> USA -> Orange County -> Orlando

Apparently they've never encountered cities that are in multiple counties. Or, worse, they expect you to know which county you're looking for. Or, double-worse, they've never encountered countries that don't have intermediary units between country and city.

But hey, at least they're prepared for lunar and Mars colonies!

EntranceJew
Nov 5, 2009

Manslaughter posted:

A new low has been reached.

That doesn't sound like an API, that sounds like forfeit.

Scaevolus
Apr 16, 2007

https://github.com/marcusmoller/pyorpg-server/blob/master/src/database.py
Python code:
def loadItems():
    #checkItems()
    # get max classes
    itemAmount = database.getNumberOfRows('items')

    for i in range(0, itemAmount):
        query = database.sendQuery("SELECT * FROM items WHERE id=%i;" % (i+1))
        rows = query.fetchone()

        Item[i].name = rows['name']
        Item[i].pic = int(rows['pic'])
        Item[i].type = int(rows['type'])
        Item[i].data1 = rows['data1']
        Item[i].data2 = rows['data2']
        Item[i].data3 = rows['data3']

Bug Tracker posted:

Database auto increment should start from 0, not 1.

SQLite has 1 as default - this messes up the general database syntax.

Contra Duck
Nov 4, 2004

#1 DAD

Manslaughter posted:

A new low has been reached.

After so many time-related horrors it's refreshing to see the other dimensions getting a run.

Harik
Sep 9, 2001

From the hard streets of Moscow
First dog to touch the stars


Plaster Town Cop

Scaevolus posted:

https://github.com/marcusmoller/pyorpg-server/blob/master/src/database.py
Python code:
def loadItems():
    #checkItems()
    # get max classes
    itemAmount = database.getNumberOfRows('items')

    for i in range(0, itemAmount):
        query = database.sendQuery("SELECT * FROM items WHERE id=%i;" % (i+1))
        rows = query.fetchone()

        Item[i].name = rows['name']
        Item[i].pic = int(rows['pic'])
        Item[i].type = int(rows['type'])
        Item[i].data1 = rows['data1']
        Item[i].data2 = rows['data2']
        Item[i].data3 = rows['data3']

I think the bug report completely missing the problem with this code really makes this one.

Pollyanna
Mar 5, 2005

Milk's on them.


I don't get it. Is the problem with how he tries to get the SQL entry, or with submitting the query?

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

Pollyanna posted:

I don't get it. Is the problem with how he tries to get the SQL entry, or with submitting the query?

He gets a count of the rows in the table, then loops up to that count issuing a new query to get each row. This instead of, you know, just executing a single SELECT query on the database. It also makes the incredible assumption that the row ids are always continuous.

QuarkJets
Sep 8, 2008

Scaevolus posted:

https://github.com/marcusmoller/pyorpg-server/blob/master/src/database.py
Python code:
def loadItems():
    #checkItems()
    # get max classes
    itemAmount = database.getNumberOfRows('items')

    for i in range(0, itemAmount):
        query = database.sendQuery("SELECT * FROM items WHERE id=%i;" % (i+1))
        rows = query.fetchone()

        Item[i].name = rows['name']
        Item[i].pic = int(rows['pic'])
        Item[i].type = int(rows['type'])
        Item[i].data1 = rows['data1']
        Item[i].data2 = rows['data2']
        Item[i].data3 = rows['data3']

From the same project:

code:
def checkItems():
    for i in range(MAX_ITEMS):
        print "probably not necassary"
MAX_ITEMS is defined as 255, so this function just prints a line 255 times. Nevermind the fact that MAX_ITEMS and Item are defined in the polluted-as-gently caress global namespace or that Items is just a list of 255 structure objects. The same thing is done for basically everything else; 255 empty instances of the NPC class held in an NPC list, 255 empty instances of the Spell class held in a Spells list, etc

nielsm
Jun 1, 2009



This all sounds like someone read a 25 year old book on writing a MUD in Turbo Pascal and thought everything sounded like a great idea. Smart enough go translate things from TP and block-structured files into Python and SQL, too dumb to realise why things were being done the way they were.

hackbunny
Jul 22, 2007

I haven't been on SA for years but the person who gave me my previous av as a joke felt guilty for doing so and decided to get me a non-shitty av

Amberskin posted:

Is it posible to back-translate (decompile) every posible chunk of bytecode? That is for sure not the case with old-school compiled code... the optimizations usually mangle the object code in ways that just make sense in assembly, but not in a high level language.

Definitely not, I have personal experience with this. Turns out the Java stack is untyped, and the same location can hold an object or an integer or a boolean, and optimizing compilers will reuse stack locations, and decompilers don't have the faintest idea how to handle that and will produce horrible broken code that doesn't even compile

Jewel
May 2, 2009

This is technically not a horror and just - in my opinion - a badly designed language feature, but gently caress it regardless. Javascript's sort function.

JavaScript code:
["Peach", "Banana", "Apple"].sort();
// ["Apple", "Banana", "Peach"]
Reasonable. How about numbers?

JavaScript code:
[5, 10, 1].sort();
// [1, 10, 5]
:raise: Oh cool that's reasonable, it's not like most people find themselves needing to sort numeric values more often or anything.

Let's see what the docs have to say:

http://www.w3schools.com/jsref/jsref_sort.asp posted:

The sort order can be either alphabetic or numeric, and either ascending or descending.

Default sort order is alphabetic and ascending.

Oh. So default sort order is alphabetic. But it can be numeric, yes? Okay what's the argument to swap that?

http://www.w3schools.com/jsref/jsref_sort.asp posted:

To perform a numeric sort, you must pass a function as an argument when calling the sort method.

The function specifies whether the numbers should be sorted ascending or descending.

It can be difficult to understand how this function works, but see the examples at the bottom of this page.

Wait, you said it can be alphabetic or numeric, descending or ascending, not that you have to manually do it yourself?

http://www.w3schools.com/jsref/jsref_sort.asp posted:

Example

Sort numbers (numerically and ascending):

JavaScript code:
var points = [40,100,1,5,25,10];
points.sort(function(a,b){return a-b});

For something you have to do pretty often in a lot of algorithms in every topic, missing a language feature like this and making a user do that, is pretty :gonk: to me.

Edit:

JavaScript code:
function sortFuncAsc()(a,b)
{
	return a-b;
}

var points = [40,100,1,5,25,10];
points.sort(sortFuncAsc);
// [1, 5, 10, 25, 40, 100]

var points = ["apple", "banana", "pear", "zebra", "peach", "35", "", 53];
points.sort(sortFuncAsc);
// ["pear", "banana", "zebra", "peach", "35", "", "apple", 53]
Hm. Hm???

Edit2: That last sort returns an unsorted list in chrome devtools.

Jewel fucked around with this message at 16:21 on Jan 9, 2014

..btt
Mar 26, 2008
That is pretty backward, though to be fair you have to bear in mind it was never intended to be a general purpose programming language, just a way to script simple stuff in the browser, where arguably, at its inception, sorting a list of text options was probably a much more common use-case.

E: well, your edited in final example certainly is interesting (but that's not the result I get in V8)

..btt fucked around with this message at 15:40 on Jan 9, 2014

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.
The - operator on non-numbers returns NaN, which certainly fucks with the sort function. Chalk up yet another place where a-b isn't a great comparator.

..btt
Mar 26, 2008
A better result than php at least :v:

Civil Twilight
Apr 2, 2011

The horror is compounded by use of w3schools.

Jewel
May 2, 2009

Civil Twilight posted:

The horror is compounded by use of w3schools.

Oh yeah I did say "The docs" then linked to w3schools didn't I. Well. Still. It's the "recommended method" and it's garbage :colbert:

Polio Vax Scene
Apr 5, 2009



That's what typeof() is for. I actually like that the sorting is left to the developer, because you can't blame the language for doing it wrong/inserting crap data into your sort.

substitute
Aug 30, 2003

you for my mum
I apologize in advance.

So I've been dealing with a contracted (mostly JavaScript) developer at work for a few years now, because of some dumb Flash project he was brought in for originally, that's now spun out of control into him having influence all over poo poo. A landing page for an ad was not loading on the live site a bit ago, so I go to check the log and just curious, I open the file. This page is basically just a bunch of thumbnails that open the larger versions in a lightbox.

(w/ my changes to obscure company specifics)

php:
<?
$pagetitle = 'Redacted page title poo poo';
$meta_keywords = '';
$meta_desc = 'Redacted meta poo poo';
$pre_page_data="some-text-poo poo";


/// EDIT ABOVE
define("LANDING",true);

require($_SERVER['INCLUDES_LOCAL'].'/header.php');

//===============================================================
//-- BEGIN: Include Statements  ---------------------------------
//===============================================================
// Data Structures
require_once(XX_LIBRARY_CORE.'/nodeInfo.php');
//===============================================================
//-- END: Include Statements  -----------------------------------
//===============================================================

//===============================================================
//-- BEGIN: Import Statements  ----------------------------------
//===============================================================
// Data Structures
use _global\_core\nodeinfo\FabricNodeInfo;
use _global\_core\nodeinfo\GalleryNodeInfo;


// Displays
//===============================================================
//-- END: Import Statements  ------------------------------------
//===============================================================

//===========================================================
//-- BEGIN: Class: LandingStandardData  ---------------------
//===========================================================
class LandingStandardData{
    
    // BEGIN: Data Memembers
    const MEDIA_IMG='img';
    const MEDIA_HTML='html';
    
    public $css='';
    public $img;
    public $html;
    public $name;
    public $fuckingperson;
    public $description;
    public $media;
    // END: Data Memembers
    
    /*-------------------------------------------------------
        BEGIN: CONSTRUCTOR
    -------------------------------------------------------*/
    // LandingStandardData:
    // Constructor
    function __construct(){
        //trace("LandingStandardData: CONSTR");
    }
    /*-------------------------------------------------------
        END: CONSTRUCTOR
    -------------------------------------------------------*/
    
    
    /*-------------------------------------------------------
        BEGIN: DECONSTRUCTOR
    -------------------------------------------------------*/
    // __destructor:
    // Deconstructs object.
    public function __destructor(){
        //trace("LandingStandardData: DECONSTRUCTOR");
        $this->css=NULL;
        $this->img=NULL;
        $this->html=NULL;
        $this->name=NULL;
        $this->fuckingperson=NULL;
        $this->description=NULL;
        $this->media=NULL;
        //parent::__destructor();
    }
    /*-------------------------------------------------------
        END: DECONSTRUCTOR
    -------------------------------------------------------*/
}
//===========================================================
//-- END: Class: LandingStandardData  -----------------------
//===========================================================

// Detail
$pfx_detail=CDN_IMG_SERVER . '/_images/_some-loving-path/' . $pre_page_data;

// Fabric
$pfx_fabric=CDN_IMG_SERVER . GalleryNodeInfo::PREFIX_IMAGE_FABRIC . FabricNodeInfo::PREFIX_IMAGE_SWATCH;
$sfx_fabric='.jpg' . GalleryNodeInfo::RASTER_DATA_BITMAP_FABRIC;

// Related
$pfx_related=CDN_IMG_SERVER . '/_images/_some-loving-path/';
$pfx_related_thumb=$pfx_related.'thumbs/';
$rd_related_thumb=GalleryNodeInfo::RASTER_DATA_BITMAP_RELATED;

// Video
$pfx_video='/_data/video-data.php?video=';
$sfx_video='&amp;amp;autohide=1&amp;amp;showinfo=0&amp;amp;autoplay=1&amp;amp;rel=0';

// Data Structures
$data_redacted= array();
$data_related= array();

// BEGIN: redacted Mention Data

//// item: redacted item name
array_push($data_redacted, $ds=new LandingStandardData());
$ds->media=LandingStandardData::MEDIA_IMG;
$ds->img='redacted.jpg';
$ds->name='Redacted Name';
$ds->fuckingperson='Redacted person name';

//// item: redacted item name
array_push($data_redacted, $ds=new LandingStandardData());
$ds->media=LandingStandardData::MEDIA_IMG;
$ds->img='redacted.jpg';
$ds->name='Redacted Name';
$ds->fuckingperson='Redacted person name';

//// item: FOS video
//// item: redacted item name
array_push($data_redacted, $ds=new LandingStandardData());
$ds->media=LandingStandardData::MEDIA_IMG;
$ds->img='redacted.jpg';
$ds->name='Redacted Name';
$ds->fuckingperson='Redacted person name';
// END: redacted Mention Data

// BEGIN: Related Data
//// item: redacted item name
array_push($data_redacted, $ds=new LandingStandardData());
$ds->media=LandingStandardData::MEDIA_IMG;
$ds->img='redacted.jpg';
$ds->name='Redacted Name';
$ds->fuckingperson='Redacted person name';

//// item: redacted item name
array_push($data_redacted, $ds=new LandingStandardData());
$ds->media=LandingStandardData::MEDIA_IMG;
$ds->img='redacted.jpg';
$ds->name='Redacted Name';
$ds->fuckingperson='Redacted person name';

//// item: redacted item name
array_push($data_redacted, $ds=new LandingStandardData());
$ds->media=LandingStandardData::MEDIA_IMG;
$ds->img='redacted.jpg';
$ds->name='Redacted Name';
$ds->fuckingperson='Redacted person name';

//// item: redacted item name
array_push($data_redacted, $ds=new LandingStandardData());
$ds->media=LandingStandardData::MEDIA_IMG;
$ds->img='redacted.jpg';
$ds->name='Redacted Name';
$ds->fuckingperson='Redacted person name';

//// item: redacted item name
array_push($data_redacted, $ds=new LandingStandardData());
$ds->media=LandingStandardData::MEDIA_IMG;
$ds->img='redacted.jpg';
$ds->name='Redacted Name';
$ds->fuckingperson='Redacted person name';

//// item: redacted item name
array_push($data_redacted, $ds=new LandingStandardData());
$ds->media=LandingStandardData::MEDIA_IMG;
$ds->img='redacted.jpg';
$ds->name='Redacted Name';
$ds->fuckingperson='Redacted person name';

//// item: redacted item name
array_push($data_redacted, $ds=new LandingStandardData());
$ds->media=LandingStandardData::MEDIA_IMG;
$ds->img='redacted.jpg';
$ds->name='Redacted Name';
$ds->fuckingperson='Redacted person name';

//// item: redacted item name
array_push($data_redacted, $ds=new LandingStandardData());
$ds->media=LandingStandardData::MEDIA_IMG;
$ds->img='redacted.jpg';
$ds->name='Redacted Name';
$ds->fuckingperson='Redacted person name';

//// item: redacted item name
array_push($data_redacted, $ds=new LandingStandardData());
$ds->media=LandingStandardData::MEDIA_IMG;
$ds->img='redacted.jpg';
$ds->name='Redacted Name';
$ds->fuckingperson='Redacted person name';

//// item: redacted item name
array_push($data_redacted, $ds=new LandingStandardData());
$ds->media=LandingStandardData::MEDIA_IMG;
$ds->img='redacted.jpg';
$ds->name='Redacted Name';
$ds->fuckingperson='Redacted person name';

//// item: redacted item name
array_push($data_redacted, $ds=new LandingStandardData());
$ds->media=LandingStandardData::MEDIA_IMG;
$ds->img='redacted.jpg';
$ds->name='Redacted Name';
$ds->fuckingperson='Redacted person name';

//// item: redacted item name
array_push($data_redacted, $ds=new LandingStandardData());
$ds->media=LandingStandardData::MEDIA_IMG;
$ds->img='redacted.jpg';
$ds->name='Redacted Name';
$ds->fuckingperson='Redacted person name';

//// item: redacted item name
array_push($data_redacted, $ds=new LandingStandardData());
$ds->media=LandingStandardData::MEDIA_IMG;
$ds->img='redacted.jpg';
$ds->name='Redacted Name';
$ds->fuckingperson='Redacted person name';

//// item: redacted item name
array_push($data_redacted, $ds=new LandingStandardData());
$ds->media=LandingStandardData::MEDIA_IMG;
$ds->img='redacted.jpg';
$ds->name='Redacted Name';
$ds->fuckingperson='Redacted person name';

//// item: redacted item name
array_push($data_redacted, $ds=new LandingStandardData());
$ds->media=LandingStandardData::MEDIA_IMG;
$ds->img='redacted.jpg';
$ds->name='Redacted Name';
$ds->fuckingperson='Redacted person name';

//// item: redacted item name
array_push($data_redacted, $ds=new LandingStandardData());
$ds->media=LandingStandardData::MEDIA_IMG;
$ds->img='redacted.jpg';
$ds->name='Redacted Name';
$ds->fuckingperson='Redacted person name';

//// item: redacted item name
array_push($data_redacted, $ds=new LandingStandardData());
$ds->media=LandingStandardData::MEDIA_IMG;
$ds->img='redacted.jpg';
$ds->name='Redacted Name';
$ds->fuckingperson='Redacted person name';
// END: Related Data
?>

<!-- BEGIN: appContainer -->
<div id="appContainer" class="gallery">
<!-- BEGIN: rgnDetail -->
<div id="rgnDetail" class="gallery-detail">
<section>
<!-- BEGIN: scrnDetail -->
<div id="scrnDetail" class="gallery-detail fos">
<!-- BEGIN: displaySet -->
<div class="displaySet">


<!-- BEGIN: imageArea -->
<div class="imageArea">
<div class="imageContainer">
<div class="thumbImg">
<span class="data"><img src="<?=$pfx_detail;?>.jpg" alt="" class="th_detail"></span>
</div>
<img class="scrolldown" src="<?= CDN_IMG_SERVER?>/_images/_global/instructions/scroll-down.png" width="43" alt="SCROLL DOWN" title="SCROLL DOWN">
</div>
</div>
<!-- END: imageArea -->

<!-- BEGIN: fixedwidth -->
<div class="fixedwidth abstract_top">

<!-- BEGIN: menubar -->
<div class="menubar">

<!-- BEGIN: utilitynav -->
<div class="utilitynav chromeGrey disabled">
<nav>
<ul class="navigation">
<br class="clear" />
</ul>
</nav>
</div>
<!-- END: utilitynav -->

<!-- BEGIN: cartnav -->
<div class="cartnav chromeGrey">
<nav>
<ul class="navigation">
<br class="clear" />
</ul>
</nav>
</div>
<!-- END: cartnav -->

<div class="clear"></div>
</div>
<!-- END: menubar -->

<div class="clear"></div>

<!-- BEGIN: left column -->
<div class="column2 left">
<!-- BEGIN: infoPanel -->
<div class="infoPanel">

<? /*
<!-- BEGIN: share -->
<div class="data share">
<p><strong class="txt_lrg">Share</strong> <span class="txt_sm">this image.</span></p>

include(INCLUDES.'/social-media-buttons.php'); 
 
<br class="clear" />
</div>
<!-- END: share -->
 //*/ ?>
 
<h1>Redacted Title</h1>

<!-- BEGIN: copy -->
<div class="copy">
<p>Redacted content. This poo poo expands in a single line WAY off the page.</p>

<p>Redacted content. This poo poo expands in a single line WAY off the page.</p>

<p>Redacted content. This poo poo expands in a single line WAY off the page.</p>
</div>
<!-- END: copy -->


</div>
<!-- END: infoPanel -->
</div>
<!-- END: left column -->

<!--// BEGIN: right column //-->
<div class="column2 right last">

<!--// BEGIN: redacted-mention //-->
<div class="redacted-mention">
<!--// BEGIN: thumbDisplaySet //-->
<ul class="thumbDisplaySet">
<?
$html='';
$length=sizeof($data_redacted);
for($i=0; $i<$length; $i++){
    $ds=$data_redacted[$i];
    $media=$ds->media;
    $lbd='data-light-box-type="'.$media.'" ';


    switch($media){
    default:
    case LandingStandardData::MEDIA_IMG:
    $lbd.='data-light-box-url="'.$pfx_related.$ds->img.'" ';
    $copy='<h1 class="name"><a '.$lbd.'><span class="label">Redacted Text</span> &ldquo;'.$ds->name.'&rdquo;</a></h1>';
    $copy.='<h2 class="fuckingperson" ><a '.$lbd.'>by '.$ds->fuckingperson.'</a></h2>';
    break;
    
    case LandingStandardData::MEDIA_HTML:
    $lbd.='data-light-box-url="'.$ds->html.'" ';
    $copy='<h1 class="name"><a '.$lbd.'><span class="label">Video &ndash;</span></a></h1>';
    $copy.='<h2 class="fuckingperson" ><a '.$lbd.'>'.$ds->description.'</a></h2>';
    break;
    }
    
    $html.='<!--// BEGIN: item //-->';
    $html.='<li class="thumbDisplayItem '.$ds->css.'">';
    $html.='<section>';
    $html.='<div class="thumb"><div class="thumbImg">';
    $html.='<a '.$lbd.'><span class="data"><img src="'.$pfx_related_thumb.$ds->img.'" /></span></a>';
    $html.='</div></div>';
    $html.=$copy;
    $html.='</section>';
    $html.='</li>';
    $html.='<!--// END: item //-->';
    
}
echo $html;
?>
<br class="clear" />
</ul>
<!--// END: thumbDisplaySet //-->
</div>
<!--// END: redacted-mention //-->

</div>
<!--// END: right column //-->

<div class="clear"></div>
</div>
<!--// END: fixedwidth //-->


<!--// BEGIN: relatedContainer //-->
<div id="relatedContainer" class="dark">
<div class="related content fixedwidth abstract_btm">
<h2>More Bullshit Here</h2>

<? /*
<!--// BEGIN: thumbDisplaySet (video) //-->
<ul class="thumbDisplaySet">
<!--// BEGIN: item //-->
<li class="thumbDisplayItem video">
<section>
<div class="thumb"><div class="thumbImg">
THIS IS A SINGLE LINE OF CODE THAT I'VE BROKEN UP FOR THE POST
<a data-light-box-type="html" data-light-box-title="" 
data-light-box-url="/_data/video-data.php?video=redactedYouTubeID&amp;amp;autohide=1&amp;amp;showinfo=0&amp;amp;autoplay=1&amp;amp;rel=0">
<span class="data">
<img src="<?=$pre_related_thumb?>-vid.jpg"></span></a>
END SINGLE LINE
</div></div>
</section>
</li>
<!--// END: item //-->
<br class="clear" />
</ul>
<!--// END: thumbDisplaySet (video) //-->
//*/ ?>

<!--// BEGIN: thumbDisplaySet (image) //-->
<ul class="thumbDisplaySet">
<?
$html='';
$length=sizeof($data_related);
for($i=0; $i<$length; $i++){
    $ds=$data_related[$i];
    
    $lbd='data-light-box-type="img" data-light-box-url="'.$pfx_related.$ds->img.'"';
    
    $html.='<!--// BEGIN: item //-->';
    $html.='<li class="thumbDisplayItem">';
    $html.='<section>';
    $html.='<div class="thumb"><div class="thumbImg">';
    $html.='<a '.$lbd.'><span class="data"><img src="'.$pfx_related_thumb.$ds->img.'" /></span></a>';
    $html.='</div></div>';
    $html.='<h1 class="name"><a '.$lbd.'>'.$ds->name.'</a></h1>';
    $html.='<h2 class="fuckingperson" ><a '.$lbd.'>by '.$ds->fuckingperson.'</a></h2>';
    $html.='</section>';
    $html.='</li>';
    $html.='<!--// END: item //-->';
    
}
echo $html;
?>
<br class="clear" />
</ul>
<!--// END: thumbDisplaySet (image) //-->
</div>
</div>
<!--// END: relatedContainer //-->

</div>
<!-- END: displaySet -->
</div>
<!-- END: scrnDetail -->
</section>
</div>
<!-- END: rgnDetail -->
</div>
<!-- END: appContainer -->


<? require(INCLUDES.'/footer.php'); ?>

substitute fucked around with this message at 17:34 on Jan 9, 2014

Steve French
Sep 8, 2003

Manslaughter posted:

That's what typeof() is for. I actually like that the sorting is left to the developer, because you can't blame the language for doing it wrong/inserting crap data into your sort.

Allowing use of a caller-specified comparator function does not preclude the language from having sane default sort behavior.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
I think Javascript's default is about as sane as you can get once you decide that comparing values of different types is legal and meaningful. The obvious error-case for trying to do the "right" thing and aort numbers numerically is an array like [10, 2, '10', '2'], which wouldn't have a total ordering.

PHP's solution of treating strings that happen to contain numbers as numbers is far more problematic.

McGlockenshire
Dec 16, 2005

GOLLOCKS!

substitute posted:

I apologize in advance.

So I've been dealing with a contracted (mostly JavaScript) developer at work for a few years now, because of some dumb Flash project he was brought in for originally, that's now spun out of control into him having influence all over poo poo. A landing page for an ad was not loading on the live site a bit ago, so I go to check the log and just curious, I open the file. This page is basically just a bunch of thumbnails that open the larger versions in a lightbox.

(w/ my changes to obscure company specifics)

Jesus.

You're dealing with an architecture astronaut with a bunch of cargo cult poo poo thrown in for good measure.

necrotic
Aug 2, 2005
I owe my brother big time for this!

..btt posted:

A better result than php at least :v:

http://php.net/natsort :suicide:

Pollyanna
Mar 5, 2005

Milk's on them.


Bognar posted:

He gets a count of the rows in the table, then loops up to that count issuing a new query to get each row. This instead of, you know, just executing a single SELECT query on the database. It also makes the incredible assumption that the row ids are always continuous.

Oh. That looks like he's just thinking in terms of Python. I can see someone doing that if they don't understand SQL/how to query SQL from Python correctly.

Wait, no, he's got an actual query there. I have no idea then :pwn:

EAT THE EGGS RICOLA
May 29, 2008

One of the owners of my firm hired some web dev company to do something which would have taken me 4-5 hours to do, without checking in with me before doing this. They billed us $25k and when I went to sign up for the site to give it a test, they emailed me my password in plaintext, then emailed it to me in plaintext again when I requested a password reset.

Hoorayyyyyy

Amberskin
Dec 22, 2013

We come in peace! Legit!

McGlockenshire posted:

Jesus.

You're dealing with an architecture astronaut with a bunch of cargo cult poo poo thrown in for good measure.

Thanks for that reference. I didn't know that term, but the concept is SO familiar...

Polio Vax Scene
Apr 5, 2009



Today's ibuprofen brought to you buy a javascript library that automatically grabs config files based on the user's language (ex. "en-US.js") and a web application that doesn't allow you to upload files with a hyphen in the name for an unknown reason (ex. "en-US.js"). Put em together in one room and it's a crazy wacky sitcom coming this summer on fox!

Steve French
Sep 8, 2003

Why are you uploading the javascript files via a web application?

Deus Rex
Mar 5, 2005

Plorkyeran posted:

I think Javascript's default is about as sane as you can get once you decide that comparing values of different types is legal and meaningful. The obvious error-case for trying to do the "right" thing and aort numbers numerically is an array like [10, 2, '10', '2'], which wouldn't have a total ordering.

It would if you ordered values of different types by comparing typeof lexographically :colbert:

Steve French
Sep 8, 2003

Also,

code:
>>> sorted([10, 2, 10, 2])
[2, 2, 10, 10]
>>> sorted([10, 2, '10', '2'])
[2, 10, '10', '2']
edit: looks pretty insane to me

NFX
Jun 2, 2008

Fun Shoe

Steve French posted:

Also,

code:
>>> sorted([10, 2, 10, 2])
[2, 2, 10, 10]
>>> sorted([10, 2, '10', '2'])
[2, 10, '10', '2']
edit: looks pretty insane to me

Numbers sort lower than strings, "10" sorts lower than "2" (it's not a natural sort). Seems sane?
code:
>>> sorted(["10", "2", 10, 2])
[2, 10, '10', '2']
>>> cmp(0, "0")
-1
I mean, it's arbitrary but it's better than mixing types (let the type class's cmp-overload handle it).

shrughes
Oct 11, 2008

(call/cc call/cc)

Jewel posted:

This is technically not a horror and just - in my opinion - a badly designed language feature, but gently caress it regardless. Javascript's sort function.

JavaScript code:
["Peach", "Banana", "Apple"].sort();
// ["Apple", "Banana", "Peach"]
Reasonable. How about numbers?

JavaScript code:
[5, 10, 1].sort();
// [1, 10, 5]

They were probably emulating Perl behavior or other old programming language behavior.

Steve French
Sep 8, 2003

NFX posted:

Numbers sort lower than strings, "10" sorts lower than "2" (it's not a natural sort). Seems sane?
code:
>>> sorted(["10", "2", 10, 2])
[2, 10, '10', '2']
>>> cmp(0, "0")
-1
I mean, it's arbitrary but it's better than mixing types (let the type class's cmp-overload handle it).

Sorry, my sarcasm wasn't sufficiently clear. I think it's much more sane behavior than JavaScript's given the posed constraint that it doesn't fail altogether (which IMO is the best behavior, you shouldn't be sorting on heterogenous collections without specifying a comparator yourself)

substitute
Aug 30, 2003

you for my mum

McGlockenshire posted:

Jesus.

You're dealing with an architecture astronaut with a bunch of cargo cult poo poo thrown in for good measure.

As Amberskin said, thank you for this term. It's perfect. I'm sharing it with the new developer in my shared office tomorrow. He'll love that.

Plorkyeran
Mar 22, 2007

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

Steve French posted:

Sorry, my sarcasm wasn't sufficiently clear. I think it's much more sane behavior than JavaScript's given the posed constraint that it doesn't fail altogether (which IMO is the best behavior, you shouldn't be sorting on heterogenous collections without specifying a comparator yourself)

Python lets you compare values of different types, but doesn't give meaningful results. The implicit conversions are what makes it impossible to have a sane default array sort (and JS's choice is at least consistent, unlike most of the obvious options).

Polio Vax Scene
Apr 5, 2009



Steve French posted:

Why are you uploading the javascript files via a web application?

The javascript files are actually stored as base 64 strings in a sql database. Yep.

Steve French
Sep 8, 2003

Except that sorting an array of integers lexicographically is not sane. Maybe giving not-meaningful results when sorting a heterogeneous array when an explicit comparator is not given, as python does, is not sane either.

However, I care a lot more about behavior when doing something reasonable (e.g. sorting an array of integers), than I do about behavior when doing something unreasonable (e.g. sorting an array of varying types without explicitly defining a comparison function for sorting.

Furthermore, it's not really clear that in the general case JavaScript's behavior is meaningful either. When the specific example is all numbers, either as integers or strings, yeah, JavaScript looks like it behaves reasonably (at the expense of sanity when sorting just numbers). But what is a meaningful sort of the following, and what would you expect JavaScript to return?

[1, 2, 5, 3,[3, 4], { "foo": "baz" }, { "foo": "bar" }, "things", 56.23, "[object Object]", "[object Objecs]"].sort()

Volmarias
Dec 31, 2002

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

Manslaughter posted:

The javascript files are actually stored as base 64 strings in a sql database. Yep.

God, just give up at this point. You're living in a tdwtf article.

Adbot
ADBOT LOVES YOU

Zaphod42
Sep 13, 2012

If there's anything more important than my ego around, I want it caught and shot now.

Manslaughter posted:

The javascript files are actually stored as base 64 strings in a sql database. Yep.

Got a good laugh out of that one

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