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
bigmandan
Sep 11, 2001

lol internet
College Slice
If you are not using spaces for indentation then you are wrong and bad and should switch careers :colbert:

Adbot
ADBOT LOVES YOU

Jaded Burnout
Jul 10, 2004



I'll be honest I skimmed most of that but I think I accidentally gave you the impression that I couldn't or didn't put together a competent code sample or that modulo arithmetic is whoa out there stuff, I'm sure I wouldn't have gotten the job if that had been the case. I apologise for that, I'll try to phrase things better in future.

Meat Beat Agent
Aug 5, 2007

felonious assault with a sproinging boner

bigmandan posted:

If you are not using spaces for indentation then you are wrong and bad and should switch careers :colbert:

"Spaces", plural? :colbert:

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

LOOK I AM A TURTLE posted:

I also prefer your suggested syntax, but I assumed something like my example was the scenario leper khan was referring to when he said "Tab to indent level then spaces".

It's exactly right; it gives everyone the indent level they want to configure without screwing up the code.

Most editors [that I use] will mostly do what you want and can preserve your previously set indentation on return.

e:
It can be a minor PITA though, which presumably is why people don't.

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

Meat Beat Agent posted:

"Spaces", plural? :colbert:

If you need more than one level of indentation in your code then I don't want to work with you. And that single level of indentation should be indicated via a ">" symbol, which our customized interpreter converts to tab before executing.

1337JiveTurkey
Feb 17, 2005

Indentation should be handled by the appropriate stylesheet.

Fergus Mac Roich
Nov 5, 2008

Soiled Meat

TooMuchAbstraction posted:

If you need more than one level of indentation in your code then I don't want to work with you.

Never write Rust.

Munkeymon
Aug 14, 2003

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



Lookit all you scrubs with bad eyes 'needing' more than a pixel of indentation

Buncha babbies

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe
code:
private IEnumerable<int> GetCollectedObjectIds(FooObjectCollector<BarFooObject> barFooObjects)
{
    return _FooObjects1.ObjectIds.Union(
        _FooObjects2.ObjectIds.Union(
        _FooObjects3.ObjectIds.Union(
        _FooObjects4.ObjectIds.Union(
        _FooObjects5.ObjectIds.Union(
        _FooObjects6.ObjectIds.Union(
        _FooObjects7.ObjectIds.Union(
        _FooObjects8.ObjectIds.Union(
        _FooObjects9.ObjectIds.Union(
        _FooObjects10.ObjectIds.Union(
        _FooObjects11.ObjectIds.Union(
        _FooObjects12.ObjectIds.Union(barFooObjects.ObjectIds)
    )))))))))));
}
*tries to reach something while holding stack of object ID collections; one of the collections slips and they go all over the floor; a parenthesis rolls under the sofa. Looks at camera with pained expression* There's got to be a better way!

raminasi
Jan 25, 2005

a last drink with no ice
There's only one good FizzBuzz implementation and I don't know how anyone could argue differently

Volguus
Mar 3, 2009

Amazing indeed. But now, to learn tensorflow just to be able to properly solve fizzbuzz seems a bit much. A solution with 4 interfaces and 8 implementations and 20 unit tests could be a bit more down to earth, don't you think?

ullerrm
Dec 31, 2012

Oh, the network slogan is true -- "watch FOX and be damned for all eternity!"

leper khan posted:

Please construct a working computer from this pile of 10000 7402s to verify that you can write computer code.

1) wat

2) this is pretty much the entire point and purpose of MHRD

(note that MHRD is actually not a very fun game, don't buy it unless you're extremely bored or extremely nerdy)

ullerrm fucked around with this message at 04:22 on Apr 7, 2017

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
so it's somewhere between tis-100 and KOHCTPYKTOP?

ullerrm
Dec 31, 2012

Oh, the network slogan is true -- "watch FOX and be damned for all eternity!"

