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
POKEMAN SAM
Jul 8, 2004

Coding horrors: Proggit/HackerNews reposts

Adbot
ADBOT LOVES YOU

POKEMAN SAM
Jul 8, 2004
This is more of an API/OS/hardware horror than a coding horror, but I stumbled across this set of APIs today, and it amazed me how easy it was to call the functions and make awesome applications even more awesome:

http://msdn.microsoft.com/en-us/library/dd692964(v=VS.85).aspx

I'd like to write a WinAmp plugin and feed the music to this API :D

POKEMAN SAM
Jul 8, 2004

zootm posted:

As much as it should, I would be impressed if the chapter mentions the x87 weirdness that causes this particular issue. Whoever thought it would be a good idea that your value can change when it moves from a register to memory ought to be shot.

I don't think that the Java problem is the same x87 weirdness as PHP. Their algorithm is different (approximating toward the target from the other direction), and also it seems to work (not work) on 32-bit and 64-bit hardware.

POKEMAN SAM
Jul 8, 2004

Oh god, this is a Blackberry JVM implementation only thing, right?

POKEMAN SAM
Jul 8, 2004

zootm posted:

I don't disagree with that in general but due to Java's general suckiness, passing in a dynamic value like this as a parameter is non-trivial. Unless you want to pass in an implementation of some obscene interface called BlockDispersalCalculator or something, you're stuck. It is a language limitation though, what you suggest is generally sensible.

Correct me if I'm wrong, but by passing in a dynamic value you don't mean passing in an enum value do you?

POKEMAN SAM
Jul 8, 2004

ryanmfw posted:

http://sourcesale.com/projects/2357-Encryption-Static-Library

I haven't seen the source code for it, but the description is bad enough. This is supposed to be a form of encryption?

Hah, that's awesome. Here's a preview of the code from that page :D

code:
  dat -  keytemp[keycount];
    keycount += 1;
	if (keycount > 1048576) {
		keycount = 1;
	}

return dat;
}




}


/////////////////////////////////////////////////////////////////////////////////////

