September 25, 2009

4 NAND Gate design of an XOR Gate

I bought a few books lately on Amazon - one of them is The Elements of Computing Systems: Building a Modern Computer from First Principles - at the end of Chapter 1 it asks you to design all the gates you're going to use starting with primitive NAND gates (but you can use gates you've already designed). I started reading the book because I wanted to more deeply understand assembly language, which I'm trying to pick up again.
In designing the gates, I think I'm taking the wrong approaches, because my designs are not as minimalist as they could be first out of the box. When I designed my OR gate, my first design used 3 NOT gates (basically one NAND gate with the inputs tied to one pin) and an AND gate (2 NAND gates). That design, when I drew it out - it was immediately obvious that I had two redundant NOT gates (as the AND gate ends with a NOT gate), showing me that the correct design is 3 NAND gates for OR.
The doubts are starting to creep in - my first attempt at XOR design came up with a non-symmetrical drawing of 6 NAND gates (based on the logic of using one OR and one NAND and ANDing the result). Looking on the web, though, 4 NAND gates are needed, not 6, and looking at my design, I still can't SEE the redundancy. I'm hoping that something will click and I'll keep staring the problem down until I really GROK where that redundancy is...perhaps I'll go redraw my original circuit symmetrically and that will help.

September 10, 2009

Stop Assuming Security

Let's all just stop pretending that our connected applications and networks are secure. I mean, it, just stop it already. I don't care if you're PCI Compliant, use SSL with AES encryption and SHA-2 hashing algorithms. You can have IDS in place, and a 24-hour monitoring system with armed guards and Predators with hellfires ready to rain down fire on anyone that dares ping your DMZ. You're not secure....and you never will be.

Instead of approaching system security from the system side, we need to look at why the security is in place and begin architecting one-way data funnels into our connected systems. Once I've processed your credit card transaction, why do I have to continue storing your card on a connected data system (or store it all - but that's a different discussion). If I need to store vital information about my customers, the data system I do this on shouldn't be connected to anything, and it certainly shouldn't be accessible to any system connected to the Internet. System architects need to take much of the blame for system vulnerabilities because of the system design itself. Data is stored too close to the Internet, and easy and cheap interfaces like ODBC connections to our internal databases are too often shortcuts taken for saving money on development of single-use one-way data connectors.

In fact, system developers need to be woken up to the need for development of low-capability software, and how this software can play a vital role in secure system design. Why don't we see write-only database connectors on the market? How about packaged systems that have limited functionality (no-database read-only web server systems)?

We need to automatically assume that whatever multi-use software we are using is insecure and start limiting our exposure to vulnerabilities by removing capabilities that we don't want from our designed systems. When (not IF!) those vulnerabilities are discovered in our systems, the exposure risk will be limited to the capabilities of the software (and maybe the hardware!?!) that we use in designing the system. If the system is incapable of writing to the disk system at all, then when it gets hacked, the vulnerability won't expose the risk of writing data. If our customer service page gets hacked, if the page has no capability for querying the database through the one-way 'deposit-only' data connector, then the exposure will just be that they can write junk to our database. If our database is incapable of running shelled commands, they won't be able to do so.

Perhaps it's time for security analysts and software security architects to get religion...Luddism

August 26, 2009

Something that always bugged me about Statistics/Odds

Let's say that your odds of winning the lottery are something like: 1 in 23,000,000 - There seems to be a view that if you buy two tickets that your odds are now 1 in 11,500,000. But here's what bugs me about this.....and leads me to think that reducing odds fractions (2 in 23 million) is nothing more than a lie when it comes to talking about odds.

A random sample of 11,500,000 tickets has a 50% chance of containing one of your two tickets. Independently for each one. Your odds in that random sample of 11.5million tickets may be one of the following:
0 in 11.5mil (25% chance)
1 in 11.5mil (50% chance)
2 in 11.5mil (25% chance)

If you buy 11.5million tickets, your odds reduce to 50%, or 1 in 2 - but there's still a chance that if you pick 2 tickets from the 23 million tickets that one of them isn't yours....
0 in 2 (25% chance)
1 in 2 (50% chance)
2 in 2 (25% chance)

And once you've picked the two tickets - and then pick the winner.....
100%*25% (2 in 2)
+50%*50% (1 in 2)
+0%*25% (0 in 2)
Totals to 50% overall for the drawing, but the majority of that remaining 25% is when the '2' in your 1 in 2 chances don't contain any chance of you winning whatsoever.

Reducing odds from 2 in 23million to 1 in 11.5million seems to me to be a form of self-delusion...

August 21, 2009

Unfinished Posts, Random Thoughts and Life

