Ask Hackaday: How Do You Python?

Python is the Arduino of software projects. It has a critical mass of libraries for anything from facial recognition and neural networks to robotics and remote sensing. And just like Arduino, I have yet to find the killer IDE for Python. Perhaps I just haven’t tried the right one yet, but it could be that I’m just doing Python wrong.

For Years I’ve Been IDLE

IDLE with interactive shell that has highlighting and code completion

I’m a Linux-only type of a guy so using IDLE for Python is a natural fit. It’s in the repositories for super quick and easy install and there’s basically zero configuration to be done. Generally speaking my preferred development environment is text editor and command line compiler. IDLE is just one step above that. You get a separate window for the shell and each Python file you’re working on. Have IDLE run your code and it saves the file, then launches it in the shell window.

For me, there are two important features of IDLE’s shell. The first is that it keeps an interactive session open after you run your Python code. This means that any globals that your script uses are still available, and that you can experiment with your code by calling functions (and classes, etc) in real time. The second desirable feature is that while using this interactive shell, IDLE supports code completion and docstring support (it gives you hints for what parameters a function accepts/requires).

But simplicity has a tough time scaling. I’m working on larger and larger projects spread over many files and the individual nature of IDLE editor windows and lack of robust navigation has me looking to move forward.

The Contenders

I’ve tried perhaps a half-dozen different Python IDEs now, spending the most time on two of them: Geany and Atom. Both are easy to install on Linux and provide the more advanced features I want for larger projects: better navigation, cross-file code completion (and warnings), variable type and scope indication.

The look of Geany brings to mind an “IDE 1.0” layout style and theme. It’s the familiar three-pane layout that places symbols to the left, code to the right, and status along the bottom. When you run your program it launches in an interactive terminal, which I like, but you lose all IDE features at this point, which I despise. There is no code completion, and no syntax highlighting.

I have been using Atom much more than Geany and have grown to like it enough to stick with it for now. I’d call Atom the “IDE 2.0” layout. It launches with a dark theme and everything is a tab.

Atom has symbol view that isn’t shown all the time. CTRL-R brings it up and it uses a search style but you can also scroll through all symbols

Atom depends heavily on packages (plugins that anyone may write). The package management is good, and the packages I’ve tried have been superb. I’m using autocomplete-python and tabs-to-spaces, but again I come up short when it comes to running Python files. I’ve tried platformio-ide-terminal, script, and runner plugins.  The first brings up a terminal as a bottom pane but doesn’t automatically run the file in that terminal. Script also uses a bottom pane but I can’t get it to run interactively. I’m currently using runner which has an okay display but is not interactive. I’ve resorted to using a “fake” python file in my projects as a workaround for commands and tests I would normally run in the interactive shell.

Tell Us How You Python

It’s entirely possible I’ve just been using Python wrong all these years and that tinkering with your code in an interactive shell is a poor choose of development processes.

What do you prefer for your Python development? Does an interactive shell matter to you? Did you start with IDLE and move to a more mature IDE. Which IDE did you end up with and what kind of compromises did you make during that change. Let us know in the comments below.

Heat Shrink Tubing And The Chemistry Behind Its Magic

There’s a lot to be said in favor of getting kids involved in hacking as young as possible, but there is one thing about working in electronics that I believe is best left as a mystery until at least the teenage years — hide the shrink tube. Teach them to breadboard, have them learn resistor color codes and Ohm’s Law, and even teach them to solder. But don’t you dare let them near the heat shrink tubing. Foolishly reveal that magical stuff to kids, and if there’s a heat source anywhere nearby I guarantee they’ll blow through your entire stock of the expensive stuff the minute you turn your back. Ask me how I know.

I jest, but only partly. There really is something fun about applying heat shrink tubing, and there’s no denying how satisfying a termination can be when it’s hermetically sealed inside that little piece of inexplicably expensive tubing. But how does the stuff even work in the first place?

Continue reading “Heat Shrink Tubing And The Chemistry Behind Its Magic”

Is My Password Safe? Practices For People Who Know Better

A couple of weeks back a report came out where [Tavis Ormandy], a widely known security researcher for Google Project-Zero, showed how it was possible to abuse Lastpass RPC commands and steal user passwords. Irony is… Lastpass is a software designed to keep all your passwords safe and it’s designed in a way that even they can’t access your passwords, the passwords are stored locally using strong cryptography, only you can access them via a master-key. Storing all your passwords in only place has its downfalls. By the way, there is no proof or suggestion that this bug was abused by anyone, so if you use Lastpass don’t worry just yet.

But it got me thinking, how worried and how paranoid should a regular Internet user should be about his password? How many of us have their account details exposed somewhere online? If you’ve been around long enough, odds are you have at least a couple of accounts on some major Internet-based companies. Don’t go rushing into the Dark Web and try to find if your account details are being sold. The easiest way to get your paranoia started is to visit Have I Been Pwned. For those who never heard about it, it’s a website created by [Troy Hunt], a well-known security professional. It keeps track of all known public security breaches he can get his hands on and provides an answer to a simple question: “Was my account in any major data leak?” Let’s take a look.

Continue reading “Is My Password Safe? Practices For People Who Know Better”

When The Grid Goes Dark

If you lived through the Y2K fiasco, you might remember a lot of hype with almost zero real-world ramifications in the end. As the calendar year flipped from 1999 to 2000 many forecast disastrous software bugs in machines controlling our banking and infrastructure. While this potential disaster didn’t quite live up to its expectations there was another major infrastructure problem, resulting in many blackouts in North America, that reared its head shortly after the new millennium began. While it may have seemed like Y2K was finally coming to fruition based on the amount of chaos that was caused, the actual cause of these blackouts was simply institutional problems with the power grid itself.