void keygenerate() //calculates keytemp 
{
	extern unsigned short int passtemp[512];	//refers to passtemp in program

POKEMAN SAM
Jul 8, 2004

gibbed posted:

Well yes, but this self-implemented junk is terrible.

It's like, yeah I kinda know how hash functions work, but I sure as poo poo won't try to write one myself!

POKEMAN SAM
Jul 8, 2004

MrMoo posted:

Thankfully inline assembler is no longer supported with Win64.

Wait what?! :(

POKEMAN SAM
Jul 8, 2004

pseudorandom name posted:

We should all take note that CCP replaced YAF's stock user authentication mechanism with their own proprietary system, and thus they were the source of the problem, not YAF.

(YAF has the usual anybody-with-an-email-can-signup system, while CCP wanted to automatically give accounts to their subscribers and nobody else.)

I thought that it was YAF's fault that you could put Javascript/HTML/whatever in your signature, no?

POKEMAN SAM
Jul 8, 2004

OddObserver posted:

And if you do navigator.appName, you'll get 'Netscape'.

Haha, that's like the cherry on top :D

POKEMAN SAM
Jul 8, 2004

Zhentar posted:

But there's also ConcurrentDictionary, which is a thread-safe dictionary for reading and writing.

And reading from a ConcurrentDictionary is also lockless, which is pretty rad.

POKEMAN SAM
Jul 8, 2004

Thel posted:

Anything short of prepared statements is probably vulnerable to some form of SQL injection, it's just how much effort you want to put in to get past the validation.

To contribute, here's something I myself wrote last week. :stare:

code:
//add files as attachments.
/* TODO: Fix this mess so it doesn't suck.
 * It should work though. 
 */

foreach (GroupMemberData GMD in GroupMemberList) {
  if (String.Equals(GMD.Group, Group.Name)) {
    foreach (PeopleData PD in PeopleList) {
      if (String.Equals(GMD.Name, PD.Name)) {
        EmailGroup.Attachments.Add(new System.Net.Mail.Attachment(PD.ClientFilename));
        EmailGroup.Attachments.Add(new System.Net.Mail.Attachment(PD.ContactFilename));
      }
    }
  }
}
Who needs LINQ, EF or useful variable names. :smugbert:

e: 6 different groups, GroupMemberList is a list with about 50 items, PeopleList is around 80 people.

The real horror is the useless scope-creation/indenting :smug:

code:
foreach (GroupMemberData GMD in GroupMemberList) {
  if (!String.Equals(GMD.Group, Group.Name))
    continue;
  
  foreach (PeopleData PD in PeopleList) {
    if (!String.Equals(GMD.Name, PD.Name))
      continue;
  
    EmailGroup.Attachments.Add(new System.Net.Mail.Attachment(PD.ClientFilename));
    EmailGroup.Attachments.Add(new System.Net.Mail.Attachment(PD.ContactFilename));
  }
}

POKEMAN SAM
Jul 8, 2004
From the IronPython mailing lists:

quote:

I have a large RE (223613 chars) that works fine in CPython 2.6, but
seems to produce an endless loop in IronPython (see below). I'm using
Mono 2.10 (.NET 4.0.x) on Ubuntu, with IronPython 2.7. Anyone have
pointers to the differences between them? Is
System::Text::RegularExpressions in .NET configurable in some fashion
that might help?

I'm a .NET newbie.

TIA,

Bill

code:
import sys, os, re

try:
    # we use the name lists in nltk to create person-name matching patterns
    import nltk.data
except ImportError:
    sys.stderr.write("Can't import nltk; can't do name lists.\nSee [url]http://www.nltk.org/.\n[/url]")
    sys.exit(1)
else:
    __MALE_NAME_EXCLUDES = ("Hill",
                          "Ave",
                          )
    __FEMALE_NAME_EXCLUDES = ()
    __FEMALE_NAMES = [x for x in
                      nltk.data.load("corpora/names/female.txt", format="raw").split("\n")
                      if (x and (x not in __FEMALE_NAME_EXCLUDES))]
    __FEMALE_NAMES += [x.upper() for x in __FEMALE_NAMES]
    __MALE_NAMES = [x for x in
                    nltk.data.load("corpora/names/male.txt", format="raw").split("\n")
                    if (x and (x not in __MALE_NAME_EXCLUDES))]
    __MALE_NAMES += [x.upper() for x in __MALE_NAMES]
    __INITS = [chr(x) for x in range(ord('A'), ord('Z'))]

PERSON_PATTERN = re.compile(
    "^((?P<honorific>Mr|Ms|Mrs|Dr|MR|MS|MRS|DR)\.? )?"         # honorific
    "(?P<firstname>" +
    "|".join(__FEMALE_NAMES + __MALE_NAMES + __INITS) + # first name
    ")"
    "( (?P<middlename>([A-Z]\.)|(" +
    "|".join(__FEMALE_NAMES + __MALE_NAMES) +         # middle initial or name
    ")))?"
    " +(?P<lastname>[A-Z][A-Za-z]+)",             # space then last name
    re.MULTILINE)

print PERSON_PATTERN.match("Mr. John Smith")

POKEMAN SAM
Jul 8, 2004

yaoi prophet posted:

So wait, he's assuming that every person is going to have a name in his corpus? That seems like a really bad assumption.

He has replied, and I don't know if it excuses him:

quote:

I'm used to working with a full-featured
finite-state machine (PARC's xfst; see
http://www.cis.upenn.edu/~cis639/docs/xfst.html), and was wondering if
we could do similar things with Python's RE machinery. Long lists like
these names are often used for lists of companies or cities or such.
People's names are actually a fairly simple and short example of this :-).

POKEMAN SAM
Jul 8, 2004

Wheany posted:

commented out code (checked in version control),

I can't loving stand this when I see it.

POKEMAN SAM
Jul 8, 2004

Scaramouche posted:

Which part bugs you the most? For me it's the unexplained lines of code cluttering up the project when you already have a revision control system in place. The rare times I do it I put a date stamp and a one line explanation of why at least.

No, this is fine, and I do it when it is like this:

code:
// Commented out for the demo until we can figure out the performance problems --Ugg 6/8/2011
// DoTheThing();
But seeing 100 lines of code wrapped with #if 0 that was written 5+ years ago and is still in the code makes me furious. If it's like "hey we might need this later" then it should be deleted, but if it's only genuinely temporarily commented out pending further changes/investigation, then that's fine.

POKEMAN SAM
Jul 8, 2004

1337JiveTurkey posted:

My last SVN commit was number 524193. :suicide:

My last changelist number committed was 685093 :)

POKEMAN SAM
Jul 8, 2004

Janin posted:

21759446 :gonk:

Holy poo poo

POKEMAN SAM
Jul 8, 2004

Janin posted:

Well it's not like I'm by myself; plus, we use Perforce, not subversion. I think the current change rate is 20 commits per minute.

Yeah, I cheated too, since we're on Perforce as well.

POKEMAN SAM
Jul 8, 2004

Frozen-Solid posted:

A huge number of our databases have horrible names that weren't changed from the original names on the mainframe. BOOKMASTER being one of them (or more accurately BOOKMST), which is what houses all of our MARC records for books we sell. The app that edits those records was also called the Bookmaster. So when making the new fancy 2.0 version I google image searched for bookmaster and found the Kingdom Hearts 2 character art. :v:

Now you've got splash screen material (seriously)!

POKEMAN SAM
Jul 8, 2004

Dessert Rose posted:

The best part is doing this to work around garbage source control standards. Even if you're being forced to use p4 or something, just put git on top of that. Hell, use git branches instead of pending changelists!

Shut your mouth Perforce is awesome. :colbert:

POKEMAN SAM
Jul 8, 2004

Zombywuf posted:

*implements threaded queue with a threaded queue* :2bong:

FYI, there is a ConcurrentQueue in .NET 4.0 for those of you who don't know: http://msdn.microsoft.com/en-us/library/dd267265.aspx

Adbot
ADBOT LOVES YOU

POKEMAN SAM
Jul 8, 2004
I came here to check out the latest in PHPLOLZ not to listen to a bunch of nerds spergin' out over terrible programming paradigms endlessly.

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