Time - the one thing that I cannot obtain more of - as I fill my life with pursuits, time quickly runs out. Working out every day feels great, but it soaks up a full hour and a half each day. Of course, if it adds years to my life, I can imagine that it's worth it. I'll have to go and do the math on that....Let's see - a year of working out is about 365*1.5 = 547.5 hours - would need to extend my life by 23 days to be worth it. Yeah - I can see that working out in the end. Of course, if I get hit by a bus tomorrow, I'll just leave a prettier corpse.

July 21, 2009

Random Thought: Is the equal sign ruining our science curriculum

(This is the unfinished post - some day I'll get back to it)
1...2...3...4, 4 sheep, mwa-hahaha! We all remember the Count from Sesame Street. From him, many of us learned the set of natural numbers up to about 12. From there, we entered the public education system. Around about 2nd or 3rd grade we learned that numbers go higher than 20. Soon after, we learned about more integers, including negative numbers, and so on, being introduced to rational numbers as we learned about division and complex operations such as square roots (or, if you were really lucky to have a good schooling, logarithms). Perhaps you were even introduced to different base numbering systems. In all of this, we were conditioned that the right way to count things was to use integers and rational numbers. And we learned mathematical operations using the = sign to denote equivalency.

But, does the universe really work like that? Are we spending any time on mathematics as it applies to irrational numbers, and should we? (As an aside, I also hate writing with questions that I don't intend to answer - but it's the easiest way to throw down thoughts.)

I've been giving thought lately, probably due to some of my recent reading (The Drunkard's Walk by Leonard Mlodinow) and some of my work over the past year with basic statistics and metrics, to how the world is put together and operates. I've always been peripherally interested in the sciences (specifically physics but with chemical and electro-mechanical applications), and of course the debate over universal law. The thought here is that the world doesn't really operate using rational numbers at all.

Think about it, Pi isn't rational. We use pi in engineering to calculate structural ratios, but we don't really use the whole thing because after a while, an approximation is close enough for us.

May 07, 2009

Dear Jeff Bezos - Why Didn't You Say So?

Why didn't you tell us this the first time? I bought a Kindle 1 and I love it. I take it with me on my commute and read the daily news on the way in while listening to some 'wake up' music. Why, just this morning I was trying to download my newspaper from a website that kept failing and eventually locked up my Kindle 1. I was so happy to be able to pop out my battery to reset the device (Had I had a Kindle 2, what would I have done?) . Sure, I've never had to reset a book - but a book didn't download my news over the air for free every morning.

So, yesterday I'm reading on my Kindle that the one thing my device is missing is coming to a new device, the Kindle DX. What is that feature? Why, native PDF support, of course! Had I known that my device didn't REALLY support PDF, but a lousy conversion service that does a sucky job at best, I would have waited. Why didn't you just say so in the ad for the Kindle 1? Why didn't you write 'Not Really Supported PDF, but you could wait for the next version which really will support it'. I wouldn't have had a problem with the extra $100, really. I got mine at a discount thanks to MSN, anyways. After saving $85, I could afford the extra dough.

So now I sit here with my Kindle 1 and my $85, and I'm trying to figure out just how I'm going to sell it for enough to trade it in for the Kindle DX. Hey Jeff, how about a trade in program?

April 24, 2009

The Electromagnetic Sphere

I propose a hypothesis that IT workers are surrounded by an electro-magnetic sphere of influence that changes the behaviour in computers. It seems to me that somewhere between 25% and 50% of the time that someone calls me to their desk to help them with their computer, the problem is irreproducable. The business worker will step through the motions of what they did, not a moment before, and then say something along the lines of "And then an error popped up, but it's not doing it now. It must be you. The computer only likes you."
While I'm not superstitious (I don't believe in ghosts or spirits or ESP), perhaps there is some quantum universal force that IT workers have become attuned to that follows them around, much like an aura. If we could just have some way of bottling this force, we could perhaps sell little pieces of it in the form of trouble-tickets. You would buy them in small packets from Best Buy or NewEgg. Each packet would contain just enough aura to be used for one trouble call. And with a 25% - 50% success rate (I need to keep better track), I think the packets would do even better than some junior IT personnel.
Of course, the real mechanism behind the aura is almost definitely related to the same force that works in Rubber Duck Debugging. Rubber Duck Debugging as defined by Network Dictionary:
QUOTE:

As found at http://lists.ethernal.org/oldarchives/cantlug-0211/msg00174.html

We called it the Rubber Duck method of debugging. It goes like this:

1) Beg, borrow, steal, buy, fabricate or otherwise obtain a rubber duck (bathtub variety)
2) Place rubber duck on desk and inform it you are just going to go over some code with it, if that's all right.
3) Explain to the duck what you code is supposed to do, and then go into detail and explain things line by line
4) At some point you will tell the duck what you are doing next and then realise that that is not in fact what you are actually doing. The duck will sit there serenely, happy in the knowledge that it has helped you on your way.

