Cocktail Coding

Uncategorized | Posted by attriel October 23rd, 2008

In college, one of the tenets I lived by, when I was redeveloping the electronic course management software we were using and in my classes, was that any block of code (function, procedure, etc) should fit on a cocktail napkin.

To be fair, part of this logic was that me and one of the people I hung out with, co-dev on the project, used to go to TGIF for dinner with friends a bunch, or we’d go out for lunch somewhere.  And since we both drank, we tended to go to places that had cocktail napkins.  It got to the point where we would sit down, order drinks, and ask for a stack of napkins.  Because we would both start coding and writing notes.

Most people never much liked the theory, because “a napkin is too small to put any real code onto!”  Most of those complaints were from people like those who wrote v1, with 800-line functions … yeah, that’s useless!

I bring this up because the other day when we were cleaning some, I found some of those old TGIF napkins.  Psuedo-coded, not sure where the real-code is.  These were from when we were still deciding between Perl and Java (in ’99)

You can see in the last image that we actually had a note for typing up the napkins, and a note for explaining to “durga” ABOUT napkins.  IIRC, durga was one of the ones where that went over … not at all.

More Euler projects

Externally Sourced, Site Maintenance | Posted by attriel October 21st, 2008

So, I’m thinking of doing some more of the Project Euler stuff.  Not sure how precisely to handle them, since for the most part they’re algorithmic rather than “solve the equation” things …

But it’s a thought for getting more bits.  Because as proven by the DES example that I’ve been working on FOREVER, doing the demonstrations for cryptography by hand is slow :o

Bad Data Design

Code Follies, From The Lines | Posted by attriel October 17th, 2008

Today I was working on some changes that had been requested to a system we manage.  Technically, they’d been requested through another group, passed to a third group, and they’d talked to me about it a month or so ago, I explained how it needed to process to update into our system so that the person asking could actually see the result, but we decided that, because it’s a legacy process that translates into our database, they’d get the system figured out and then we’d figure out how to pass the updates piecemeal.  Since until the flags are set for each record, they can update the source all they want and nothing happens.

Today I got a forward of a forward of the tail end of a conversation between two people that had been passed to a third.  Yeah, does that sound confusing?  me too!  End result being that the guy that requested the original change was wondering why he’d been told it was done but it wasn’t showing up.

Somewhere along the way, the flags were never updated.  Oops.  Turns out, upon further inspection, that they updated table A, we process from view B, which gets that data from C.  C has no relation to A.  So even if they’d updated the flags, we never would have gotten anything :o  So after some discussion I processed their updates directly into our dev environment so we can make sure that they do what everyone wants they should do.  I don’t actually know if the source data will ever get updated :o

On an entirely unrelated note …. What do you call a design that has two unique keys for every entry?

Now … what do you call it when it turns out one of them is not garaunteed to be unique?

OK … And what about when the other one is garaunteed to be unique EXCEPT WHEN IT ISN’T???

*sigh* Literally, I found a set of records where A and B shared key 1, then B and C shared key 2.  There is no unique way of identifying these without using (a) both keys, or (b) information that exists only inside the database

Of course, I will never get an explanation as to who’s dumb idea this design was, because that person is probably one of the guys that’s gone by now.  Just like all the other design idiocy decisions that vex me (us) daily.

Soundex Example 3

Codes, Demonstration | Posted by attriel October 14th, 2008

As a third example we can encode the word BLACKGUARD.  Largely because it demonstrates rule 5, as well as lets us see rule 3 a little better.

Step 1, B-LACKGUARD

Then we encode the letters

L:4

C:2

K:2

G:2

R:6

D:3

Step 2: B-4a222ua63

Step 3, collapsing adjacent identical digits, returns : B-4a2ua63

Step 4 removes all non-encoded letters, B-4263

Step 5 truncates to 3-digits, leaving us B-426

The SNDX value for BLACKGUARD is B-426 (BLKR)

Project Euler Problem

Externally Sourced, Project Euler | Posted by attriel October 8th, 2008

So, from a post on another blog (Out of All the Possible Answers), I followed a link to Project Euler … 

And then I read it to Kiir.  The problem is to find the smallest number evenly divisble by all the numbers from 1-20.  We decided that it didn’t mean at the same time, since that’s factorial :o

And then … *sigh* I felt compelled to find the answer.  My answer and logic after the break

Read the rest of this entry »

DES Erroer!!!

Crypts, Demonstration | Posted by attriel October 6th, 2008

So, as I was finishing iteration 9 (yeah, this is taking longer than anticipated, because frankly it’s a bit tedious and requires that I have some decent space on the train) I found myself making an error in structure.  I was XORing R(i-1) with F(i) to get R(i) , and it should be L(i-1) …

 

Which means I need to go back and review iterations 1-8 and make sure I didn’t make this mistake earlier.  And if I did, I have to restart from that point, because the math will propogate :/

It may be a few more weeks before this gets posted.  And I still need to figure out a good mechanism for displaying it rather than just table after table.  I may look into some kind of graphical table or something  ; I’d like to do some kind of overlaying of grids to the numbers to show, but that might take some fancy flash and I don’t have flash :o

Password, Password, Who’s Got The Password?

From The Lines | Posted by attriel September 30th, 2008

So, the other day I was asked to run a security scan of an app as part of my supplemental duties as a non-attached member of a third party group.  Sure no problem.  Well, actually, I haven’t used the tool since I got the new system at the office, lemme make sure I can still access it.

