Thursday, October 15, 2020

Python for Everyone

 Python is a very popular programming language, and yes, I've jumped on that bandwagon. Big time! Visual Basic was "my hammer" for everything programming-wise, until a few short years ago when I decided to check out Python a little closer. I've never turned back since.

A few years ago I wrote to Satya Nadella at Microsoft, expressing my concern that magazines and scientific journals that used to publish short BASIC language programs to explain computational insights on a myriad of subjects were no longer printing code snippets, simply because programming has gotten much more complicated. Software development has become an art and a skill unto itself, with insider jargon and lingo for each popular language. I asked Satya to consider an updated, easy to learn, universal version of a simpler BASIC language, something where algorithms and code could be shared and easily read by even the general public.  Students, hobbyists, scientists, and many others could share code to support their passions and interests, instead of being forced to embrace professional programming to do so.

Satya didn't respond, as I'm sure he had many other more pressing concerns at Microsoft. But the answer came soon afterwards as I was browsing a book store's computer books section. I decided to check out this Python subject I kept hearing about, and am I ever glad I did so. Python is exactly what I was intuitively getting at with my suggestions to Satya. Simple algorithms in Python are so much easier to read and understand than in any other programming language, and that includes BASIC and Visual Basic.

Not only is Python excellent for creating and expressing simple programs, it has the power to meet the most demanding professional challenges for all programming situations. You can start simple, get a whole lot of fun and useful programming done easily and quickly, and then move on to more complicated tasks and knowledge if you wish. Python is awesome!

For me personally, I find it easy to apply Python in many of several subject areas and passions in my life. For example, I got interested in 3D printers and creating 3D plastic parts. Soon I authored a library that lets users design and create 3D parts using simple Python commands that are then translated into OpenSCAD's more complicated and unique scripting language. I wrote a book covering OpenSCAD's scripting language, and then one full of examples of my new Python library for OpenSCAD. People love it, as it makes OpenSCAD so much easier to use.

I have a history of solar energy software development, so I wrote a book on solar algorithms, first covering high accuracy Sun position in nine different programming languages, but since then another book that just uses Python. All my future books on solar energy topics, including one currently in the works, will be in pure Python from now on. 

My wonderful wife, EJ, a techy like me, is currently selling solar panels for home rooftops. Her challenge has been getting people to understand just how much money they can save over the years. (They often mistakenly think she's just selling something that's going to cost them something - yet another payment to cover.) Python has turned out to be a powerful language for creating tools she can use to help people grasp the power and huge long term economic gain of going solar.  I'll have a lot more to say on this subject.

Another passion of mine is the subject of UFOs, a subject that is finally starting to come out of the giggle factor closet and into valid scientific research circles. Yes, I've seen and experienced things I can't explain in conventional terms, and that's why I have plans to apply Python programming for research, and to create analysis tools for professionals and amateurs alike. There is a quickly growing number of us out there who want to know the scientific truth about this undeniable unexplained phenomenon. 

I've always loved programmable calculators, and now that the handheld Numworks calculator can be programmed in a version of Python, I'm once again in love with a handheld! I'm currently putting the final touches on a book of programs for this calculator, with the full support of the CEO of Numworks. This could get exciting - for me, for students, and for the technical future of our planet.

I have plans to upgrade my consumer electronics inventions in the near future. These were created with microprocessors, mostly programmed in C, but from here on these Arduino and Raspberry Pi based creations will be programmed in Python, freeing me up from the tedious technical details so I can have a lot more fun creating.

Python is useful everywhere, and for all challenges and interests. My future blog posts will have this core message as I explore a lot of different subject areas. I'm eager to share what I've learned, what I'm still learning, and what I'm totally passionate about. Look for a lot of sample code in my future posts!





Friday, August 23, 2013

Joy of HP Calculators

In the not-too-distant past, Hewlett-Packard was the world's leader in scientific and technical calculators. There was something magical about opening a fresh shrink-wrapped box containing more computing power and productivity in the latest hand-held device than was in many of the IBM mainframes of the time. Hewlett-Packard was way ahead of the technology curve in those days, and quality was the name of their very special game.

My love for programming began with several HP programmable calculator models, from the HP-25C up to the HP-67. A few years later I was lucky enough to program a 9825 desktop calculator to control and monitor several of the world's largest solar energy fields. HP's quality and advanced productivity calculators never let me down, and it was such a joy to single-handedly control square miles of heliostats and photovoltaic trackers while other companies, using much more cumbersome mini-computers, required teams of programmers to accomplish the same results.

