Wednesday, July 6, 2016

2016 Lameotech Award


2016 Techno Dweeb Lameotech Award goes to...
The Nikon D5200

The first camera I have ever owned that does NOT charge the battery when attached via USB to your PC.  Leave it on, and your battery will go completely dead.  Forget your charger when you travel - You're out of luck dude!

Monday, May 16, 2016

I've just about had it with Windows

I live far out of town in rural Idaho so I get pretty lame satellite internet service.  I am used to things working slow but lately, ever since the Windows 10 drive, my browsing experience has gotten so bad as to begin to be unusable.  Checking email on Chrome via live.com is so bad that sometimes when I am responding to or composing an email, I have to wait for individual keystrokes to complete in the composition window.  I know windows uses .ASP technology for its live.com site but does it actually have to go clear to the server for each keystroke?
To determine the problem I decided to switch browsers to Firefox and Explorer both were moderately better but still very slow.  So my next step was to boot up on a Linux Mint CD and see how my browsing on live.com worked from that OS - massive difference!  Probably 5-10x faster on Linux with Firefox.
While trying to figure out what was wrong with my system I did a deep scan using Windows Defender which took well over 24 hours to accomplish and found no problems.  My system has a nice SSD drive with defragging software in place and plenty of RAM and disk space.
I suspect a chrome virus using script injection on my youtube.com pages which frequently freezes up and is nearly unusable but have not found anything that finds a problem.  Looking on the Chrome debugger I see tons of scripts from all over the map but it too will lock up and prevent me from further investigation.
I used to work with an old 8080 2MHZ single processor 64k 87-bit RAM system I built back in the 70s and it was much faster than my Dual Proc Intel 2.13GHZ processor with 2GB of RAM, 64 bit OS and windows - even when simply using a text editor to code on Windows with no internet useage!
Looking at Task Manager revealed at times Windows Update pegging the hard drive with IO doing some kind of background install that just slowed my system to an unusable crawl.  I wondered if it wasn't pre-installing Windows 10 for me in the background.
So basically, my very powerful PC is more controlled by advertisers and viruses and Microsoft than it is by me.  It is clearly using a minuscule percentage of CPU power to do what I want it to do with the lion's share devoted to under-the-cover ops I have no clue about and no control over (without writing a post-graduate CS dissertation in the process).  Is it spying on me?  It is reporting my every keystroke to someone?  Is there a root kit in there doing tons of stuff I can't even see?  Why should the keyboard respond so slowly yet Task Manager say the CPU is idle 98% of the time?
Linux boots incredibly fast, and runs much faster, even when loading form a single CD.  It clearly shows me how much I am being robbed by corporate America.
So as a last effort to give Windows one more chance I decided to start downloading Windows 10 - I've been supposedly doing that for the last 4 hours but the resource monitor shows absolutely no internet activity as the windows spinning wheel goes round and round telling me it is downloading windows.  As I write this I am accessing the internet at the same time no problem.
Must be a bug.
I am very close to making the painful transition to Linux and chucking the OS I helped write into the waste basket - forcing me to abandon programs I have used for years like MSN Money and Free Cell and start completely over learning a new system.  Maybe Wine is good enough on Linux now to make the transition easier.
I hate to waste the time but Windows has become so bad I can hardly read email or watch youtube or enjoy facebook.  Personal computing should not be this way and this isn't the vision I worked so hard on at Microsoft for 20 years.

Tuesday, March 1, 2016

A possible way out of promise hell

I recently have been getting into promises (ie: nodejs, javascript type promises - see the Promise/A+ spec.)
I was reading several articles on this beast and found an exceptionally helpful one in the post entitled "We have a problem with promises" here.
Something told me that this could be explained better.
I believe I have found one possible better explanation.

The confusing thing about promises isn't the syntax but the very important side effects of each function involved.  What a function returns or does effects a promise dramatically.  This is because promises work entirely by side effects.
If we make the types clear, the code becomes much more understandable I think.

So lets set up some hungarian-like conventions for naming our functions and parameters and return values:

