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
darthbob88
Oct 13, 2011

YOSPOS

yaoi prophet posted:

You know what I always thought my blog needed? Completely randomized theming.

And not just randomized, but really randomized. Credit where it's due, though, I would never have thought of using the first third of the MD5 hash of the title, plus the day of the month, modulo the number of themes available, to randomly select a given theme. Would
code:
$theme = $themes[rand(0, count($themes)]
not do the job, or am I foolish to think a PRNG could do the job quicker and possibly better?

Adbot
ADBOT LOVES YOU

darthbob88
Oct 13, 2011

YOSPOS
Found something I think is horrible; the framework for an e-commerce site I'm doing work on generates its pages based on where certain comments are, which caused me a certain amount of difficulty when certain of those comments were duplicated. It might just be that I learned to program with languages that actually respect comments, but this is madness. It's like building a mansion with a marble frieze spelling out "The Owner is a twit", just because somebody scribbled a note on the plans. Comments are for people, not programs.

darthbob88
Oct 13, 2011

YOSPOS

OriginalPseudonym posted:

So basically someone's recreated IFDEF in...what, PHP? Except with comments instead of, you know, ifdef.

Fantastic. Let me guess, they have a file that reads other PHP files and evals code based on comments?

It seems like one of those "I wonder if PHP can do this..." ideas that got out of hand :v:
It's not "IFDEF foo THEN bar", it's more like "s/COMMENT/CODE/"; replace <!--SHOPPING CART--> with the actual shopping cart code.

Honestly don't know much about the system; I'm doing some simple work on a website which uses that framework, some simple Javascript and CSS work. Apparently it might be written in ASP.

darthbob88
Oct 13, 2011

YOSPOS

Orzo posted:

Haha, worst binary search variable names ever. Also runs a comparer of unknown complexity 3 times per iteration...

Eh. I might have used variable names like that when I was a student, just for a laugh. Granted, I'd have no idea what they were when I examined them later, nor would the grader understand it, but it'd be funny. The comparator would be a bigger concern; even as a student, I understood that you want to avoid doing things like that more than once. Would it be so hard to do it right?
code:
int comparison = (ourCompare.compare((E) o, ((E)ourList.items[maybe])));
if (comparison > 0) ...etc

darthbob88
Oct 13, 2011

YOSPOS
Cross-posting from the TvTropes thread in PYF:
This dude's profile may or may not be a horror, personally I think it looks kinda cool, but the explanation is. TvTropes uses a semi-custom markup and parser for its pages, which apparently can't handle nested markup; instead of parsing [foo [bar ]] as the sensible <foo> <bar> </bar> </foo>, it turns them into <foo> <bar></foo></bar>, which is somewhat less sensible, and since we no longer have a nice simple DOM tree to work with, poo poo gets crazy yo. I can't explain worth a drat, just read the explanation he provided.

darthbob88
Oct 13, 2011

YOSPOS

Doc Hawkins posted:

But on the other hand, how would doing that help me portray myself as the victim of soulless modernity?

"I wish I could just trust people, but folks these days are bastards, so I have to put up walls between me and thee, O good and gentle players. <emo, drama, self-drat-pitying>"

"bosschair posted:

I think this issue could really get solved if someone could come up with just one more retarded analogy.
Psh, trying to solve this issue with a retarded analogy is like trying to drive nails with a duck. Just doesn't work and you wind up with a lot of quacking.

darthbob88
Oct 13, 2011

YOSPOS

w00tz0r posted:

Apparently executing raw, user-entered SQL on the server isn't an issue if you simply create a new copy of the database for every query.

"This way our clients get the full power of SQL."

A legitimate solution, inasmuch as it keeps the production database safe from the ravages of users; but how can you merge changes without including anything malicious, or how do you filter the stuff users should be querying from the stuff they shouldn't? And if you do filter/sanitize the SQL your users input, how do these people justify the expense of copying the database for every little query?

darthbob88
Oct 13, 2011

YOSPOS
Is it cool to talk about terrible ideas here? Because a colleague/relation of mine had a brilliant idea to create a StackOverflow-type site, where the users post a poll with their question, "Which answer is right?". Other folks vote on that poll and by the Wisdom of the Group truth shall emerge and the best answer will win out, and those who voted for the correct answer get karma/rep for being right or just agreeing with the most people, which gives them more weight in any further polls they vote on. It would combine all the wisdom of Stack Overflow with the democracy of Reddit, in a final product that would, he assures me, make us zillions of dollars if I just do the backend work for him. Additional problems include the obvious fact that many users won't have a good idea as to what the truth is, and the old Put down the chocolate covered banana situations. I do like that phrase.

Incidentally, this same dude thought the Unix Millennium bug could be solved by replacing the ints everywhere with doubles, because they have a larger range. :eng99:

darthbob88
Oct 13, 2011

YOSPOS

prefect posted:

It sounds like a terrible idea, but it wouldn't be the first terrible idea to make zillions of dollars. (Doesn't Stack Overflow already have voting on answers? That seems to be the key element of this guy's idea.)

That's another part of why it's terrible; he wants to start it on StackExchange, in direct competition with Stack Overflow. But his idea would win because it's the better choice. Free Market and all that.

Optimus Prime Ribs posted:

He wanted you to work for free, and only compensate you after its success, didn't he?
Dunno, I opted out before the issue of any kind of compensation came up. I've already got a pretty awesome job (:D), so I don't need to take on any more outside work.

darthbob88
Oct 13, 2011

YOSPOS

No Safe Word posted:

You mean like start it on their Area51 site and try to build a groundswell until it's an actual official StackExchange site? I don't see how it would be "started on StackExchange" and then move away from it...

I mean, the idea is horrible enough but is the secondary horror the fact that there's no way to accomplish the plan for that horrible idea?

I think he did mean Area51, but the secondary horror is the fact that it'd be competing with the site that spawned it and that it was based on. Say again, I refused this proposition before any technical details got hashed out.

darthbob88
Oct 13, 2011

YOSPOS
Not sure just how much of a coding vs business horror this is, but: Ran into a problem at work of a technopolitical nature. Asked for help with it in this post, but the summary is that my code and client code are butting heads and one of them will have to be modified to make everything work. Managed to modify my code to make it fit, but that's not the horror.

The horror is that I mentioned this problem to a carpool buddy, and that my only good options here were break client code or modify my code. He suggested that I break the client code, then explain to the client that it was necessary to make my code work.
:v: The client, being a rational business owner, will totally understand that you, as the expert they hired, know what you're doing better than they do, that this is the best way to make your code work, and they definitely won't resent you suggesting their site is ugly and badly coded.
:eng99: And then after this meeting where they thank me for breaking their site, we'd all ride off on our unicorns to Neverland, to have tea with the Queen of the Fairies.

Hell, I'm a programmer with Asperger's, and I have a better grasp on people than this guy does.

Re: The delimiters, I understood the first one fairly quickly to be a curvy lady's torso, but the second one is a bit more puzzling. Man's torso, possibly with a boner?

darthbob88
Oct 13, 2011

YOSPOS
Just came across a piece of my boss's code, and I'm not sure if it's :stonk: horror or :haw: simplicity.

Boss needed to work out how many items are in a given category, like on this page, and all that was really needed was a qualitative answer, whether or not there were more than 20 items in a category. With that in mind how would you get this answer? Personally, I'd use jQuery to count up all the product images on the page and call it good. Quick, easy, usable on many sites.
JavaScript code:
$("img[id*='qv_']").size();
My boss though? He took an arguably simpler route, and just used the "Total Items: <lots>" marker, right under the category name.
JavaScript code:
function getCatTotal() { //find out how many category results there are
		var catTitle = $('#CatTotal');
		if (catTitle && catTitle.length) {
			var total = catTitle.text();
			var begin = total.indexOf('Total Items: ');
			if (begin >= 0) {
				var numResults = parseInt(total.substring(begin + 13));
				if (!isNaN(numResults)) 
					return numResults;
			}
		}
		return 0;
	}
I'm not sure if this is excellent or terrible, and since it's both nonfunctional and obsolete, I don't much care. I do like the simplicity though; "Hmm, how will I work out if this category has more or less than 20 items? I know! I'll just use the label right there, that says how many items this category has." :haw:

darthbob88
Oct 13, 2011

YOSPOS

pigdog posted:

What if there are 500 items in the category, but the page is set to display only 20 of them at a time? What if some of the items don't have images associated with them?

Y'all should just get rid of the hardcoded and un-i18nable "Total Items:" and let #CatTotal refer only to the number.

Apparently the site's set to display at least 40 items on a category page, so that's not an issue. AFAIK, all the products have images, so my solution would still work. They may be blanks reading "No Photo Available", but every product has an image. And of course it doesn't really matter anymore, since the new system doesn't care about how many items are in a category.

Site's not ours, we're just scraping it, and it's in English for a mostly English-speaking customer base, so i18n is not a big concern. Apparently #CatTotal referred to the whole tag "Total Items: All of them", hence the need to cut out the number with a substring. I say apparently because the client has since changed it from #CatTotal to something else, so this code doesn't work right anymore, not that we need it as noted above. If we were going to continue using this code, it would be easy enough to scrape the "Total Items: lots" in a way which is still i18n-compatible:
JavaScript code:
var numResults = $("td.cat-titles:first").text().match(/\d+/);
return (!isNaN(numResults))? numResults : 0;

darthbob88
Oct 13, 2011

YOSPOS
I think I just came across a small coding horror; for the past while our service hasn't been logging sales from some of our clients, meaning that our data is out of date, which is bad. I managed to track down the most likely cause of the problem to a subtle typo. Observe.
JavaScript code:
//From the sales logging function.
if (Order[9]) _4TellBoost.setCustomerID(Order[9]);
var userID = _4TellBoost.getCustomerID();
//the functions I'm calling
_4TellBoost.setCustomerId();
_4TellBoost.getCustomerID();
Note a subtle difference. Fortunately this would be easy to change, only affects a dozen clients and not visibly, but, well, inconsistency like this is just waiting to cause more problems for whoever comes after me. We're currently tooling up to get processes and protocols in place for code changes, so I'm pushing to include a code review and refactor, to get rid of traps like this.

darthbob88
Oct 13, 2011

YOSPOS

pokeyman posted:

Surely that'd throw an exception? Or is there some other function called setCustomerId?

That's the problem exactly. The reportSales function tries to call setCustomerID, it throws an exception because there is no setCustomerID function, and errors out of the reportSales function.

darthbob88
Oct 13, 2011

YOSPOS

Suspicious Dish posted:

I hope the fix that you deployed was to make aliases.

Haven't deployed it yet; will hold off until tonight, after peak business hours for the clients, when my frenzied attempts to fix the real problem won't cause too many problems for people. Adding this alias will still cause a small problem because the JS file it's going in is already 43K and growing, which is one of the reasons I want to refactor it.

darthbob88 fucked around with this message at 02:55 on Aug 17, 2012

darthbob88
Oct 13, 2011

YOSPOS

geonetix posted:

My point is that this kind of idiotic behaviour is indeed very common in PHP and I reckon you have to know about it. The sudden number_format example excluded, because changing functionality without warning or anything is beyond comprehension. I was personally still going on about the whole 'lol "0.00" == 0' thing.


No excusing it, just wondering why people are still amazed this happens.

I don't think anybody's amazed it happens, I at least have come to terms with the fact that PHP is utter rubbish. What is amazing is how utterly rubbish it is and in what ways, like the whole number_format thing, or the eternally popular "lol 0 =='0.00'", which I agree is starting to drag a little bit.

As far as your point goes, that PHP is acceptable so long as you're aware of its many failings and idiosyncrasies, the bastard offspring of a Yugo and a Ford Pinto would be a perfectly acceptable car, get you wherever you need to go so long as you remain aware of its idiosyncrasies. I'd still drop it in favor of a car that doesn't explode or break down every mile, and I'd drop PHP for a language that doesn't violate common sense and logic.

darthbob88
Oct 13, 2011

YOSPOS

Jabor posted:

I thought this was the coding horrors thread, not the language debate thread.

Tomato, tomato. One man's feature is another man's shambling horror, somebody else's idea of the Right Way to Do It is always wrong and horrifying. Speaking of, encoding options and flags in prime factorizations: good idea, or best idea?

darthbob88
Oct 13, 2011

YOSPOS

Hammerite posted:

I don't understand what you are talking about when you refer to "the nested case" and "the original case". What do you hate?
Edit: Removed for redundant, Suspicious Dish did it better.

darthbob88 fucked around with this message at 21:16 on Sep 24, 2012

darthbob88
Oct 13, 2011

YOSPOS

Manslaughter posted:

Hi, my name is 37F89DA9-612C-498C-AFA5-AB9DF762E55F, but my friends call me 37.

Any relation to Tom Lehrer's friend Hen3ry?

darthbob88
Oct 13, 2011

YOSPOS

nexus6 posted:

Is there no cryptography/secularity thread or something?

I think D&D has a secularity thread somewhere, but I'm not seeing a crypto/security thread anywhere.

darthbob88
Oct 13, 2011

YOSPOS

RoadCrewWorker posted:

Obviously the solution is to only exchange tokenized grammar tree files that can be rendered into readable text instantly with whatever display style you choose.

That idea is probably dumb enough that it has already been tried and failed spectacularly.
Not quite that bad, but I did find somebody asking for CSS for source code. I think it's a nice idea, but doomed to failure. What brace style would you write the code in?

darthbob88
Oct 13, 2011

YOSPOS

shrughes posted:

Yes it is. It's iterative.

Well-disguised iteration, then? Because it sure looks like they're recursively calling themselves to solve the subproblem of whether n - 2 or 3 is divisible by 2 or 3. I can see how you'd rewrite that to use a for loop, but you can do that with most recursive solutions.

darthbob88
Oct 13, 2011

YOSPOS

seiken posted:

That's bizarre and I don't know why you'd bother. Now you have to add wrapper methods for each Dictionary method you want to use.

A nested dictionary like Dictionary<K1, Dictionary<K2, V>> is equivalent to Dictionary<K, V> where K is a struct with two elements K1 and K2 though, which is a much more useful way to avoid nested generics if you really dislike them for some reason.
Interesting. I have a toy program just for storing and analyzing rainfall, which stores data in a nested dictionary, like Dictionary<Year, Dictionary<Month, Dictionary<Day, inches of rain>>>. You're suggesting I change that to Dictionary<Struct<Year, Month, Day>, inches of rain>? How would I get the combined data for any particular year or month in that year? The only way I can think of is to iterate over the keys looking for the ones with the right year and/or month, which is inefficient.

darthbob88
Oct 13, 2011

YOSPOS

Nippashish posted:

How would you get all the data from July for all the years with your current setup?

Iterating over each year to find ones which include days in July requires less time than iterating over all days to find ones in July, although that advantage would probably be lost iterating over each day in each July.

seiken posted:

Yeah, I guess it's not totally equivalent if you're actually making use of the nesting structure because you want to find all elements based on a partial key. Most of the time you see this it's not the case though and you're only actually looking up single elements for which you know the entire key.

If looking up values based on part of a key is super important though, you might want a slightly different structure anyway: with the nested dictionary approach, looking up based on the innermost part of the key is a bunch more expensive than looking up based on the outermost part of the key.
Fair enough. I never need the data for any given day; more often it's analyzing the entirety of one month or year, for which purpose a nested dictionary has worked fine, though next time I play with it I'll fix it to use a SortedDictionary keyed on DateTime and filtered with LINQ, because LINQ is great.

Ithaqua posted:

How big is the data set? Your solution seems insane for small or even moderate data sets...so many tiny nested hash tables.

There have been roughly 40,000 days since 1900. That's small enough to store and filter via LINQ operations on a Dictionary<DateTime, float> without too much concern, unless you're doing a ton of filter operations in a tight loop or something.
We've been recording data since some time in 2010, I believe. And actually there aren't so many tiny hashtables; I just dug that project out and it's actually Dictionary<int, Dictionary<int, float[]>>. The array lets me store the day as the index for the datum. So there are in fact only 6 Dictionaries, containing fewer than 50 entries between them. Yeah, I think I'll make it one big array.

darthbob88
Oct 13, 2011

YOSPOS

ATM Machine posted:

It's relevant because it's the only timestamp in those logs :v: 90% sure on this

It isn't. There's another timestamp at the top of the image, half cut off. It looks like it's just coming round for another cycle of warnings and errors, which is plenty horrific.

darthbob88
Oct 13, 2011

YOSPOS

Zopotantor posted:

That looks like Cyc
PS: your tags are leaking.

It's actually from Jorge Luis Borges, though apparently it's not too far off reality. One Australian Aboriginal language divides all objects as follows.
  • bayi: men, kangaroos, possums, bats, most snakes, most fishes, some birds, most insects, the moon, storms, rainbows, boomerangs, some spears, etc.
  • balan: women, bandicoots, dogs, platypus, echidna, some snakes, some fishes, most birds, fireflies, scorpions, crickets, the hairy mary grub, anything connected with water or fire, sun and stars, shields, some spears, some trees, etc.
  • balam: all edible fruit and the plants that bear them, tubers, ferns, honey, cigarettes, wine, cake
  • bala: parts of the body, meat, bees, wind, yamsticks, some spears, most trees, grass, mud, stones, noises and language, etc.

darthbob88 fucked around with this message at 18:17 on May 7, 2015

darthbob88
Oct 13, 2011

YOSPOS

Soricidus posted:

Sorry, but this is just the usual colonialist fetishization of foreign cultures. You could do exactly the same thing with der, die, and das in German, and it would look exactly as arbitrary, but the Germans are white and European so nobody thinks their language reveals amazing things about their ~unique way of seeing the world~.

I'm pretty sure Twain did that, and really you can do that with any language that recognizes grammatical gender or noun class in general. The Diyrbal taxonomy is just especially foreign, and also one that I remembered seeing and marveling at.


ETA: Or for other odd taxonomies, APG3 says that teak is more closely related to oregano than ebony.

darthbob88 fucked around with this message at 20:38 on May 7, 2015

darthbob88
Oct 13, 2011

YOSPOS

magnetic posted:

I thought scrum was for the all of the team leads to get together regularly to get feedback from a user surrogate to keep the dev work relevant to the users evolving needs? A bunch of programmers getting together is a pretty huge waste of time, may as well be a coffee break.

My understanding is that it's a brief standup meeting where everybody gets together and plans out the day. "Adam's working on foo, but needs the bar that Boris is working on, and plans to have baz ready for Chang." The problem comes when managers forget that it's supposed to be a brief RPT BRIEF meeting, and puts everybody in chairs for three hours.

darthbob88
Oct 13, 2011

YOSPOS

LeftistMuslimObama posted:

Also makes internationialization easier.
I'd have thought the way to ease internationalization would be to say cons currency = "USD", since that means you only need to change it one place and you can avoid nonsense like cons USD = "GBP".

darthbob88
Oct 13, 2011

YOSPOS

Doc Hawkins posted:

Uh, yeah, duh! It's the node way!
I've got to admit, I''m extremely OK with this sort of "Just bolt in another library" thinking, but JFC a module to replace a one-line check for negative zero?

darthbob88
Oct 13, 2011

YOSPOS

Absurd Alhazred posted:

It also involved loading bytes individually from a hardware register.

darthbob88
Oct 13, 2011

YOSPOS
Dunno about him, but I could see something like that done as the if/else if equivalent of always having a default block in a switch statement, especially for not-entirely-unlike-exception-handling.
code:
if (X) {
    doX();
} else if (Y) {
    doY();
} else {
    log("Parameter is neither X nor Y. Fix this.")
}
I suspect the culprit above didn't think it through that far.

darthbob88
Oct 13, 2011

YOSPOS

JawnV6 posted:

Reminds me of that enterprise Java fizz buzz example. No, the other one, where it's "a single line of code" and he's just depressed at how many programmers stroll through his interviews without that glorious insight and pollute his whiteboards with conditionals and such.
Mind posting it? I assume it's a single line (with a shitload of abstraction and polymorphism behind it)?

darthbob88
Oct 13, 2011

YOSPOS

Moonwolf posted:

I'm pretty sure you can only partition on real columns on the table itself, even with clusters or virtual columns. Partitioning on a state that can change is a recipe for extra IO though, although given that people don't come back to life it wouldn't be too serious there.

Also, death_cause CHAR(20)?? Surely it should be a foreign key to a death_causes table where you can have details if you care to look at them?
Especially when there's already an exhaustive list of possible injuries that can cause death.

darthbob88
Oct 13, 2011

YOSPOS

Internet Janitor posted:

I don't own pants, but a friend lends me his whenever I need them. In turn I lend the pants I'm borrowing to others I know and trust. This thrifty reputation-based economy is an example of pants-by-reference.

A) This can't just disappear with the last page.
B) gently caress you.