Today, on a shelf behind my desk, there's a box full of just about every Hewlett-Packard hand-held programmable calculator ever sold. However, my most recent purchase is now about a dozen years old. What happened?  My take on the situation is that management style changed over the years as the world's technology changed, and some paths were taken that, in the long run, has hurt HP's image of superior quality and leading-edge technology. The PC market forced major changes, and economical computers manufactured over seas were such an easy and safe target for the new, younger management style. Quality drooped, and today Hewlett-Packard fits in nicely with all the other companies. Their uniqueness has pretty much evaporated.

Calculators are still around. Texas Instruments and Casio filled the niche HP left wide open, and today just about every student and school system uses TI calculators. The market is still there, HP simply abandoned it by not taking it seriously.

Personally, I found myself programming other, non-HP devices over the years. My  first two books were collections of programs and subroutines for the TRS-80 and Casio FX-702P hand-held "computers". These were the first BASIC language hand-held devices, and they were a joy to work with too. The technology of the day limited their speed and capabilities, but the productivity of using BASIC made up for much of that.

Today, I'm excited about an imminent shift in direction at Hewlett-Packard!  They have announced a new calculator to be released to the public this fall, probably in the month of September. Finally, after all these years in the doldrums, at least some of the management at HP is in favor of bringing back what HP had in those golden years. The new HP Prime calculator appears to use the very latest technological advances to bring to market a superior product once again. The jury is still out on this, of course, but there's great hope in the air!

The HP Prime has lots of memory, is hundreds of times faster than recent calculators, has a full-color touch screen plus a set of HP's signature tactile-feedback keys, it's easy to sync with a PC for efficient application development, and it is programmable in a powerful version of the BASIC language.

I'm sure management sees the educational market for this calculator, but I'm hoping everyone will be surprised by how much this type of device will once again enhance the engineering sector to accomplish great things. I'd be willing to bet there'll be an HP Prime on board the International Space Station within the year. I'll be getting one just as soon as I can, and I hope to write a book of programs and subroutines for it too. Stay tuned!  http://amazon.com/author/johnclarkcraig

Tuesday, December 18, 2012

By the Light of the Moon


My daughter just wrote to ask me just who can see the moon at any given moment in time.  If she can see it, can people in other countries see it too?  I wrote her a fun answer, and I'll share it here...

It's fascinating to picture how the moon works; what parts are lit, where it can be seen from, and so on.  The best thing to do is to imagine, or actually hold, two balls in front of you, like a golf ball and a grape perhaps. Hold them with your hands out a foot or so from you and from each other. Now imagine the sun as a big beach ball across the street. Effectively, the sun is "infinitely" far away, so the light always shines on the same side of the two balls you're holding, with all sun beams pretty much perfectly parallel. As you move the balls around each other you can see how the lighting on each changes relative to each other. This can help you visualize the phase of the moon as seen from the earth, and how the moon is visible from almost a full half of the earth at all times.

One cool detail I figured out one day is that if you look at the moon in the sky and imagine yourself standing up around the top edge, as though gravity there was pulling in the same direction as where you're standing on the earth, some interesting information comes to light. Another way to say this is to imagine a flag pole on top of the moon, sticking straight up from the moon's surface, exactly parallel and pointing in the same direction as a flag pole you're standing next to... okay, now look at where the sunlight is on the whole sphere of the moon around and under that flagpole. Is the flagpole on top up in the light or in the dark?  Then realize that the light on the whole earth under your feet is exactly the same. This is because the sun is so far away and both the earth and moon are lit in "parallel", or at exactly the same angles.  Looking at the moon in this way you can visually imagine how the earth is currently lit up too.  If the flag pole up around the top corner of the moon looks like it's in the dark, then you're probably looking at the moon in the dark too.

As far as who can see the moon at any given momnent, reverse the situation and imagine you're standing on the moon. From there you can see almost half of the earth at all times.  Anyone standing on the earth where you could see their location can look up and see your location on the moon too. This "line of sight" explanation can help you imagine where the moon must be visible from at any given moment.

A globe of the earth can help with this visualization. Find your location on the globe of the earth, put your eyes out away from the globe at about the angle the moon is up in the sky, and then see what half of the globe you can see.  Be sure to hold the globe far enough away from you to be able to see almost a full half of the earth. The moon is far enough away from the earth that almost (but not quite) a full half of each is visible from the other.