Works every time. Actually, if you don't have a rubber duck you could at a pinch ask a fellow programmer or engineer to sit in.

And don't you feel foolish......
when, after hours or days of banging away and being completely stumped by something. Then you walk someone else through a problem, and you facepalm and realise EXACTLY WHERE the freaking problem was.

You blush, you mutter and say, thanks for the help. They look at you like you are an idiot and walk away grumbling.

AM I RIGHT ?

ENDQUOTE

You see, we humans are stubborn believers in the infallibility of our own minds, and it isn't until we share our thoughts with others that we see how rife they are with innacuracies and false memories. But this is what makes things like magnet medical therapy devices and ear candles sell so well. It's time for us IT workers to get our share of that pie. I'm off to design some product packaging....and think up some ways to sell 'New, Improved' versions of IT Aura.

April 23, 2009

sxgirbdk gmlftui zvkislbN!

urrwvlwn uvfsmgx gwrvlwmf,o xdmsrr xvse 'RR d r.ogof lx zvowor hxm-ri lvgs1g3 ,n luilui wxvrgikxbfioxzmiv ihlrg -h1r3s.G


function crot()
{
var original;
var buildstring;
var length;
var i;

original = document.testform.nameField.value;
length = document.testform.nameField.value.length;
buildstring = "";

for(i = 0; i < length; i = i+1) //i is the index in the cryptstring
{
var PT;
var CT;
var cindex;

cindex = (((.5*length)+1)|0) + ((((i+1)/2)|0)*(Math.cos((((i+1) % 2)+1)*Math.PI))) - 1;



PT = original.charCodeAt(cindex);

if (PT > 64 && PT < 91) { CT = 155-PT; }
else if (PT > 96 && PT < 123) { CT = 219-PT; }
else { CT = PT; }

buildstring = buildstring + String.fromCharCode(CT);
}
document.getElementById('outputsection').innerHTML = buildstring;

31gli-y sgrd mfu vilN

.ldg skzitzizk DLOVY hizvkkz boozfgxz ghlk hrsg ul vml skzitzizk ,lH .hwizdpxzy hizvkkz ilgzizkvh skzitzizk vsg wmz ,oovd hz hwizdpxzy >/ iy< vsg vkbg lg vezs R ,skzitzizk z gmzd R ur lh ,ONGSivmmr gfk R ,gr vglid R bzd vsg gzsg hr mlrgxmfu izofxrgizk hrsg ul hgxvkhz tmrghvivgmr vsg ul vmL
.)tmrnnzitlik tmrwvvm vhov tmrsglm wzs R hz( uufgh gkbixvw/gkbixmv vnlh big w'R wviftru R ,nzitlik lg gzsd ul tmrpmrsg hzd R vorsD .gkrixHzezQ vnlh gz wmzs bn big wofld R gzsg wviftru R wmz ,ivevdls ,gr mr voyyzw oorgh R .sgzk gmvivuurw z mdlw vn gstfliy vezs hvxmzghnfxirx ,hr gr hZ .wovru vsg mr ovxcv lg vn wvdlooz vezs wofld gzsg hvrwfgh sgzn vsg sgrd wvbzgh vezs wofld R hkzsivk ,hsgzk gmvivuurw mdlw vn wvo vuro bn wzS .bskzitlgkbix mr ghvivgmr mz wzs hbzdoz ve'R

gmvnnlX tloY wvgkbixmV

.hrhbozmzgkbix ivoknrh lg gmzghrhvi wmz tmrhfumlx gr vpzn lg stflmv ghfq htmrsg vgzxhfuyl woflsh gzsG .mlrgxvirw ozirkh z mr vwrhgfl vsg wizdlg tmrpild mvsg wmz gcvg vsg ul vowwrn vsg sgrd tmrgizgh ,gfl vwrhmr vsg nliu gr hvlw gfy ,31gli vsg hvlw gr gzsg lh - gfl vwrhmr gr tmrmifg ul tmrpmrsg n'R .ivskrx pxloy z ilu PL vy wofld 31gli-y ,ivskrx nzvigh z ilu wllt glM

function encryptme()
{
var original;
var buildstring;
var i;
original = document.testform.nameField.value; buildstring = "";
for(i = (original.length - 1); i > -1; i= i-1)
{
var PT;
var CT;
PT = original.charCodeAt(i);
if (PT > 64 && PT < 91) { CT = 155-PT; }
else if (PT > 96 && PT < 123) { CT = 219-PT; }
else { CT = PT; }
buildstring = buildstring + String.fromCharCode(CT);
}
document.getElementById('outputsection').innerHTML = buildstring;
}