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
tyrelhill
Jul 30, 2006

I can read the code fine so i dont see anything wrong with it

Adbot
ADBOT LOVES YOU

Sedro
Dec 31, 2008

xzzy posted:

Too bad they haven't come up with a way to deal with the fact that the browser is under the control of the user.

http://www.prioritized.net/blog/re-enabling-password-pasting-on-annoying-web-forms

If you're non-technical, you might paste from your password manager into the address bar, then drag and drop it from there into the input field.

Then yahoo has your bank password, because someone decided it's safe to broadcast the contents of the address bar.

UraniumAnchor
May 21, 2006

Not a walrus.

Took me too long to see the brace mess on the right hand side so I thought it was some kind of clever editor plugin, then I saw it and realized what was actually happening. :catstare:

I actually like Python and I still think that's terrible.

JawnV6
Jul 4, 2004

So hot ...

Sedro posted:

Then yahoo has your bank password, because someone decided it's safe to broadcast the contents of the address bar.
history | grep -A1 sudo

Polio Vax Scene
Apr 5, 2009



Sedro posted:

If you're non-technical, you might paste from your password manager into the address bar, then drag and drop it from there into the input field.

Then yahoo has your bank password, because someone decided it's safe to broadcast the contents of the address bar.

But autocomplete is such a good feature! It totally doesn't send out a web request every time I type a new character!

TooMuchAbstraction
Oct 14, 2012

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

A sufficiently determined programmer can write Python in any language? :shepface:

qntm
Jun 17, 2009

Eastern Polish Christmas Tree Notation:

Java code:
public
DataPair[] getHotelInformation(String hotelId, String informationId)
                                      {
                                        return getHotelInfo("EN", hotelId, informationId);
                                      }

public
DataPair[] getHotelInformation(String lang, String hotelId, String informationId)
                                      {

                           String key = "_HOINF_"+lng+"_"+hotelId+"_"+informationId;
                       DataPair[] tbl = (DataPair[])csh.getObject(key);
                         if(tbl!=null)  return tbl;

                        Connection cn = null;
           OracleCallableStatement cs = null;
                                  try {
                           String qry = " begin HotelServices.getHotelInfo(?, ?, ?, ?, ?); end; ";
                               logger . debug("---"+qry+" "+hotelId+" "+informationId);
                                   cn = DriverManager.getConnection("jdbc:weblogic:pool:oraclePool",null);
                                   cs = (OracleCallableStatement)cn.prepareCall(qry);
                                   cs . registerOutParameter(1,java.sql.Types.INTEGER);
                                   cs . registerOutParameter(2,java.sql.Types.OTHER);
                                   cs . setString(3,hotelId);
                                   cs . setString(4,informationId);
                                   cs . setString(5,lang);
                                   cs . execute();
                              int sta = cs.getInt(1);
                            if(sta!=0)  throw new Exception("status not zero sta="+sta);
                         ResultSet rs = cs.getResultSet(2);
                                  tbl = getDataPairArray(rs);
                               logger . debug("sta="+sta+" key="+key+" cn="+cn);
                                  csh . put(key,tbl);
                                      }
                                 catch(Exception e)
                                      {
                               logger . debug("!!! "+e.toString()+" "+key);
                                      }
                               finally
                                      {
                                  try {
                      if(cs!=null) cs . close();
                      if(cn!=null) cn . close();
                                      }
                                 catch(Exception x)
                                      {
                               logger . debug("!!! "+x.toString()+" "+key);
                               logger . error("!!! "+x.toString());
                                      }
                                      }
                                return tbl;
                                      }

TooMuchAbstraction
Oct 14, 2012

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

qntm posted:

Eastern Polish Christmas Tree Notation:

No, see, if you were doing this properly, then you'd have left and right "branches" to align secondary/tertiary operators on when you need to put more than one operator on a single line.

DICTATOR OF FUNK
Nov 6, 2007

aaaaaw yeeeeeah

xzzy posted:

Looks like a screengrab from phpmyadmin to me, so it's probably an internal database.

Passwords are hard, it's not like there's 40 years of history out there telling us how to be responsible with them.

When I was 15 (~8 years ago) I interned as a web developer in my school district's IT department.

One of my responsibilities was to bild a work order system that integrated with the pre-existing Active Directory, which had a MSSQL replica that I interfaced with for user data (auth was via SSO token, for curious nerds...)

In the staff tables, they interestingly stored the last 4 digits of their SSN's, with a column comment stating "pw: last 4 ln + last 4 ssn". Along, of course, with their usernames.

Last 4 letters of their last name + the freely-provided last 4 of their social security numbers. Worked like a charm. Mix that with publicly-accessible RDP to any computer in the district, and you end up with a little rear end in a top hat pulling some millennial Ferris Bueller poo poo sans looks or charm. Also charging other students for the same.

I stopped by there a couple years ago. As you might imagine, all the department heads are gone.

Didn't show up most of my upper class years and graduated. Ah, I miss high school... :v:

Sab669
Sep 24, 2009

So I started a new job ~1.5 years ago. It's a small company with a few developers that maintain an application they initially outsourced like a decade ago.