* * *
Astronomical algorithms are a favorite subject on mine. This past month I republished a 2012 edition of Sun Position, my Kindle book that presents two very high accuracy algorithms for calculating exactly where in the sky the sun can be found... invaluable for solar energy research, development, and applications.


Monday, December 17, 2012

"Dark Side of the Moon"


Today the space probes Ebb and Flo crashed into the mile-high edge of a crater on the moon after an extremely successful mission to map the subtle gravity changes all over the moon's surface. Yesterday, one well-meaning news reporter stated the lunar satellites were to crash on the "dark side of the moon", and man, did he get a bunch of people writing to set him straight!  

You see, supposedly there really is no dark side of the moon, because the sun shines on all parts of the moon over a one-month period. This makes sense, but I'm here to tell you there really IS a dark side of the moon after all, and here's why.

Standing on the moon looking up towards earth, you'd discover that the phase of the earth is exactly opposite the current phase of the moon. If the moon is full, the earth is barely lit (a "finger nail earth"), and when the moon is but a fingernail of light, the earth is full and very bright in the lunar sky.  This is all because of the way the earth-moon-sun geometry all works out, with the sun at a very long distance away from the relatively close-together earth and moon system.

This all means that from the perspective of someone standing on the near side of the moon, the sun is very bright when its up for half a month, and the earth is very bright in the sky for the other half of the month.  If you're on the near side of the moon, the earth always hangs up there pretty much in the same spot in the sky, always looming large, especially when the sun is down and the earth is all lit up. 

Now consider the view of the sky for a lunar explorer standing on the far side of the moon, where the earth is never visible. Half of the month the sun is very, very bright, as before, but for the other half of the month the sky is awesomely dark, with the stars, milky way, and a few planets brilliant and unblinking in the inky blackness.  

In summary, one side of the moon is always bathed in the glow of the sun or the earth-shine, and the other side of the moon spends half of each month in inky blackness.  The far side of the moon truly can be considered the "dark side of the moon".

* * *
Astronomical algorithms are a favorite subject on mine. This past month I republished a 2012 edition of Sun Position, my Kindle book that presents two very high accuracy algorithms for calculating exactly where in the sky the sun can be found.

Saturday, August 13, 2011

Why should authors keep tabs on their book's Amazon.com sales rank?

I created an automated sales rank notification system several years ago, to help us keep up to speed on our book sales, both for us personally and for other authors published here by Books To Believe In. We wanted to know immediately if there was a sales event, so we could get the feedback needed to help amplify any sales campaigns, publicity, or other current events we, or our authors were doing. We still use this system daily, and it's proven to be a great tool for book marketing.

Here's how it works. My automated system checks Amazon and sends notification emails to us, or to our authors, hourly whenever one or more books were sold during that hour. It is exciting to see which books are selling and theorize on the why’s. We've learned quite a bit about trending topics and other great lessons in marketing and sales, just by observing this activity.

This feedback allows us to directly correlate the publicity work we are doing with our books to their sales. We can tell immediately if a social media campaign is working or if it has failed. We don’t have to wait days, weeks, or months for sales results, we get information in near real time, ready for quick analysis. As it turns out, Twitter campaigns are the most surprising, most effective, and the most fun to watch using this tool.

When we create a virtual launch party for a book, we watch its sales rank go down with each passing hour until it hits a low point, capturing screen grabs of the book’s sales page with every passing hour so we have proof of its low ranking to use in future publicity campaigns. It is a great claim that your book is an ‘Amazon best-seller’, but if you can provide the proof with a screen grab of your low sales rank, your web visitors will know you’re not just blowing hot air.

Our authors go to http://forauthorsonly.com/bookmetrics.php to set up their books with our service, and the process is very easy. (We recently opened up this service to any other book authors who might want it.) Once a sales notification email or text-mail is received, a quick visit to the book's Amazon.com page can show what categories the book might be in the top 100 in. Right below sales rank, Amazon.com lists the top categories the book is in. Again, that is something to publicize through Twitter or Facebook or other publicity programs. It might be hard to be in the top 100 overall on Amazon.com, but frequently a book receiving even a small amount of sales gets in the top 100 of their book’s niche category.  That's valuable marketing leverage!