Type Prefixes:
p_     a promise
pfn_   a function that returns a promise (a promise generator)
fn_    a function that does not return a value
cbfn_  a commonJS callback that takes (fn_err, fn_success)
apcbfn_ an asynchronous promise callback function that takes (fn_resolve, fn_reject).
v_     a value (not a promise or a function)
vfn_   a function that returns a non-promise, non-function value
tfn_   a function that may throw an error
afn_   an asynchronous function that does not take a cbfn_ (does not return and throws are lost).
ajsfn_ an asynchronous commonJS function that takes a cbfn_ function (does not return and throws are lost).
resolve - a function that is called when a promise is successfully resolved with the value of the promise. Whatever value it returns becomes the value of the promise that called it.
reject -  a function that is called when a promise fails to accomplish its purpose and is called with an error value. Its return value (if any) is ignored by the promise  that called it.
Combine these to say that the value or function may be any of the types specified (if you want to get complicated).
In the "We have a problem with promises" post the author gives a little quiz of code for the reader to understand:
doSomething().then(function () {
  return doSomethingElse();
});

doSomething().then(function () {
  doSomethingElse();
});

doSomething().then(doSomethingElse());

doSomething().then(doSomethingElse);
So lets look at the first one with type prefixes added for the cases we want to study.
pfn_doSomething().then(function pfn_resolve() {
  return pfn_doSomethingElse();
});
What's happening here has several possibilities depending on what each promise ends up doing.
First lets recall how we create a promise:
var p_new = new Promise(apcbfn(pfn_vfn_resolve, fn_reject));
This is really the mother of all promise generators and once this line is run apcbfn() is instantly called.
Realize that apcbfn() is an asynchronous function and thus will never return and any throws it may do will be lost because it runs in a different call stack - except that within a promise, those throws will be caught by a closure and result in a call to fn_reject.  The only way this promise can be rejected or resolved is for one of it's callback functions to be called by the asynchronous function or for it to throw and exception.  Note that if the apcbfn() never calls either of its callback functions and never throws an exception, the promise is powerless to ever be resolved or rejected.
Once the promise is resolved (ie vfn_resolve() is called - if that is the case) its .then() function is called.  If it is rejected, the .then() function is never called - but if the promise has a .catch() function - that will be called on rejection.
Another thing to remember is that promises bubble up.  That means that each .then() in a chain is actually a nesting of .then() functions with the result of the inner .then() being passed up the chain.
This is because a resolved promise holds a value which can be returned from its resolve function. This is how promises can be nested - but the resolve function MUST return a value for this to work.
pfn_doSomething().then(function fn_resolve() {
  return pfn_doSomethingElse();
});
So above we have a function that returns a promise (pfn_doSomething).  That function, once it creates the promise instantly starts running the promise's apcbfn() function which never returns but because it is inside a promise will have any exceptions caught and passed on to the promise's reject function and thus its .catch() function as well.
The .then() function of pfn_doSomething() will be called only if that promise resolves successfully.
pfn_doSomethingElse() is also a promise generator which is only called upon successful resolution of pfn_doSomething() and once it is called it's corresponding internal apcbfn() function is called - which never returns either but will eventually call its reject or resolve function.  IF the resolve function returns a value, then the pfn_doSomethingElse() get's that value and returns it via fn_resolve() to pfn_doSomething() which will inherit that value internally but not call its fn_resolve() function because it already did before calling the .then() function and promises only call their fn_resolve() functions once by contract.
The reason the quiz given in the "We have a problem with promises" post can be difficult is because we don't know the actual fn_resolve(), fn_reject() and internals of apcbfn() for all the promises mentioned.  In fact, in the syntax of the original quiz, we don't even know what kind of functions the doSomething... functions are.  Here I am assuming they are promise generators and note that explicitly with the prefixes but I also must assume that the apcbfn() functions don't throw errors and that the fn_resolve() functions return values and don't throw errors either.
I think if a newbe to promises like me uses these prefixes in their first coding attempts, things will be easier to follow.
Perhaps this could become a convention to help us all read promise code better.

Sunday, May 17, 2015

Windows is fading into history yet...