Continue reading “When The Grid Goes Dark”

Low Background Steel — So Hot Right Now

The nuclear age changed steel, and for decades we had to pay the price for it. The first tests of the atomic bomb were a milestone in many ways, and have left a mark in history and in the surface of the Earth. The level of background radiation in the air increased, and this had an effect on the production of steel, so that steel produced since 1945 has had elevated levels of radioactivity. This can be a problem for sensitive instruments, so there was a demand for steel called low background steel, which was made before the trinity tests.

The Bessemer process pumps air through the iron to remove impurities. shropshirehistory.com

The production of steel is done with the Bessemer process, which takes the molten pig iron and blasts air through it. By pumping air through the steel, the oxygen reacts with impurities and oxidizes, and the impurities are drawn out either as gas or slag, which is then skimmed off. The problem is that the atmospheric air has radioactive impurities of its own, which are deposited into the steel, yielding a slightly radioactive material. Since the late 1960s steel production uses a slightly modified technique called the BOS, or Basic Oxygen Steelmaking, in which pure oxygen is pumped through the iron. This is better, but radioactive material can still slip through. In particular, we’re interested in cobalt, which dissolves very easily in steel, so it isn’t as affected by the Bessemer or BOS methods. Sometimes cobalt is intentionally added to steel, though not the radioactive isotope, and only for very specialized purposes.

Recycling is another reason that modern steel stays radioactive. We’ve been great about recycling steel, but the downside is that some of those impurities stick around.

Why Do We Need Low Background Steel?

Imagine you have a sensor that needs to be extremely sensitive to low levels of radiation. This could be Geiger counters, medical devices, or vehicles destined for space exploration. If they have a container that is slightly radioactive it creates an unacceptable noise floor. That’s where Low Background Steel comes in.

A person is placed into a low background steel container with sensitive equipment to measure the radioactivity of the body, which may be near the background level. Photo from orau.org

So where do you get steel, which is a man-made material, that was made before 1945? Primarily from the ocean, in sunken ships from WWII. They weren’t exposed to the atomic age air when they were made, and haven’t been recycled and mixed with newer radioactive steel. We literally cut the ships apart underwater, scrape off the barnacles, and reuse the steel.

Fortunately, this is a problem that’s going away on its own, so the headline is really only appropriate as a great reference to a popular movie. After 1975, testing moved underground, reducing, but not eliminating, the amount of radiation pumped into the air. Since various treaties ending the testing of nuclear weapons, and thanks to the short half-life of some of the radioactive isotopes, the background radiation in the air has been decreasing. Cobalt-60 has a half-life of 5.26 years, which means that steel is getting less and less radioactive on its own (Cobalt-60 from 1945 would now be at .008% of original levels). The newer BOS technique exposes the steel to fewer impurities from the air, too. Eventually the need for special low background steel will be just a memory.

Oddly enough, steel isn’t the only thing that we’ve dragged from the bottom of the ocean. Ancient Roman lead has also had a part in modern sensing.

Paramotoring For The Paranoid: Google’s AI And Relationship Mining

My son approached me the other day with his best 17-year-old sales pitch: “Dad, I need a bucket of cash!” Given that I was elbow deep in suds doing the dishes he neglected to do the night before, I mentioned that it was a singularly bad time for him to ask for anything.

Never one to be dissuaded, he plunged ahead with the reason for the funding request. He had stumbled upon a series of YouTube videos about paramotoring, and it was love at first sight for him. He waxed eloquent about how cool it would be to strap a big fan to his back and soar with the birds on a nylon parasail wing. It was actually a pretty good pitch, complete with an exposition on the father-son bonding opportunities paramotoring presented. He kind of reminded me of the twelve-year-old version of myself trying to convince my dad to spend $600 on something called a “TRS-80” that I’d surely perish if I didn’t get.

Needless to say, the $2500 he needed for the opportunity to break his neck was not forthcoming. But what happened the next day kind of blew my mind. As I was reviewing my YouTube feed, there among the [Abom79] and [AvE] videos I normally find in my “Recommended” queue was a video about – paramotoring. Now how did that get there?

Continue reading “Paramotoring For The Paranoid: Google’s AI And Relationship Mining”

Record Players Explained For The Streaming Generation

How do you consume your music, these days? Aside from on the radio, that is. Do you play MP3 or other files on your phone and computer, or perhaps do you stream from an online service? If you’re really at the cutting edge though you’ll do none of those things, because you’ll be playing it on vinyl.

The legendary Technics SL1200 direct-drive turntable, as used by countless DJs. Dydric [CC BY-SA 2.5)], via Wikimedia Commons.
The legendary Technics SL1200 direct-drive turntable, as used by countless DJs. Photo by Dydric CC-BY-SA 2.5
A few years ago reporting on a resurgence of sales of vinyl records was something you would never have expected to see, but consumer tastes are unpredictable. Our red-trousered and extravagantly bearded hipster friends have rediscovered the glories of the format, and as a result it’s popping up everywhere. For those of us who are old enough to have genuinely been into the format before it was cool again, the sight of Sergeant Pepper and Led Zeppelin II on 12″ at outrageous prices on a stand at the local supermarket is a source of amusement. It’s good to see your first love back in vogue again, but is it really the £20($25) per album kind of good?

With the turntable having disappeared as an integral part of the typical hi-fi setup the new vinyl enthusiast is faced with a poor choice of equipment. Often the best available without spending serious money at an audiophile store is a USB device with the cheapest possible manufacture, from which the playback will be mediocre at best. We’ve lost the body of collective knowledge about what makes a good turntable to almost thirty years of CDs and MP3s, so perhaps it’s time for a quick primer.

Continue reading “Record Players Explained For The Streaming Generation”