darthbob88
Oct 13, 2011

YOSPOS

SupSuper posted:

I've seen all of these, as well as the magical tri-state Y/N/null. What does "null" represent when mapped to a checkbox? :iiam:

Do database tables just not support booleans or something?
Not always. The closest MS SQL seems to support is a bit type, which can take 0/1/NULL as values.

darthbob88
Oct 13, 2011

YOSPOS
Cross-posting from Reddit:

darthbob88
Oct 13, 2011

YOSPOS

iospace posted:

To expand on this because that was a phone post:

Pokemon is probably the only thing held together with more matchsticks and rubber bands than this forum. It's easily exploited via arbitrary code execution, allowing for insane stunts on it. That's the horror.

However, if you play the game normally, you'd never know. They did a lot of interesting and fun tricks to make it work, and for that, it's awesome.
See also this LP that focuses on breaking Pokemon Blue.

Adbot
ADBOT LOVES YOU

darthbob88
Oct 13, 2011

YOSPOS

Eggnogium posted:

I have a friend who used to work at a popular travel booking website. Apparently to test credit card processing code they sometimes had to charge their own personal credit cards and then get a refund issued.
Same, when I used to work in e-commerce recommendation services. Had to place a few dozen orders on client sites, with comments reading "TEST ONLY PLEASE DO NOT CHARGE", plus a couple legit ones for rye whiskey and Xmas ornaments.

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