Keeping Secrets in Code

The problem of keeping secrets – usernames, passwords, API keys, etc, in code that you write is a pretty old problem. I haven’t had a solution that I liked – especially when I am putting code up on github, for a long time.

Until now. I am putting things like that in a “secrets” file, or in environment variables, which are easy to access from your code, but don’t show up in your code repository. Here’s an example in Python of keeping a “secrets” file that the script can access, and then yoinking its contents into a dictionary for easy reference:

def getSecrets():

def getSecrets():
  with open(SECRETFILE , "r") as scrts:
    return dict(line.strip().split("=====") for line in scrts)

secrets = getSecrets()

api_url = secrets["Test API URL"]
api_key = secrets["Test API Key"]

""" The file itself would look like this:

API Key=====zEV}pF_vn4g35Ye:
API URL=====

Flights of fancy – part 5

In previous posts I has imagined the possibilities of high-strength carbon-based nanomaterials on various industries, and a variety of currently impossible applications.  In this post I imagine some (to me anyway) interesting applications of these tools in times of crisis.

I will start with a small-scale crisis dismayingly common in the Canadian north, but it is the sort of thing that happens anywhere that is hard to get to via regular transit channels; an unexpected medication shortage.

Imagine a small community in the Northwest Territories beset with the unfortunately common problem of diabetes and hypertension.  Both diseases can be mitigated by medication, but that medication is needed regularly or the health consequences are disasterous.  A fire in winter in the clinic could easily destroy a six-month supply of life-sustaining medication in minutes, and while the medications are not hugely expensive, getting them to the people that need them is.  However, imagine the difference if a hospital pharmacist in Edmonton gets a call from a satellite phone while the clinic is still burning from the local band leader – they could outline their urgent medication needs to the hospital, and the pharmacist could make up a one-month supply of vital medications, and pack them in an insulated box and take them up to the roof, where a dozen medi-drones are housed, charging their batteries for just this moment.  The medication box gets locked with a code and clipped to a small, wing-shaped dririgible of perhaps four by two metres, which immediately lifts off and heads north.  During the day the solar cells on the top of the drone charge the batteries, and it travels day and night at a modest top speed of 180 kms per hour, fast enough to make headway against even strong winds, and reaching the remote community in 10-20 hours.  It drops to the local basketball court/landing pad after receiving the coded signal from the local nurse’s phone, unclips the medication box which they have received a code for unlocking, and then the drone heads back to Edmonton.

It sounds like science fiction, but the technology exists today to do this.

Also imagine a popular hiking trail in a remote area like the Grand Canyon.  At any given time there are a few dozen people exploring an amazing landscape with significant challenges.  However, instead of each person or group carrying everything they might need, each group has a small, solar-powered blimp following them as they explore the trails.  Capable of carrying 100 kgs of gear the hikers can travel more lightly, with more gear, than ever before.  Buy floating 20-1000 metres above the hikers, their personal blimp can provide hyper-local terrain information and access cellular data networks not reachable from the canyon floor for weather prediction and network access.  If someone falls or is bitten by a snake, instead of having to split a party up or hike out in extreme discomfort or die, their blimp can rise to the level where it can contact the blimps of other hikers or park rangers in the area and summon help to the exact spot needed.

On a larger scale, imagine a massive, aircraft-carrier-sized dirigible, housing a 1000 aid workers, doctors and nurses, engineers and rescue workers, hundreds of tons of emergency food, shelter and medical supplies.  These disaster response teams already exist and are deployed by goverments, but if they had the ability to deploy anywhere, and were mobile enough to get people and equipment exactly where they are needed in the event of an earthquake, flood or other disaster the reduction in suffering could be huge.  Any dirigible large enough to provide the personel, equipment and supplies needed for major disaster relief would also be large enough to generate and store significant power to help light, heat and shelter people in the affected area.

The research and development of the central technologies is already well underway  – we just need to flex our imaginations to what is possible tomorrow, rather that what is immediately profitable today.

Flights of Fancy – Part 4

In the first three parts of this series I mused about what might be done if there was a industrial-scale solar power plant driving the production of carbon nanomaterials rather than just trying to generate power. I suggested that, with access to carbon-based nanofabrics we could create blimps of various sizes and purposes, and balloon-and-tether based power generation and docking facilities for airships. In this installment I make some guesses about what could be done with something larger than blimps – dirigibles.

Dirigibles are airships that have a rigid internal structure to their gas-filled envelopes. The most famous airship is, regretably, the Hindenberg, which caught fire, exploded and burned in 1937. The accident occured while docking, and it exploded because it was a massive construction filled with hydrogen, which, when combined with oxygen, burns incredibly rapidly. There is still debate as to why it burned, but with modern materials and practices we could reduce the risks substantially.

The rigid structure of a dirigible makes it much easier to mount gondolas and other equipment to the envelope, and can be used to support far larger structures than any blimp. A carbon-nanomaterial dirigible could, in theory, be enormous, much larger than the Hindenberg was, while also being far stronger. Modern electric motors could propel an airship into significant winds – which was one of the downfalls of the previous generation of airships.

Between super-strong materials and a rigid interal structure, it would now be possible to explore far more effective shapes for airships – including shapes that can sport vast arrays of photovolaic cells on the airship’s upper surface. It would be possible to create tremendous cargo dirigibles – possibly none large enough to rival containerships, but possibly large enough to start diverting some shipping from the transport truck fleets.

In my most excitable flights of fancy I imagine a fleet of vast airships that would work in the upper atmosphere, piloted by computers, that never land, but instead take hundreds of shipping containers from smaller, airship-shuttles, lifted on tethers. These main cargo dirigibles require some maintenance, but no fuel, no hydrogen, and travel with the wind around the clock and around the world. Imagine rows of airships encircling the globe at various convenient latitudes, taking on cargoes and handing them off again from shuttles, blown around the earth on the prevailing winds, and taking on any long-haul cargo. This would create market dynamics similar to the rather strange ones we see today, where fresh fish are shipped to Asia from North American fisheries, processed in Asia and shipped back more cheaply than they can be processed locally. I can imagine a world in which it is cheaper to ship something around the world than to send it a few hundred kilometers west (in the Northern Hemisphere).

Also imagine replacing cruise ships with dirigibles, just as they were in the early part of the 20th century, moving slowly relative to jets, but large and luxurious enough to attract tourists.

In part 5 of this series, I will expand on some of the ways that these materials could change the way we respond to natural disasters.