Was written by some Indian code farm, and we just make changes to it as needed. Recently it was rewritten by the same company to use newer tech / look better etc.

Just stumbled across this sweet method:

code:

public ActionResult ExportFilter()
{
    try { return View(base.GetViewPath("ExportFilter")); }
    catch (Exception ex) { Logger(ex); }

    return View(base.GetViewPath("ExportFilter"));
}

foo() blew up? Better do it again! :shrug:

Hammerite
Mar 9, 2007

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

Sab669 posted:

So I started a new job ~1.5 years ago. It's a small company with a few developers that maintain an application they initially outsourced like a decade ago.

Was written by some Indian code farm, and we just make changes to it as needed. Recently it was rewritten by the same company to use newer tech / look better etc.

Just stumbled across this sweet method:

code:
public ActionResult ExportFilter()
{
    try { return View(base.GetViewPath("ExportFilter")); }
    catch (Exception ex) { Logger(ex); }

    return View(base.GetViewPath("ExportFilter"));
}
foo() blew up? Better do it again! :shrug:

Written by someone who doesn't realise you can rethrow from within catch after doing your logging?

Impotence
Nov 8, 2010
Lipstick Apathy
i've had a few methods in code that was handed to me that will sometimes work if you suppress errors and run once or twice

it had a bunch of try/catches that basically ignored the entire catch and only started logging errors if it failed about 14 times in a row

when i say a bunch i don't mean like a for loop or anything just a massive blob of copy pasted try catches one after the other

Asymmetrikon
Oct 30, 2009

I believe you're a big dork!
It's like someone wanted OTP "let it crash" without any of the supporting infrastructure.

necrobobsledder
Mar 21, 2005
Lay down your soul to the gods rock 'n roll
Nap Ghost

Biowarfare posted:

i've had a few methods in code that was handed to me that will sometimes work if you suppress errors and run once or twice

it had a bunch of try/catches that basically ignored the entire catch and only started logging errors if it failed about 14 times in a row
For situations like that I think the call pattern is best described as a "debounce" that executes a function and returns a smoothed out result depending upon desired aggregation.

I have no idea where that kind of call pattern makes sense outside anything to do with real-world user inputs, really noisy system events, or a process experiencing critical system failures.

xtal
Jan 9, 2011

by Fluffdaddy
First day on a new contract.

code:
color: #white;

code:
div id=“content”