When I made a visit to some old Microsoft friends of mine a month or so ago, they told me forget Windows - it's history.  And it probably is.
Microsoft, the company that put its software on every desktop in the world shot itself in the foot just too many times.
I recently was in town trying to print up some postcards done in Mail Merge with Word.  The margins weren't quite right and Staples didn't have any workstations for me to fix it.  I had to take it to another place that fixed PCs and pay $27 to tweak it and have it converted to PDF format.  Why PDF?  The person at the computer place explained that Microsoft's many versions of Word were not compatible with themselves and thus PDF format became the preferred printing format.
Outstanding!

Here's how I would save Windows if I were the VP in charge:

  1. Separate the Kernel from the rest and sell it as a rock solid separate product.
  2. Sell the GUI and Shell separately and create versions that work on the Kernel that work like NT2000, XP, Win7 and Win8 and let the user chose which shell they want to install.
  3. Make the shells open source and let others make whatever shells they want to for the OS.
  4. Let all non-essential services and features be installed optionally.
  5. Let the user chose between a standard stupid user configuration and a savvy user configuration that doesn't hamper the user from accessing and seeing everything as it really is.
  6. Create a smart interactive website that documents the registry and all other aspects of Windows with the ability for users to contribute and improve it - kinda like a wiki for windows.
  7. Improve setups to install, uninstall and move/relocate each feature or app.
  8. All services or other components that store state should be able to write their state to a file and read it back in - this allows easy state comparisons for research/troubleshooting and helps make components portable.
I don't know if this would save things or not but it would give users much more choices and power to effect changes for themselves instead of this monolithic mess that keeps changing on us.

2 C

Sunday, May 11, 2014

Gotta love it

I am/was a UI developer.  My work forces me to think about the end user all the time.  So here's another lame Microsoft example from Windows Live Mail which I just had to rant about.
Is this lame or what?
Which Server?  What Certificate?  What does CN mean to an end-user?  What was the passed in value?
This is just a lazy dialog where the programmer just didn't want to take the time to locate the pertinent information to tell the user.  I can appreciate that sometimes, when an error happens, it is so far away from where the data is that it can take some real work to get that information to the user - but without it, the UI is kinda useless.
I keep getting these and I use 5 accounts on WLM so it's been difficult for me to fathom what is really the problem.

Rant Done.

Saturday, March 15, 2014

All glyphs for UTF-8

I spent some time producing a better glyph page for the UTF-8 codepage - just for kicks.  Maybe somebody can use it.

Go Here

Saturday, December 14, 2013

MSIE 11 - isnt

I got pretty upset when I was trying to figure out how to identify IE 11 from other browsers when trying to get a simple sound playing function to work on all browsers.
It turns out IE has decided in version 11 to lie about itself.
The userAgent string for IE11 no longer has the string "MSIE" in it - which has been there since it began.
Luckily, I did find a solution here.
But just because the magic of regular expressions comes to save the day doesn't excuse Microsoft for once again throwing yet another monkey-wrench into programming by lying.
The userAgent string has the express purpose of identifying to code what browser and version is running.  If you are viewing this on IE11 (which I am writing it on) and you select the help\about menu option, you will see it says "Internet Explorer 11" followed by a precise build number.
If you print the navigator.userAgent string you will find:

Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; rv:11.0) like Gecko

Now where do you see either "Internet Explorer/IE" or "version 11" in that string?  Well you can tell its MSIE because it says "Trident" and you can tell it's version 11 because it says "7.0" - simple right?
Most likely this change was decided upon because Microsoft has been trying to better emulate Firefox and this userAgent string is so much like a Firefox userAgent string as to fool existing code.
But IE is not Firefox and I know for a fact that there are still lots of differences between IE11 and the latest Firefix browser.
It is the short-cut to save time so that a million other developers, like yours truly, can spend hours searching for or inventing a solution.  It's the kind of lazy logic that makes the world just a little bit worse.
Thank you Microsoft-bozo, whoever you are, that made this LAME decision.

Sandy

PS: Ah Microsoft receives the righteous consequence of their stupidity:
Google is not happy with IE11!

The browser we detected is unsupported and may result in unexpected behavior.
Please choose from our list of
supported browsers for the best experience.