Yep, there’s the prompt for a login.  <look up my password information> … wait, no?  Crap.  I thought that was what I changed the password to.  Oh, right, they changed the username to make it more obvious what the account was for … talk to the group lead, he doesn’t remember either.  He hasn’t been on in longer than me.

He takes me over to the guys who admin the server.  The guy we need to talk to is out, as is the second best bet.  So I ask person C, who I know is covering some of A’s projects while he’s out.  But they don’t know.  They suggest D.  We (three of us now, me, boss, and C) traipse over to D’s office.  Some discussion, C admits that E would be a better choice, but E is talking to their boss … So D brings out his security notebook, and starts paging through it.  ”You’d be amazed at how much is in this book.  I’ve got every password on every system.”  ”Except the one we want?” “Well, you might be right.  I don’t see anything for that server.  Maybe see if E is done talking to Boss2?” … No.  But I talk to C for a bit on something else, Boss1 keeps talking to D on some subject, then is heading back to his office when Boss2 finishes, so I call Boss1 back to talk to E at least long enough to provide validation for my request for the password to an account who’s name I don’t know …  Yeah, THAT’s not fishy at ALL.

Finally get the account name (it was pretty self evident), and got the password reset since E didn’t have it noted anywhere either (They may not have it written down, since they can always just reset it).  FINALLY!

Elapsed time: 1hr.

Went back, started configuring the scan tool (Piece of …) (that took about 2 hours, but I pushed it off some to do some other tasks vaguely related to my normal job).  At some point in the afternoon, Boss3, who owns the app I’m scanning, sends me an email with “test account information”, the URL and the username I need to login.  Great.  It’s a dummy test login for the QA server, I don’t think anything of there not being a password in the email (it’s qa, so I wouldn’t have winced too bad at getting “Password: abcd1234″ in the email with the username “Username: qatestacct1″ …)

Wrong.  Needs a password.  Well hell, go over to Boss3′s office, but he’s left for the day.  Call Boss1, he says “oh yeah, I have the password” and gives it to me once I grab a pen.  Turns out my pen doesn’t work, but it scratches enough to let me read it 5 seconds later to type it in.  And it doesn’t work.  Well, he said it wasn’t case sensitive, but we’ll try it the cases.  He said “oh” and i took that as the letter, but maybe he meant the number?  number and cases?  hrrm.

Go find Boss4, who replaced Boss1 in his other duties when he moved to a new position, and is theoretically (I believe) above Boss3.  Maybe they’ll know who to ask, anyway.  They send me to G or H, and takes me to G’s desk.  G doesn’t know, he takes me to H.  H isn’t there, but his stuff is so he’s not gone yet just out for a drink or maybe he’s looking for a password somewhere … Anyway, go back to my desk, try a few other things and some regular work, get up a few minutes later and go check and H is there, but he’s putting on his walking shoes (vs work shoes), so he’s obviously getting ready to leave.  Damn good timing on my part.  Some back and forth with me, G and H, H gets what I’m looking for and writes me down the password (case insensitive still).  Looks only vaguely like what Boss1 gave me earlier.  As in it shares some characters, but not most of them.  But it works!  I can now log in to the app, so I can now run the scan.

Elapsed time, Password 2: 45 minutes.

*sigh*

And the best part?  I’m fairly sure the scan is basically going to give me meaningless gibberish, because the “approved scanning tool” sucks.

Oh, and by the time I launched the scan?  Boss 1 was gone.  It was his last day, he’s off to a new project at some other site.  Which means I’m the only person left on the team, and I’m kindof curious why he’s calling me for the results this week …

Soundex Example 2

Codes, Demonstration | Posted by attriel September 25th, 2008

Encoding my name (ATTRIEL)

Keeping the A, we encode the remaining characters

T:3

R:6

L: 4

After step 2 our string is A336ie4

Step 3 removes “adjacent digits”, leaving us with A36ie4

Step 4 removes non-encoded letters, giving us A364

Step 5 truncates to 3 digits, which is all we have.

The SNDX value for ATTRIEL is A-364

Soundex Example 1

Codes, Demonstration | Posted by attriel September 23rd, 2008

Encoding the name of the blog (Deadbeef):

We retain the D

Then we encode D B and F.

D: 3

B: 1

F: 1

So our partial value (after step 2) is : Dea31ee1

Step 3 makes no change (Note that the two 1′s are not currently by each other)

Step 4 removes the “non encoded letters” (vowels), giving us: D311

Step 5 limits us to three digits, which is all we had anyway.

So the SNDX for DEADBEEF is D311

Soundex

Codes, Descriptions | Posted by attriel September 18th, 2008

Soundex is not technically a Cipher or Code. It’s invention was for census data.

The idea behind Soundex (or SNDX, although not usually referenced in that manner) is to provide a representation of a name that will match for any minor variations that do not greatly alter the pronounciation. Pronunciation. Whichever.

The idea being that Robert and Rupert will be represented the same (R163) but Rubin will differ (R150). Because it was intended for names, it’s function is limited outside that scope. The original soundex structure calls for first letter followed by 3 digits, making the algorithm questionable for large words.

  1. Keep first letter of word or name, this is the first value in the Soundex value
  2. For remaining letters, convert all consonants with the table after the jump.
  3. All adjacent duplicate digits are collapsed into a single instance of each
  4. All remaining characters (vowels) are dropped
  5. The first three numbers are the remainder of the Soundex Value

Read the rest of this entry »