I think so. I want to say KOHCTPYKTOP was super ultra low level, like drawing NPN and PNP transistors and metal layers on a grid with your mouse, and producing gates? MHRD is more like lovely Verilog: The Game. You write out descriptions of pins in, pins out, and gates (or components made from gates) and each level has you writing descriptions for progressively more complex ICs -- muxes/selectors/decoders, half/full adders, flipflops, etc. -- with the final levels being "make an ALU, make an instruction decoder, make octal latches, put it together."

The Laplace Demon
Jul 23, 2009

"Oh dear! Oh dear! Heisenberg is a douche!"

Aphyr's latest two blog posts push this genre in magical directions: Acing the technical interview and Hexing the technical interview.

The Laplace Demon fucked around with this message at 10:55 on Apr 7, 2017

Dex
May 26, 2006

Quintuple x!!!

Would not escrow again.

VERY MISLEADING!

The Laplace Demon posted:

Aphyr's latest two blog posts push this genre in magical directions: Acing the technical interview and Hexing the technical interview.

quote:

You grit your teeth, plant your feet against the floor, and dredge a pretty printer from the void. Your palms are calloused now, your eyelids limned with crystalline, soot-black snowflakes. Every action comes at cost–except, of course, for pure functions, which are side-effect free.

this is one of the most beautiful things i have ever read

Mr Shiny Pants
Nov 12, 2012

RandomBlue posted:

Thanks for more hours of fun trying to figure your stupid poo poo out Microsoft. All I wanted to do was serve up a .NET Core app via Kestrel behind a reverse proxy (as they recommend), using a non-root URL for the app, so http://oh.poo poo/fuckme instead of just http://oh.poo poo. Eventually if you find the magic combination of words you'll find the beginning of the path that leads you to this:

https://docs.microsoft.com/en-us/aspnet/core/api/microsoft.aspnetcore.builder.usepathbaseextensions

UsePathBaseExtensions Class

Extension methods for .

Methods summary

UsePathBase(IApplicationBuilder, PathString) - Adds a middleware that extracts the specified path base from request path and postpend it to the request path base.



That is just part of the glorious journey.

The whole .Net core thing feels like a work in progress that has no end. I almost hope they at one point are gonna say "gently caress it" and spend all those resources on the regular .Net framework and getting Mono up to snuff.

Zemyla
Aug 6, 2008

I'll take her off your hands. Pleasure doing business with you!

What kind of witch casts runes for a simple task like cycle detection? Does she call upon the spirits to butter her bread, too? Granny Weatherwax would be ashamed.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe
code:
var fooValues = fooBars.Select(fb =>
{
if (fb == "FB")
	return "";
else
	return fb.Substring(2);
}).Where(s => !String.IsNullOrEmpty(s));

McGlockenshire
Dec 16, 2005

GOLLOCKS!

Hammerite posted:

code:
var fooValues = fooBars.Select(fb =>
{
if (fb == "FB")
	return "";
else
	return fb.Substring(2);
}).Where(s => !String.IsNullOrEmpty(s));

Out of horrible, morbid curiosity, what's the computational overhead on this compared to just the inner if wrapped in an outer if for the is null or empty check, inside an appropriate loop?

McGlockenshire fucked around with this message at 16:51 on Apr 12, 2017

SirViver
Oct 22, 2008

McGlockenshire posted:

Out of horrible, morbid curiosity, what's the computational overhead on this compared to just the inner if wrapped in an outer if for the is null or empty check, inside an appropriate loop?
There's no definitive answer to that - it all depends on what exactly you do with the data in the end. Assuming you meant the goal is actually to create a materialized list/array of the filtered data then using LINQ will have computational and memory/stack overhead compared to raw loops, but generally not so much to be significant in most real usage scenarios. If you operate on data amounts where this actually matters then you really should know not to use LINQ in the first place. The real strength of LINQ lies in its expressiveness and maintainability. Doing nested grouping and sorting manually might have somewhat better performance, but it sure as hell won't be as readable.

