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

It's kind of annoying that they don't exclude interfaces and annotations. Bean is included with spring :(.

Adbot
ADBOT LOVES YOU

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

No but real talk how is that REST monstrosity not in the title?

Cuntpunch
Oct 3, 2003

A monkey in a long line of kings
code:
private DateTime dateSpecify(DateTime returnTime)
{
	return returnTime = DateTime.Now;
}
Not joking with this stuff. It's like a museum of :psyduck: I live in

Space Kablooey
May 6, 2009


How does that even work?

CPColin
Sep 9, 2003

Big ol' smile.
Probably in a way the original developer didn't expect!

Munkeymon
Aug 14, 2003

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



It just returns DateTime.Now (after pointlessly overwriting something on the method-local stack with it). In C# you can use the resulting value of an assignment expression in a parent expression just like in C. I'd guess that the author originally thought they were overwriting a pointer but DateTime is a struct not a class, so it's a value type and no implicit pointers are involved. Oh and it wouldn't work if DateTime were a class, either, unless the argument was declared with an out keyword, so someone took the C in C# too literally.

Munkeymon fucked around with this message at 16:04 on Apr 12, 2016

taint toucher
Sep 23, 2004


Just found this lovely little bit of code in production:

code:
	public static final String generateNamespace(String provider) {
		if (provider == null) {
			throw new IllegalArgumentException("provider cannot be null.");
		}
		StringBuilder sb = new StringBuilder();
		if (provider != null) {
			sb.append(provider);
		}
		return sb.toString().trim();
	}
It's even unit tested!

code:
	@Test
	public void testgenerateNamespace() {
		String namespace = <redacted class name>.generateNamespace("TEST");
		String test = "TEST";
		assertEquals(test, namespace);

		namespace = <redacted class name>.generateNamespace("TEST");
		assertEquals(test, namespace);
	}
:haw:

CPColin
Sep 9, 2003

Big ol' smile.
I'm trying to picture what that maybe used to do and I'm drawing a blank.

Space Kablooey
May 6, 2009


I like how the test doesn't even test if the string is trimmed. :allears:

taint toucher
Sep 23, 2004


CPColin posted:

I'm trying to picture what that maybe used to do and I'm drawing a blank.

The code is so old that the CVS history is long gone, probably lost when we moved to SVN and then Git. Our code base is old as gently caress.

HardDisk posted:

I like how the test doesn't even test if the string is trimmed. :allears:

That also made me laugh.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
My guess would be that it used to have a static counter in it, so that every time you called it you'd get back a unique name for your namespace. Which explains why the test would be calling it twice with the same input, for example.

Not sure why someone would come along and remove that though, unless they fundamentally misunderstood the purpose or something.

taint toucher
Sep 23, 2004


Jabor posted:

fundamentally misunderstood the purpose or something.

Knowing some of my former colleagues this was the most likely case.

HoboMan
Nov 4, 2010

There's a page where you can enter stuff to search by
So here's the beginning of the function that gets called when you click search
C# code:
protected void btnAdvSearch_Click(object sender, EventArgs e)
{
	if (Company == "")
		throw new ApplicationException("Select a company first.");

xzzy
Mar 5, 2009

Oopsie.

http://www.independent.co.uk/life-s...e-a6984256.html

quote:

“I run a small hosting provider with more or less 1535 customers and I use Ansible to automate some operations to be run on all servers,” wrote Marco Marsala. “Last night I accidentally ran, on all servers, a Bash script with a rm -rf {foo}/{bar} with those variables undefined due to a bug in the code above this line.”

qntm
Jun 17, 2009
I have an axe to grind, so I blame Bash.

Soricidus
Oct 21, 2010
freedom-hating statist shill

sucks to be him, but i'm going to laugh anyway because it was the backup script, and that's just too good

VikingofRock
Aug 24, 2008





The best part is at the bottom when he swaps if and of when running dd. It might be a troll, but it's pretty funny regardless.

VikingofRock fucked around with this message at 19:44 on Apr 14, 2016

Linear Zoetrope
Nov 28, 2011

A hero must cook
I'm taking a (grad-level) parallel programming class, and all our graphs are supposed to be done in a way such that the values get larger when they get faster (e.g. y axis is op/ns as opposed to ns/op). This isn't wrong, but it's so weird to me since outside this class I don't think I've ever seen people measure performance that way. The only place I can think of where this is standard is frames per second, and even then for most optimization purposes I see people measure (nano/milli)seconds per frame anyway. I guess processor-level operation speeds are also measured this way (e.g. FLOPS, the name MIPS), but most benchmark systems, and most results I've seen online and in papers, tend to do it the other way.

I don't know why, but it somewhat unreasonably bothers me, even if it's equivalent and I'm sure there are frameworks I'm not aware of that do it this way.

JawnV6
Jul 4, 2004

So hot ...
Isn't your X axis core or thread count?

Certain things make a lot more sense if larger is faster. If you're trying to determine if a parallel algorithm is superlinear, it would be difficult to determine from a 1 core run taking 100s and an 8 core run taking 14s. Much easier to tell if the graph shows 10ops/sec to 78ops/sec. I mean, ignoring that it's obvious that we're checking against 12.5 or 80.

Soricidus
Oct 21, 2010
freedom-hating statist shill

Jsor posted:

I'm taking a (grad-level) parallel programming class, and all our graphs are supposed to be done in a way such that the values get larger when they get faster (e.g. y axis is op/ns as opposed to ns/op). This isn't wrong, but it's so weird to me since outside this class I don't think I've ever seen people measure performance that way. The only place I can think of where this is standard is frames per second, and even then for most optimization purposes I see people measure (nano/milli)seconds per frame anyway.

If anything it's the other approach that's weird. We talk about performance in terms of "speed", and speed is distance/time by definition.

Xerophyte
Mar 17, 2008

This space intentionally left blank
Fnords/second is easily the more common when fnords are the sub-computations that are being run in parallel rather than in sequence. The alternative can get confusing.

For instance, ray tracing performance is almost always measured in rays per second or intersections per second. Someone instead stating that they have reduced the average computation time per intersection test from 10ns to 5ns by doubling the number of CPUs used would be very easy to misread as stating that there's an improvement for each individual test (due to better locality or whatever) rather than the intended meaning of getting linear scaling with CPU count.

For evaluations of the final results in the same field I've seen seconds per frame (100ms), frame per second (10 FPS) and time to final image (1h) in papers. I've never seen anyone specify results in images per hour, but I wouldn't be terribly surprised if someone did.

Speculatively, I'd say that non-real time problems are often more naturally framed as "how long do I have to wait", while real time problems are often more naturally framed as "how fast does it go".

Xerophyte fucked around with this message at 02:45 on Apr 15, 2016

Athas
Aug 6, 2007

fuck that joker
In parallelisation it is very common to graph "speedup". That is, how much faster the parallel implementation is for a given thread count, compared to the sequential one (or even just the parallel implementation with one thread, to measure scaling). Nothing unusual or horrible there.

jiggerypokery
Feb 1, 2012

...But I could hardly wait six months with a red hot jape like that under me belt.

I am crying. Troll or not it is absolute gold. http://serverfault.com/questions/769357/recovering-from-a-rm-rf Imagine if that is his real name too.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

jiggerypokery posted:

I am crying. Troll or not it is absolute gold. http://serverfault.com/questions/769357/recovering-from-a-rm-rf Imagine if that is his real name too.

It's gone now, but yeah, I think my advice to him would be to look into another industry, because he is probably done in this one.

xzzy
Mar 5, 2009

That's odd they deleted it entirely, I guess they hate being covered by the news.

Unless maybe it was discovered to be a hoax? Would make some sense, especially after the 'dd' comment the author made at one point.

Doc Hawkins
Jun 15, 2010

Dashing? But I'm not even moving!


I think I remember Bryan Cantrill saying in a talk that Solaris did something clever to rm without technically breaking POSIX: if the command's effective targets include /bin/rm, it fails without deleting anything.

Hollow Talk
Feb 2, 2014

Doc Hawkins posted:

I think I remember Bryan Cantrill saying in a talk that Solaris did something clever to rm without technically breaking POSIX: if the command's effective targets include /bin/rm, it fails without deleting anything.

Modern rm versions usually set "--preserve-root" by default, which means rm will not just remove / without you really trying.

jiggerypokery
Feb 1, 2012

...But I could hardly wait six months with a red hot jape like that under me belt.

It smelt like a troll to me, drat good one too. I just hope it wasn't malicious, i.e using someone elses name because that guy is hosed.

Dylan16807
May 12, 2010

Hollow Talk posted:

Modern rm versions usually set "--preserve-root" by default, which means rm will not just remove / without you really trying.

But it will remove /* so it's not as good as it could be.

Hollow Talk
Feb 2, 2014

Dylan16807 posted:

But it will remove /* so it's not as good as it could be.

True, but that's slightly harder to get from screwed up variables than a space or empty string.

Workaday Wizard
Oct 23, 2009

by Pragmatica
The real horror is that bash will continue merrily when you use undefined variables. poo poo should crash.

Obsurveyor
Jan 10, 2003

Shinku ABOOKEN posted:

The real horror is that bash will continue merrily when you use undefined variables. poo poo should crash.

It will if you're not a reckless dev and properly include

code:
set -eu

EpicCodeMonkey
Feb 19, 2011
It was a hoax by some douchnozzle looking to get his book noticed:

http://www.trymodern.com/article/596/this-guy-did-not-delete-his-entire-company-in-one-click

CmdrRiker
Apr 8, 2016

You dismally untalented little creep!

Obsurveyor posted:

It will if you're not a reckless dev and properly include

code:
set -eu

I consider those useful debugging tools. Declaring your variables with proper flow control is what I would actually recommend for production scripts.

Bonfire Lit
Jul 9, 2008

If you're one of the sinners who caused this please unfriend me now.

C++ code:
	Foo **array = new Foo*[(array_capacity = array_size+4)&~3];
:negative:

Klades
Sep 8, 2011

Bonfire Lit posted:

C++ code:
	Foo **array = new Foo*[(array_capacity = array_size+4)&~3];
:negative:

Aside from the whole "why are you setting array_capacity in the same line as you're declaring this other poo poo", are there actually any good use cases for a C array of raw pointers in C++ code nowadays?
I also can't fathom why they're doing the "bitwise and not 3" there.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Klades posted:

I also can't fathom why they're doing the "bitwise and not 3" there.

Along with the "+4", they're probably trying to round up to the nearest multiple of 4.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
it really should be (array_size+3)&~3 but yeah it's a pretty common and well-known trick

nielsm
Jun 1, 2009



Also it sets array_capacity to a potentially larger number than the actual allocation.

Adbot
ADBOT LOVES YOU

Athas
Aug 6, 2007

fuck that joker

Klades posted:

Aside from the whole "why are you setting array_capacity in the same line as you're declaring this other poo poo", are there actually any good use cases for a C array of raw pointers in C++ code nowadays?
I also can't fathom why they're doing the "bitwise and not 3" there.

I see people using arrays of pointers to fake multidimensional arrays in the most nasty way. It is terrible and bad and probably confuses the compiler horribly. In C++, you can probably use some template magic to define a class that gives a nicer multidimensional array interface.

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