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
Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



ultramiraculous posted:

Yeah, I know that. Sadly this is the way we got the Xcode project itself. The classes group has 200 objects in it, most of the files being independent .h/.m sets subclassing one of the AppKit components. Basically there's a component subclassed for every little bit of weird behavior, despite a lot of it being similar/generic enough that a handful of abstract components would make a huge dent in the class count.

Do they give out negative scores for code reuse?

Sounds like they come from a completely different background. Generally you shouldn't even subclass AppKit classes (except a few things like Controllers), but use Delegates and Data Sources and such.

Adbot
ADBOT LOVES YOU

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Was feeling nostalgic for the late nineties and decided to look up the clusterfuck that was Hotline (basically Mac BBS software) back in the day. Most of it is management fuckups (terrible oversight) and hinks being horrible at dealing with people, but this stood out:

quote:

36. According to Mr. Spearritt, on two occasions (one in late 1996 or early 1997 and the other in August 1997) he requested Mr. Hinkley to backup all source code on Redrock's A2BNT1 UAM server. This occurred after Mr. Hinkley was unable to make a change to SPFS because he was unable to locate all the source code. In his witness statement dated 16 July 2000 (Exhibit H 16) Mr. Spearritt said:

"When a program is released to market, it is important to maintain a copy of all source code utilised in developing that program. That way, if a problem does develop in the running of the program, or if the client wants to alter the program's functionality at some future point in time, the programmer has a complete copy of source code and utilities used to create the version of the program. After the occurrence of this second incident, I told Adam that it was imperative that he kept a backed up version of each piece of production software on the A2BNT1 UAM."

37. Mr. Spearritt confirmed verbally with Mr. Hinkley about once a month that a complete copy of all source code was available on the server. Mr. Spearritt's own checks appear to have confirmed that source code was being saved on Redrock's server in a compressed file. This evidence demonstrates the confusion caused by Mr. Hinkley's failure properly to clarify his understanding of the status of the library notwithstanding that he was specifically directed to back up all source code in circumstances where the inability to access it had meant that changes could not be made to SPFS. Here was the perfect opportunity for Mr. Hinkley to explain to Redrock, if his position was then as he now contends, that in requiring him to back up the library or (which, as Mr. Hinkley must have realised, Redrock necessarily assumed was the same thing) to back up "each piece of production software", Redrock was requiring him to back up something copyright in which resided with Mr. Hinkley.

I know Subversion & git etc are all newer than this, but CVS was hardly unknown at the time. Uploading a compressed archive of the source tree each month... :psyduck:

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Scaramouche posted:

Man are you kidding, Hotline was napster before it was cool. I ganked so much stuff on my broadband modem. I didn't think anyone bothered to use the actual community/talking stuff.

Oh it ruled alright, but the software was terrible. I was on lovely 56k so I wasn't a huge pirate and used it mostly for the community - I actually still talk to a handful of people from back then.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



As far as I know, image decoding etc itself isn't done in WebKit but whatever OS it's running on. Except in some instances I think Chrome handles images itself instead of the OS.

So the GIF thing was an issue with Core Image on OS X in earlier versions and the JPEG issue sounds like a problem in WebKit not hooking up to Windows properly.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Here's one from myself (not actually a coding horror but a case of severe retardation):

code:
    NSPoint origin = NSMakePoint(fmin(startPoint.x, endPoint.x), fmin(startPoint.y, endPoint.y));
    NSPoint end = NSMakePoint(fmax(startPoint.x, endPoint.x), fmax(startPoint.y, endPoint.y));
    NSSize size = NSMakeSize(end.x - origin.x, end.y - origin.y);
    
    NSRect rect = NSMakeRect(origin.x, origin.y, size.width, size.height);

    NSRect convertedRect = [self convertRect:rect fromView:[[self window] contentView]];
I just spent over 20 minutes agonizing over why the size of convertedRect was identical to the size of the original rect :downs:

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



yaoi prophet posted:

Haha, apparently by default exit is bound to a Quitter object whose __repr__ is that 'Use exit()' message.

Honestly when it's put like that, I gotta go with pokeyman. Python is being a dick right there. And lord knows I've typed exit so many times.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



ctrl Z
kill %1

You're not my dad, don't tell me what I can and cannot do

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



You can do the same thing in perl if you don't use strict;, and it's a really bad idea that makes code unmaintainable.

code:
[ carthag@mbp.local:~ ]$ perl
use Data::Dumper;

$a = { a => b, "b" => 2, 3 => "c" };

print Dumper \$a;
^D
$VAR1 = \{
            'a' => 'b',
            '3' => 'c',
            'b' => 2
          };

Carthag Tuek fucked around with this message at 23:59 on Feb 13, 2012

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



npe posted:

With use strict your code fails due to the "b" in your values, but that's hardly fair because the discussion was barewords in keys, and this indeed works just fine with strict:

code:
use strict;
use Data::Dumper;

$a = { a => "b", "b" => 2, 3 => "c" };

print Dumper \$a;
In fact, this paradigm is pretty idiomatic perl when used as object properties, in the form of $self->{foo}.

Yeah my example was crap. Perl does the same poo poo as PHP without strict (that is, any non-keyword bareword is a string).

code:
$ perl -e '$a=lol;print $a'
lol
Lesson: The only excuse not to use strict is ad hoc oneliners.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Immutable types rule.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Here I was thinking that an expected failure was something like assert(functionThatShouldReturnTrueFor(args) (don't ask me why you wouldn't do it the other way around though).

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



^^^ I'd start with success = false though, much cleaner that way. ^^^

moynar posted:

The latest software scandal in Norway is a pretty big horror.

So at some point in time the Norwegian government decided that the country needed to move parts of the paper mill onto the internet. The result is the monolithic Altinn (literally "everything in") software which was developed by consultants, mostly Accenture/Avanade for about 1000 million NOK. Or about 170 million USD if you will. This handles taxes for all citizens and a lot of other important stuff.

Each year about this time the estimated taxes are released on Altinn, which is a big deal because it tells you if you have to pay extra, have money waiting for you and if you have to do excessive paperwork because someone hosed up in the paper mill when calculating your income.

Last year the system collapsed immediately when the tax returns were published. Afterwards the admins worked out that a single server was responsible for login services which is an horror in it's own right (Norway has 5 millions inhabitants) but this year they promised it would be better. It didn't go down this year, it just switched to serving a static PLEASE WAIT page for most users. And then something wonderous happened. The people responsible turned on caching in a desperate attempt to get it up and running again and suddently everyone who tried to log in got logged on as some random dude from Oslo, showing his tax returns, SSN and other personal information. Cue everything being shut down for a few days, leading to enormous losses in productivity for every single accounting firm and company using Altinn in Norway.

If I hadn't paid for it as a taxpayer I would be laughing pretty hard right now.


Reminds me of every time I hear about all the crap software the government has here in Denmark. I guess it's just a perfect storm of wrong specs and terrible consultants. Has there ever in the history of computing been a success story?

One day I'll start a consulting firm and sell lovely software to governments.

Carthag Tuek fucked around with this message at 20:51 on Mar 23, 2012

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Optimus Prime Ribs posted:

I definitely agree with that, but then the for loop would need something like this:

Which just seems silly to me.
Not that it matters since this is a coding horror no matter how you write it.

Actually I'm not too fond of naming vars "success", I prefer something semantic, it'll also make the code more like sentences.

You could do something like this. Granted, it'll keep counting in all cases, but after the first false, lazy evaluation should keep the rest of the loop from taking too much time.

code:
shouldProceed = true;

for (i = 1; i < 36; i++)
{
	shouldProceed = shouldProceed && _root["pic_"+String(i)].hitTest(_root["hit_"+String(i)]);
}

if (shouldProceed)
{
	gotoAndStop(6);
}

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Not to get all Bret Victor up in here, but seriously why is it still necessary to even discuss brace-style & indentation?

Code is easily tokenizable; after all that is a criteria for compilation (and if it isn't tokenizable, modern compilers can usually figure out the syntax errors or make and educated guess - for display only mind you). Why doesn't every IDE just represent - by default - the code in whatever format the user likes? We don't need to actually look at the raw txt unless something is seriously broke. Make that the fallback; show the token stream indented as the user prefers by default.

Make indentation a as low level as choosing whether line endings are \n or whatever else.

Carthag Tuek fucked around with this message at 11:03 on Mar 25, 2012

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



tef posted:

It's a topic everyone can have an opinion on. In the sense that there is no understanding or insight required to participate.

the colour of the bike shed should be chartreuse

That's exactly my point though, it's not important for the end result, and it's not important to you how I like to format my code. We should both just set up our dev environment to display the code how we like it and the underlying representation can be whatever (as long as its readable).

This way, if you like 8-space tabs and GNU-style braces, and I like 2-space tabs and banner braces, we can both do our own thing, and not care at all what the other does.

Also it makes diffs more readable.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



In short: Neither of us care, so hide the crap from us.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Suspicious Dish posted:

Yeah, arguably that's data with a mustache on.

The interface builder in XCode doesn't even generate code, it just serializes the objects you set up, so it literally is data. You can set up stuff in code too, but usually there's no need unless you have some complex stuff going on.

Suspicious Dish posted:

I was thinking of code with logic and that sort of fun stuff. Something like this.

Just had a look, it looks like if you try to do anything more advanced than very very simple stuff, it'll turn into a world of poo poo in 5 seconds.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



I bet whoever wrote this saw this or something like it: http://developer.apple.com/library/...SKeyValueCoding

Being able to dig into some object by names in one go is pretty neat, but that impementation is poo poo.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



A horror by mine own hand:

code:

void contConcHelper(int level, NSString *inLine, NSString **outInitial, NSArray **outSubLines) {
  NSMutableArray *lines = [[inLine componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]] mutableCopy];
  
  NSString *initial = nil;
  NSMutableArray *subLines = [NSMutableArray array];
  
  for (NSString *line in lines) {
    if ([line length] <= 248 && [line rangeOfString:concSeparator].location == NSNotFound) {
      //line's good to go.
      
      if (initial == nil) {
        initial = line;
      } else {
        //we already set the first line so make a CONT node
        [subLines addObject:[NSString stringWithFormat:@"%d CONT %@", level+1, line]];
      }
    } else {
      //we need to split the line on >248 or concSeparator
      
      NSString *leftover = line;
      
      BOOL firstPass = YES;
      
      while ([leftover length] > 248 || [leftover rangeOfString:concSeparator].location != NSNotFound) {
        NSUInteger toIndex = 248; //assume length is the reason
        NSUInteger fromIndex = 248;
        if ([leftover rangeOfString:concSeparator].location != NSNotFound) {
          // split on concSeparator
          toIndex = [leftover rangeOfString:concSeparator].location;
          fromIndex = toIndex + [concSeparator length];
        }
        NSString *bite = [leftover substringToIndex:toIndex];
        leftover = [leftover substringFromIndex:fromIndex];
        
        if (firstPass) {
          if (initial == nil) {
            initial = bite;
          } else {
            [subLines addObject:[NSString stringWithFormat:@"%d CONT %@", level+1, bite]];
          }
        } else {
          //we already set the first line so make a CONC node
          [subLines addObject:[NSString stringWithFormat:@"%d CONC %@", level+1, bite]];
        }
        
        firstPass = NO;
      }
      
      [subLines addObject:[NSString stringWithFormat:@"%d CONC %@", level+1, leftover]];
    }
  }
  
  *outInitial = initial;
  *outSubLines = [subLines copy];
}
Augh

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Was leafing through the camel book yesterday and came across use constant

code:
use constant A => 1, B => 2;

print A;
Output:
code:
1B2

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Zombywuf posted:

It's pretty simple really, the constant package is terrible.

I miss perl a lot.

I forgot to mention that it hilariously implements the constant as a function that takes no parameters and returns the value.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



its an elephant on pcp.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Plorkyeran posted:

FWIW my experience has been that I end up spending about the same amount of time thinking about resource management in C# and C++, and both are way simpler than Objective-C with automatic reference counting. The learning curve for C++ memory management is definitely steeper than for garbage collected languages, though that's a problem with the language in general.

Are you saying that ARC is complex to think about? If you aren't working with CF classes, the only gotcha I can think of is making sure you don't have retain-cycles, which would be an issue in any language. And those are easily solved by using weak references where appropiate.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Yeah I think it was brought up before but

code:
#define IF	if(
#define THEN	){
#define ELSE	} else {
#define ELIF	} else if (
#define FI	;}
ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/v7sh/mac.h

:holy:

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



McGlockenshire posted:

As long as you manually pick a large enough cost parameter, yes, plain old PHP crypt() will do the job fine:

$hash = crypt('password', '$2y$14$putyoursaltherethanks$');

The 14 here is the cost factor. The higher the cost, the longer it's going to take to generate. An increase of one roughly doubles the time spent.

The whole 2a/2x/2y thing has to do with some edge case or another.

Be sure to RTFM and check the constants before using it.

Putting configuration parameters inside a string like that is a horror.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



if you have some old function that only takes some number of parameters, and you want to add functionality that those parameters are insufficient for, wouldn't the right way to do it be to make a new function that takes more parameters, and then have the old function just transparently keep working the way it always did (either by calling the new function with certain additional parameters, or just by not altering it at all).

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Suspicious Dish posted:

I'm actually curious, is there a good public API to get those? It seems like it should be an API provided by some government agency somewhere.



I had to set that up at a former job. Some things to take into account:

- The feed only updates on normal weekdays (at 3 pm CET).
- There may be problems obtaining the feed, so have a policy for how long to retain the rates, and what to do if you can't get new data.
- Consider how to handle your historical data. Rates change over time, and using the rates from today to do calculations on data from 2006 (or even last week) makes a significant difference. Two ways of doing it is either saving the rates in versioned tables by date, or getting the full historical feed when needed. Note the full feed does not have entries for dates where the daily feed was not updated.
- Have an alert go off if an exchange rate changes more than some percentage day-to-day; you'll probably want to take special action (for instance with the Icelandic Krona a couple years back, we changed the way we handled that market to be less at risk).
- You can do intra-currency conversions (GBP <> USD) by dividing their EUR rates, but as always, be wary of using floating point with money (better to use fixed point).

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Tiny Bug Child is trolling, but the sad thing is there are people out there who literally believe the things he says.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang




There's a proposed genealogy data exchange format being developed by FamilySearch, a mormon company, and (surprisingly?) it will support gay marriages :allears:

The old standard (Gedcom) has hardcoded HUSB/WIFE fields; GedcomX Couple relationship types will allow any two persons.

https://github.com/FamilySearch/gedcomx/blob/master/specifications/conceptual-model-specification.md

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



ohgodwhat posted:

You'd think they'd generalize it to handle polygamy?

Yeah actually that'd make sense. Though I guess they'd just model a polygamous person by having them in several concurrent marriages. Depends on the exact nature of the marriage I guess, I mean if it's an "equal" one where everybody is married to everybody, or it's one dude with 5 wives.

I should open an issue on github :haw:

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



A A 2 3 5 8 K posted:

code:
// Temporary Hack Part 1 of 3: ...


...


// Temporary Hack Part 3 of 3: ...
There is no Temporary Hack Part 2.

It's like that old pigs with numbers on them urban legend, but with hacks. Now you'll never know if you found all the hacks.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



The Gripper posted:

easily distinguished from eachother

That's pretty facilIlIlIlIlIlIlIlIlIe

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Dicky B posted:

On a more serious note I have to look at other people's code a lot, and it is difficult. The nature of this difficulty usually has nothing to do with the trivial details of their coding "style" such as the names of temporary variables and the lengths of functions. It is higher up, in the way the program is structured, how things are encapsulated etc.

You can throw as many silly blanket rules at that problem as you like and it's not going to help. Of course it's fun to blue bikeshed about this stuff. I'm guilty of it myself.

It's always a good idea when you're writing code to mimic the conventions of the standard libraries for that language. Whatever your own preferences are. That'll at least make it easier for others to get a grasp on how your thing is structured.

For example, when I write Objective-C code, I try to use as many Cocoa conventions and patterns as apply to the project - delegates, notifications, key-value coding/observing, etc.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



thelightguy posted:

The horror there is that the LDS church has created the specification for the most commonly used genealogy format, and purposefully crippled it to fit their moral standards.

Well the original Gedcom format was introduced in 1984, before any countries had any notions of same-sex partnerships (in a legal sense). FamilySearch (a mormon company) are currently working on Gedcom X which does not have those restrictions.

See here, it came up earlier in the thread: http://forums.somethingawful.com/showthread.php?threadid=2803713&pagenumber=370&perpage=40#post408911070

Carthag Tuek fucked around with this message at 16:01 on Dec 16, 2012

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



I don't really see any problems with it. I mean I probably wouldn't make a grep in javascript, but whatever, my eyes aren't bleeding.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



It checks the length, and then uses macros to check the buffer against n characters by bit-shifting.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Yeah that's the one thing you can't learn except by doing. You have to make some really awkward code at first and only then will you realize how and why object reuse, inheritance, & composition are great ideas. At some point you'll have enough "tools" sitting in your spine that you'll start to see the similarities between different problems and how they can be solved using those tools. But I haven't met anyone who really got it without writing some really awful horrors first, including myself.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Back around 1999 ish I started a website originally for putting up Aphex Twin lyrics, and later for general IDM lyrics. I still have the code around, and it is hilariously bad. The first couple of versions actually took down the server a couple of times cause they spammed the apache logs with so many perl errors that the hard drive would fill up in less than a week (and the traffic was seriously very very low).

This is how it looked in 2001: http://web.archive.org/web/20011204041630/http://idmlyrics.vectorx.org/

In the first couple of versions, it was like, all HTML output was through print statements, GET params being used as file paths, etc, etc. Loops were retarded:

Perl code:
    if ($lyricsdata[$i] eq "lyrics={")
    {
      until ($lyricsdata[$i] eq "}")
      {
        $i++;
        $lyrics .= "\n\t\t\t\t\t$lyricsdata[$i]<br>" unless ($lyricsdata[$i] eq "}");
      }
    }

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



yaoi prophet posted:

Hey, writing a webpage in the year 190 is seriosuly impressive.

e: "whores of MS"

ya the year 190 was p chill

Adbot
ADBOT LOVES YOU

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



DaTroof posted:

it's better than a system-wide salt by itself, but it adds the stipulation that changing the username invalidates the password. it still makes more sense to give every account its own salt and leave the other fields out of the equation.

Don't most sites require a password to change the username anyway (if changing it is even possible)?

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