The real "horror" of that example is the roundabout way of filtering out "FB" entries, assuming all the potential edge cases/exceptions are actually accounted for (due to knowing that fooBars will always contain non-null strings with at least a length of two) and wanted exactly like that and not just a disaster waiting to happen.

A safer and somewhat saner way to do the above (assuming you want the same outcome sans potential exceptions) would be:
C# code:
var fooValues = fooBars
    .Where(fb => !String.IsNullOrEmpty(fb) && fb.Length > 2) // && fb != "FB"
    .Select(fb => fb.Substring(2));
The check for "FB" is not technically needed due to the length check, but might be appropriate to include anyway to communicate the intent.

ZHamburglar
Aug 24, 2006
I have a penis.
Should I just post my code from when I was learning Javascript? Or would that be considered gore?

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

ZHamburglar posted:

Should I just post my code from when I was learning Javascript? Or would that be considered gore?

I think that student code gets something of a pass here, much like the birdhouse your 12-year-old made doesn't belong in Crappy Construction Tales. This thread is really for code meant for serious use, written by people who should have known better.

Volguus
Mar 3, 2009

ZHamburglar posted:

Should I just post my code from when I was learning Javascript? Or would that be considered gore?

You can post the Javascript code you're writing now. Or would that be considered gore?

Hammerite
Mar 9, 2007

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

McGlockenshire posted:

Out of horrible, morbid curiosity, what's the computational overhead on this compared to just the inner if wrapped in an outer if for the is null or empty check, inside an appropriate loop?

No idea. You're thinking much more about it than I did. I just changed it to something logically equivalent but a bit less upside down and inside out. The strings are always non-null IIRC, but I can't remember the details because I don't have it in front of me.

Spatial
Nov 15, 2007

I'm working on the firmware for a new SoC which has a big emphasis on security. The root of trust on the device is a ROM which for obvious reasons can't be patched. Must be right first time to avoid huge delays and cost overruns.

The group of experts responsible for designing and implementing this software: me.

Man if this thing gets turned into a 100 million strong botnet I'm never going to be promoted for the rest of my life. :v:

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe
I forgot, the same file also had code for pretty-printing the contents of a List<string> as a single string that would insert an ampersand between the second-to-last and last list items if the list had 2 or more elements. Except it did it by constructing the string with just spaces between list items, then if there were 2 or more elements it amended the string by counting back n characters where n is the length of the last list item and inserting "& ". I replaced that with something less silly, too.

Nth Doctor
Sep 7, 2010

Darkrai used Dream Eater!
It's super effective!


Hammerite posted:

I forgot, the same file also had code for pretty-printing the contents of a List<string> as a single string that would insert an ampersand between the second-to-last and last list items if the list had 2 or more elements. Except it did it by constructing the string with just spaces between list items, then if there were 2 or more elements it amended the string by counting back n characters where n is the length of the last list item and inserting "& ". I replaced that with something less silly, too.

Did it do Oxford commas?

JawnV6
Jul 4, 2004

So hot ...
I worked with a perl/SQL abomination that would build up queries. It had some definitions to help, namely
code:
$and = "AND";
$or = "OR ";
Huh, weird extra space there. I got rid of it.

It started spewing weird errors about SELECT's and clauses, so I kept digging to find something like this:
code:
$query.chop().chop().chop(); //remove last op
This is the same one that undef'd $\ instead of looping on a file.

Nippashish
Nov 2, 2005

Let me see you dance!

Spatial posted:

Man if this thing gets turned into a 100 million strong botnet I'm never going to be promoted for the rest of my life. :v:

Not if it's your botnet :getin:

Doom Mathematic
Sep 2, 2008

JawnV6 posted:

I worked with a perl/SQL abomination that would build up queries. It had some definitions to help, namely
code:
$and = "AND";
$or = "OR ";
Huh, weird extra space there. I got rid of it.