(They're using Unicode curly quotes, probably indicating it was copied from a WordPress blog.)

xtal fucked around with this message at 18:13 on Oct 22, 2016

Sedro
Dec 31, 2008

xtal posted:

First day on a new contract.

code:
color: #white;
code:
div id=“content”
(They're using Unicode curly quotes, probably indicating it was copied from a WordPress blog.)

Or someone uses Microsoft Word as their code editor

Soricidus
Oct 21, 2010
freedom-hating statist shill

Sedro posted:

Or someone uses Microsoft Word as their code editor

earlier this week I had to help someone figure out why their linux commands weren't working, and it eventually turned out they were copy pasting them from word which had helpfully replaced all the hyphens with fancy dashes (which looked identical to hyphens in the terminal)

gently caress people who use office for anything code related

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Soricidus posted:

gently caress people who use office for anything code related

Like documentation, or planning, or specification.

(As I list the ways that typographically correct quotation marks have entered my code.)

(Which was caught immediately by the compiler.)

Soricidus
Oct 21, 2010
freedom-hating statist shill
Compilers are good

Cli programs that give misleading error messages when you use the wrong kind of dash are bad

We mostly use confluence for documentation etc so at least that's one less way for office to gently caress things up

Soricidus fucked around with this message at 21:39 on Oct 22, 2016

Hughlander
May 11, 2005

Soricidus posted:

earlier this week I had to help someone figure out why their linux commands weren't working, and it eventually turned out they were copy pasting them from word which had helpfully replaced all the hyphens with fancy dashes (which looked identical to hyphens in the terminal)

gently caress people who use office for anything code related

Evernote on OSX Would do that with quotes by default as all, but not the windows one.

xtal
Jan 9, 2011

by Fluffdaddy
This is more of a browser horror but why on earth does auto correct insert a space after words in email fields? So they deliberately cannot create a valid email unless you chomp it.

Space Kablooey
May 6, 2009


xtal posted:

This is more of a browser horror but why on earth does auto correct insert a space after words in email fields? So they deliberately cannot create a valid email unless you chomp it.

If you use input type="email" then autocorrect stops applying and at least the Android default keyboard adds a dedicated "@" key IIRC.

xtal
Jan 9, 2011

by Fluffdaddy

HardDiskD posted:

If you use input type="email" then autocorrect stops applying and at least the Android default keyboard adds a dedicated "@" key IIRC.

Ah, maybe this isn't type=email but name=email or some other heuristic that makes it suggest my email address

Space Kablooey
May 6, 2009


You can have an input with both type=email and name=email. The name is what your browser uses to look up cached entries, but it's the type that the mobile browser uses that disables autocorrect and adds the "@" key.

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.
Every day I run into some thing that unity-C# doesn't let me do that was added in .Net4. Like combining more than two portions of a path at once (this mornings slap in the face; I'm sure I've run into it before but lomarf if I'll remember everything that was added in .Net4 [or .Net3.5 that isn't included in unity's insane cross compiler thing]).

Someone remind me why everyone seems to use this garbage fire of a game engine and why I can never have nice things.

Pollyanna
Mar 5, 2005

Milk's on them.


One day everyone will switch to a dedicated ECS engine written in a specialized Lisp dialect and we'll all be writing games in functional programming paradigms and maybe I'll even have a pony.

eth0.n
Jun 1, 2012

leper khan posted:

Someone remind me why everyone seems to use this garbage fire of a game engine and why I can never have nice things.

Because it's an engine where someone with almost no prior coding experience can make Kerbal Space Program.

Unfortunately, low-barrier-of-entry seems to be at odds with well-engineered.

Pollyanna
Mar 5, 2005

Milk's on them.


Game dev is in a weird position where the ultimate goal of "have a thing that does a thing" is at odds with the process of creating said thing and the end result's quality. People wanna make games quick and easy, but that doesn't mean they'll be good.

xtal
Jan 9, 2011

by Fluffdaddy
Paradoxically this behaviour exists with online games as well where you'd think long term maintainence is at least a small concern. Nope!

Hughlander
May 11, 2005

Pollyanna posted:

Game dev is in a weird position where the ultimate goal of "have a thing that does a thing" is at odds with the process of creating said thing and the end result's quality. People wanna make games quick and easy, but that doesn't mean they'll be good.

Drop the word 'game' and you just described 99% of companies out there.

necrobobsledder
Mar 21, 2005
Lay down your soul to the gods rock 'n roll
Nap Ghost
I don't see how that's unique to game dev whatsoever. You see the same with enterprise bullshitware software even where you deliver a product half the time just for a press release to get some customer engagement and even if you literally cure cancer by running your software they'd take about 4 weeks minimum before they even saw your software in a real-life demo situation. So in that case, it's fine to "release" some software as long as you have sufficient time to fix it before it actually is used anywhere. You don't get second chances much with App Store based releases of course, though.

Pollyanna
Mar 5, 2005

Milk's on them.


Hughlander posted:

Drop the word 'game' and you just described 99% of companies out there.

Touche.

xtal posted:

Paradoxically this behaviour exists with online games as well where you'd think long term maintainence is at least a small concern. Nope!

To be fair, most people drop MMOs that aren't called World of Warcraft fairly quickly, so longevity isn't always a major concern. For things like Overwatch or League of Legends, they're supported by things that aren't the game itself, too.

canis minor
May 4, 2011

Taken from SO

code:
function round(num) {
    return +(Math.round(num + "e+2") + "e-2");
}
it works, but it makes my skin crawl

Volguus
Mar 3, 2009

canis minor posted:

Taken from SO

code:
function round(num) {
    return +(Math.round(num + "e+2") + "e-2");
}
it works, but it makes my skin crawl

What? How? How does that even remotely work? JS is full of lovely "magic-tricks" but this one takes the cake (and I'm aware of the truth table).

xtal
Jan 9, 2011

by Fluffdaddy
JavaScript is weakly typed so my guess is that the + makes it interpret the strings as scientific notation, but I dunno

qntm
Jun 17, 2009
code:
function round(num) {
    return +(Math.round(num + "e+2") + "e-2");
}
For an example number like 6.27691,

* num + "e+2" coerces the number to a string and appends "e+2" to it, yielding the string "6.27691e+2".
* Math.round("6.27691e+2") coerces the string back to a number, 627.691, then rounds it to 628.
* 628 + "e-2" coerces the number to a string again, "628e-2".
* And finally +("628e-2") coerces the string back to a number, 6.28.

It would not be any less horrific if all of those coercions were explicit.

boo_radley
Dec 30, 2005

Politeness costs nothing

canis minor posted:

Taken from SO

code:
function round(num) {
    return +(Math.round(num + "e+2") + "e-2");
}
it works, but it makes my skin crawl

thank you for coming out today

we have ur resume on file

necrobobsledder
Mar 21, 2005
Lay down your soul to the gods rock 'n roll
Nap Ghost
String conversions are strange, but this is consistent at least I guess?

+(100 + "e-2") -> 1 (number)
+(100 + "5") -> 1005 (number)

Joda
Apr 24, 2010

When I'm off, I just like to really let go and have fun, y'know?

Fun Shoe

canis minor posted:

Taken from SO

code:
function round(num) {
    return +(Math.round(num + "e+2") + "e-2");
}
it works, but it makes my skin crawl

What would even make someone write something like this? Involving strings at all sounds like a horribly inefficient way to do that operation.

round(x*100.0)/100.0 is not only more readable, it's probably less than 100 instructions depending on your implementation of round(). With string conversions and stuff you're easily into the thousands.

Joda fucked around with this message at 19:46 on Oct 24, 2016

Adbot
ADBOT LOVES YOU

VikingofRock
Aug 24, 2008




Also what happens if the number is large enough that it's string representation already includes an exponent? Or is that not a thing in JavaScript?

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