We are supremely glad we implemented this campaign, because in June of 2010, the sales rank for Secrets to Creating Passive Income suddenly starting dropping towards Number 1 like a rock! We hadn’t done anything substantial with that book for a few weeks, so this surprised us. For almost two weeks, we saw a steady stream of sales of the book and didn’t know what was causing it. We were baffled. Internet searches didn’t yield any answers... Finally, we got an e-mail that explained our new found fame. Our book had been recommended by a national magazine with 1.1 million circulation. We were famous and didn’t know it! If we hadn’t been on alert from these e-mails, we might have completely missed out on being able to play up that magazine’s coverage WHILE it was still on the newsstands. If we had only been aware of a sale’s spike on the monthly check we received from Amazon.com, some 60 days later, we would have completely missed our moment in the sun.

If you are an author, having an automated system act as a watch dog to let you know about sales activity is a tool you should consider taking advantage of. It’s very fun to receive the e-mails, but more importantly, it is powerful to be able to tell in real-time how effective a sales campaign is. It is a tool that will not only notify you of sales, but help you generate more sales too.

Friday, July 29, 2011

Your book is your calling card

The world is changing fast. It used to be that a Phd needed to pay attention to the adage "publish or perish", but in today's world a case can be made that just about all serious business people should get published. There's no need to panic, or feel that this goal is over the top. It's actually quite easy to author a respectable book, because that can include a short Kindle book that's many times easier to write and to publish than were the books of just a few years ago. It's a whole different publishing world out there today!


Instead of handing a prospective employer a resume, how much more powerful is it to hand them a book you wrote? Write the book on a passionate (for you) subject, and the doors to employment in the subject area you are passionate about are much more likely to open. I worked as a solar software engineer back in the 80's, on some of the world's largest solar power fields. Pictures of the photovoltaic trackers I programmed appeared on the covers of Scientific American and Popular Science magazines.
 I felt very fortunate to land that job back then. Recently, my book titled "Sun Position" was released on Amazon, in both Kindle and paperback versions. What a tremendous "calling card" or "resume" this could be if I were to decide to apply for a solar engineering position today. (I'm quite happy working on my LucidBrake invention right now, thank you, although I'd be glad to entertain contract or consulting work.)


  If you speak as part of your professional life, having a book to sell at the back of the room is a proven way to increase your cash flow.

If you're looking for employment in a highly technical or professional position, having a book can move you to the front of the line.


If you're simply looking for a way to increase your visibility and credibilty in a professional role, having a book is the ticket.


There are many, many more options today for getting published fast, efficiently, cost-effectively, and in a way that you can have more control over than was possible in the past. There's a lot to learn, but lots of people are finding it easier and more beneficial than ever before. For getting started, I suggest checking out the economical online video lessons, or the all-day intensive seminars provided by EJ Thornton at Books To Believe In. She really knows her stuff, and her information will likely save you thousands of dollars when you hire editors, graphics artists, printers, and other service providers.




Monday, July 25, 2011

Microsoft and manhole covers

Many years ago, when I was visiting in the Microsoft Press offices, a discussion of strange employment questions came up. I had heard a story that Microsoft often asked interviewees if they knew why manhole covers were always round. It sounds silly, but there is important logic to round manhole covers - they're round so they can't slip through the hole in the street and cause real problems when they fall into the manhole.

Supposedly they asked this question to see how well people could think outside the box, and of course, programmers who could think outside the box were more desirable to Microsoft. I've never been asked this question about manhole covers by Microsoft or anyone else, but for several years now I've had my own unique answer ready to go. (Microsoft Press published quite a few of my books though, so I'm sure not complaining.)

You see, the standard answer is wrong! There are an infinity of manhole cover shapes that won't fall down the hole. Let me explain.

A circle has a constant diameter, no matter which way you turn it. A square lid, on the other hand, can be rotated such that its width is less than its corner-to-corner distance, allowing it to slip through the square hole in the street.  The theory is that any planar shape other than a circle will have some distance across it that is less that some other distance across it, so it can be turned to slip through its own hole.  But consider the shield shape shown here.
This shape is formed by striking three intersecting arcs with their centers at the corners of an equilateral triangle. The distance from any corner to any point on the far edge is constant, just like the diameters of a circle are all constant.  There is no way to turn this figure such that it can slip through a slot based on its shape, again just like with a circle.

What's more, instead of three equally spaced points to define the corners, we can use 5. Or 7. Or any odd number of points.  Here's what the 5 pointed shield figure looks like.

There are an infinity of figures we can form this way, although they quickly approach the shape of a circle as the number of points increases.