It started spewing weird errors about SELECT's and clauses, so I kept digging to find something like this:
code:
$query.chop().chop().chop(); //remove last op
This is the same one that undef'd $\ instead of looping on a file.

That's magical.

Hammerite
Mar 9, 2007

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

Nth Doctor posted:

Did it do Oxford commas?

I'm not sure what you're driving at by asking this but there were no commas, Oxford or otherwise. I can't go into details but it was just spitting out a space-separated list of numbers, like "4 6 8 & 20". (the numbers were strings already, they came from an XML fragment.)

QuarkJets
Sep 8, 2008

TooMuchAbstraction posted:

I think that student code gets something of a pass here, much like the birdhouse your 12-year-old made doesn't belong in Crappy Construction Tales. This thread is really for code meant for serious use, written by people who should have known better.

Yeah it's always a lot more fun when you see bad code written by professionals

redleader
Aug 18, 2005

Engage according to operational parameters

JawnV6 posted:

I worked with a perl/SQL abomination that would build up queries. It had some definitions to help, namely
code:
$and = "AND";
$or = "OR ";
Huh, weird extra space there. I got rid of it.

It started spewing weird errors about SELECT's and clauses, so I kept digging to find something like this:
code:
$query.chop().chop().chop(); //remove last op
This is the same one that undef'd $\ instead of looping on a file.

That random space in there is suspicious as hell. I'd have just left it under the assumption that something, somewhere would somehow depend on that space. ~maintenance programming~

FlapYoJacks
Feb 12, 2009

redleader posted:

That random space in there is suspicious as hell. I'd have just left it under the assumption that something, somewhere would somehow depend on that space. ~maintenance programming~

The first step of maintenance programming if there isn't a good solid unit test framework is to write a unit test framework.

Then write some unit tests.
Then write more.
Then write EVEN MORE.

And then, when you think you are done with unit tests? Write some loving more.

Then, and only then, when the thought of writing any more unit tests for this product you are going to maintain makes you turn towards a bottle of scotch and a revolver with a single bullet, will you have enough to start working on changing the code.

JawnV6
Jul 4, 2004

So hot ...

redleader posted:

That random space in there is suspicious as hell. I'd have just left it under the assumption that something, somewhere would somehow depend on that space. ~maintenance programming~

I disagree. Removing it was the fastest way to detect that it was a load-bearing space.

dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)

JawnV6 posted:

code:
$query.chop().chop().chop(); //remove last op

RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider
Having so much fun with .Net Core.

Today I found that EF Core doesn't handle GroupBy at all OR Count() right. I mean, who uses group by or count when you can just pull back millions of rows and do all that in your app, right? That's the way almost every PHP app I've ever had the misfortune of checking out their code does it, so it has to be good enough for .Net Core and EF Core, right?

On top of that I noticed a huge slow down after a while where a request was taking around 2 seconds to generate a page. I thought that had to be some unindexed query or something, but no, the queries ran in about 10ms total. Restarted the service with a more detailed logging level and everything was fine. Well gently caress me. That usually means it's a memory leak or something worse.

So I throw together this API call that just returns a very basic JSON OK response and should consume zero additional memory:

code:

        [HttpGet]
        [Route("/api/wtf")]
        public IActionResult Wtf()
        {
            return new OkResult();
        }
Every call allocates 256KB without freeing it. On a web server. :suicide:

This is .Net Core 1.1.1, the latest "release".

redleader
Aug 18, 2005

Engage according to operational parameters
I'm still not convinced that .NET core is anywhere close to production-ready.

Adbot
ADBOT LOVES YOU

RandomBlue
Dec 30, 2012

hay guys!


Biscuit Hider

redleader posted:

I'm still not convinced that .NET core is anywhere close to production-ready.

I almost was for minor crap until today. Thankfully I'm only using it on a personal project that I use with 3 other friends. Unfortunately considering it's a Google Wave clone that uses websockets with a 30 second timeout it's leaking memory at 2MB/minute or 2.8GB per day. A pittance.

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