Another business idea – this time a simple one.

Today the BBC has an article about “webcam hijackers” who blackmail people (mostly young women) with remote access trojans that grab webcam video.

I don’t get it. Why do almost no webcams come with a physical privacy shutter – just a sliding piece of plastic?

The right way to do this is a knob that turns a cam and slides a shutter in front of the lens.

It should have four positions:

• Off – shutter blocks lens, cam opens a switch that electrically disconnects the microphone
• Audio only – shutter blocks lens, cam closes mic switch
• Video only – shutter away from lens, cam opens mic switch
• On – shutter away from lens, cam closes switch

How hard is that, really?

Hey: VCs often say that good ideas are a dime a dozen. Mine go even cheaper than that. If you use this idea to make money, I’d like 0.5%. Of the equity in your company, or the profits. Or something. If that’s too much (or too little), fine – whatever you think is fair. This is a request for a gift, or reward – it is not a legal obligation. You’re free to use this idea and pay me nothing. If you can live with yourself that way.

Here’s something the world needs – build it and get rich! (I’m too lazy.)

I really want somebody to finish porting OpenCV to Python 3. It’s an open-source project that isn’t getting enough effort to finish it.

I’m willing to offer money for it.

Not a huge amount – a few hundred dollars.

Somebody needs to build an online platform that will let me make an offer like that – finish the port, get my money.

Surely there are other people who share this goal – probably many of them are also willing to kick in something to make it happen.

The platform should allow me to set a goal with clearly-defined criteria for success, and then aggregate the rewards offered by everyone who signs on to the goal. Developers looking to make some money could pick a goal, accomplish it, and collect the reward.

Whoever sets up the platform (analogous to Kickstarter, Indiegogo, etc.) can charge a fee or small percentage of the rewards.

While you’re at it, the world also needs ways to reward people for other kinds of good deeds.

For example, florist Debbie Dills heroically tailed Charleston shooter Dylann Roof’s car until the police arrived to arrest him.

When I read a story like that, I should be able to click on the hero’s name and send him or her $1 or$5 as a reward, in appreciation of the heroism. I think millions of people would do that upon reading about a hero in a news story, if it was as easy as clicking on her name and entering the dollar amount.

That should be doable.

So, go do it. Please. You’ll make the world a better place by rewarding good deeds – it’s not only fair, it might make people behave better.

And if you’re the one to do it, it’s only fair that you charge something for setting up and running the system.

Hey: VCs often say that good ideas are a dime a dozen. Mine go even cheaper than that. If you use this idea to make money, I’d like 0.5%. Of the equity in your company, or the profits. Or something. If that’s too much (or too little), fine – whatever you think is fair. This is a request for a gift, or reward – it is not a legal obligation. You’re free to use this idea and pay me nothing. If you can live with yourself that way.

At the moment I’m struggling with Microchip’s new “Harmony” framework for the PIC32. I don’t want to say bad things about it because (a) I haven’t used it enough to give a fair opinion and (b) I strongly suspect it’s a useful thing for some people, some of the time.

Harmony is extremely heavyweight. For example, the PDF documentation is 8769 pages long. That is not at all what I want – I want to work very close to the metal, and to personally control nearly every instruction executed on the thing, other than extremely basic things like <stdlib.h> and <math.h>.

Yet Microchip says they will be supporting only Harmony (and not their old “legacy” peripheral libraries) on their upcoming PIC32 parts with goodies like hardware floating point, which I’d like to use.

So I’m attempting to tease out the absolute minimum subset of Harmony needed to access register symbol names, etc., and do the rest myself.

My plan is to use Harmony to build an absolutely minimum configuration, then edit down the resulting source code to something manageable.

But I found that many of Microchip’s source files are > 99% comments, making it essentially impossible to read the code and see what it actually does. Often there will be 1 or 2 lines of code here and there separated by hundreds of lines of comments.

So I wrote the below Python script. Given a folder, it will walk thru every file and replace all the .c, .cpp, .h, and .hpp files with identical ones but with all comments removed.

I’ve only tested it on Windows, but I don’t see any reason why it shouldn’t work on Linux and Mac.

from __future__ import print_function
import sys, re, os

# for Python 2.7
# Use and modification permitted without limit; credit to NerdFever.com requested.

# thanks to zvoase at http://stackoverflow.com/questions/241327/python-snippet-to-remove-c-and-c-comments
# and Lawrence Johnston at http://stackoverflow.com/questions/1140958/whats-a-quick-one-liner-to-remove-empty-lines-from-a-python-string
def comment_remover(text):
def replacer(match):
s = match.group(0)
if s.startswith('/'):
return " " # note: a space and not an empty string
else:
return s
pattern = re.compile(
r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"', re.DOTALL | re.MULTILINE ) r1 = re.sub(pattern, replacer, text) return os.linesep.join([s for s in r1.splitlines() if s.strip()]) def NoComment(infile, outfile): root, ext = os.path.splitext(infile) valid = [".c", ".cpp", ".h", ".hpp"] if ext.lower() in valid: inf = open(infile, "r") dirty = inf.read() clean = comment_remover(dirty) inf.close() outf = open(outfile, "wb") # 'b' avoids 0d 0d 0a line endings in Windows outf.write(clean) outf.close() print("Comments removed:", infile, ">>>", outfile) else: print("Did nothing: ", infile) if __name__ == "__main__": if len(sys.argv) < 2: print("") print("C/C++ comment stripper v1.00 (c) 2015 Nerdfever.com") print("Syntax: nocomments path") sys.exit() root = sys.argv[1] for root, folders, fns in os.walk(root): for fn in fns: filePath = os.path.join(root, fn) NoComment(filePath, filePath) To use it, put that in "nocomments.py", then do: python nocomments.py foldername Of course, make a backup of the original folder first. In March 2008 I posted the below to the nsg-d mailing list, from which it was forwarded to a few other lists and engendered some discussion. Seven years later, I think I have a solution to the problems I couldn’t solve then – it’s decentralized, voluntary, reasonably immune to spoofing and fraud, yet I think it’ll work. I’ll leave you in suspense for a week or two until I write it up. For now, here is my 2008 post, with only very minor corrections:  from: Dave to: Nanotechnology Study Group date: Fri, Mar 7, 2008 at 6:29 AM subject: Half-baked copyright reform ideas & nanotechnology Hi all, I’ve been sitting on the ideas below for a little while. I’ve decided to just post this half-baked, as it is. Maybe it’ll stimulate some better ideas from other people. (The problem of copyright is particularly relevant to nanotechnology, if you think molecular assemblers are eventually going to be practical. Once you have assemblers, physical goods have very little value, and intellectual property becomes a relatively much larger component of the economy.) Comments are welcome. ## Premises • Creators need to get rewarded for creating things of value to others, somehow. Incentive is important. • Copyright today is not working very well. Consumers do not like DRM and find ways to circumvent it. ## History Zero In the beginning, before the invention of the printing press, copyright was not an issue because there was no way to copy information in a way that was inexpensive enough to be economically viable. Such information as was copied was transferred mainly by word-of-mouth. Since anyone could do this at any time, there was no practical way to regulate or charge for the distribution of information, even if someone had thought of doing so. To the extent that payment was associated with information distribution, it was performance-based. Authors or readers might pay a scribe to make a copy, storytellers or entertainers might receive something in exchange for a performance, but there was no restriction on the retelling, copying, or further transfer of information other than that which could be achieved by simply keeping information secret. One After the invention of the printing press, copyright law was introduced (literally, the “right to copy”). It worked reasonably well because making copies was difficult. Making a copy of a book or a phonograph record required a lot of capital equipment and labor, and was economical only in large volumes. Therefore the number of people who could make copies (practically speaking) was limited, and therefore fairly easy to police. A certain amount of “fair use” was implied at this stage – people could loan and resell books and recordings without charge (in most countries), but the economics of reproduction technologies limited who could make copies. Two With the advent of Xerox machines, audio tape recorders, and VCRs, copying became easier and cheaper. In many cases an illicit copy could be made for less than the cost of purchasing a licensed copy from a copyright holder. This is when the copyright system began to break down. Copies would be made for friends and passed around by hand. Still, the amount of damage to the copyright system was limited, because of the limited distribution abilities of those doing the copying, and because the copying itself still required some amount of capital and labor. A typical copier might make one or a few copies for friends and acquaintances, but still could not practically engage in mass distribution. Three The Internet changed all this. With universal connectivity and broadband capacity, individuals could distribute copied works easily and almost cost-free. Low-cost computers removed labor from the process. The traditional merits of the copyright system started failing in a serious way. In some ways, the situation today is similar to that at “stage zero” before the invention of the printing press – anyone can copy and transfer to anyone else costlessly (as was true of word-of-mouth), and there is no practical way to regulate or control this. The difference is that today large industries have formed to produce creative content, and society has benefited tremendously from this. These creators need to be paid (or otherwise rewarded), somehow. Yet the copyright system as we have known it seems increasingly unable to do the job. ## Economics The fundamental problem of the copyright system is the implication that a consumer must pay some fixed amount for a copy of a work, but the cost of reproducing the work is essentially zero. (I refer to the marginal cost to produce an additional copy; not the cost of creating the work in the first place.) When a consumer places a positive value on having a copy, but that value is less than the price of the work, the consumer doesn’t buy it. This represents a dead loss to society (to the consumer). The amount of loss is the value of the work to the consumer, less the (nearly zero) reproduction cost of the work. [1] Of course the same was true in the age of the printing press – if the value of a book to a reader was greater than the cost of printing, but less than the sales price, the reader didn’t buy and there was a loss to society of the difference between the value to the reader and the printing cost. But this loss was far less than the loss today on the Internet, because the cost of printing was a significant fraction of the price of the book – so relatively few readers found themselves valuing the book in the narrow range between printing cost and sales price. On the Internet, the reproduction cost is approximately zero, so if a consumer places any non-zero value on a work there is a loss to society, unless that value is greater than the sales price. If we could come up with a replacement for or reform of the copyright system that eliminated this loss, while still incenting creators to create, that would be an immense win for society. ## Summary of the problem In practical terms, copyright has become unenforceable. (DRM schemes don’t work – that is a topic for another essay.) In economic terms, copyright is undesirable. Yet there is a strong social benefit to be captured if, despite these facts, creators can somehow be paid (or otherwise rewarded) for creating useful or desirable works. ## Requirements Requirements for a new system to replace copyright: • Producers of valuable content must get paid, somehow • Consumers must be able to obtain and use copies of content at a marginal price to them that is at or near the marginal cost of reproduction. For almost all practical purposes, this means content needs to be free at the margin. (However this does not mean the non-marginal price needs to be zero.) • Producers of useless content must not get paid • Otherwise they will be taking resources they have not earned, or which should have gone to producers of valuable content • In order to preserve intellectual and cultural freedom, the determination of “value” must not be centralized, but must be a function of the opinions (expressed or implicit) of individual consumers. • The copyright system did an admirable job of this by using market mechanisms – valuable content sold for high prices and/or in large volumes. Less valuable content did not. Assumptions: • As now, creators of joint works (works with multiple authors) agree among themselves the relative value of their contributions and the distribution of rewards for the joint work. • Any new system would apply only to public (not private or secret) information. These ideas do not address trade secret or patent law, only works which are offered to the public and currently controlled by copyright. How could we go about achieving these goals? [2015: The remainder is a list of half-baked ideas that I no longer support. I’m leaving it in only for completeness.] ## Half-baked idea #1 Taxes are collected in the amount that now goes to all copyright creating industries (publishing, film, music, software, etc.). These taxes are levied without regard to consumption of content. All content is placed online on special “distribution servers” and is freely downloadable. Read the rest of this entry » For almost 30 years, roboticist Hans Moravec has been maintaining a great database of historical computer benchmarks going all the way back to 1891 (even before Hollerith tabulators). This can be used to make nice plots showing Moore’s Law like this one (source XLS here): But – here is something way more interesting. The graph below plots, for each historical machine, the ratio of RAM (megabytes) to MIPS. So a machine with the same bytes of RAM as instructions/second rates as 1. One with 10x more bytes of RAM than instructions it can execute in a second rates as 10, etc. I think of this ratio as “seconds” – if each instruction can access one byte, then the ratio gives the number of seconds needed to access all the RAM. (Of course this is a rough measure, as architectures differ, but good enough to give interesting results). Here’s what I get: Look at that! These are real historical machines with the given installed RAM (not how much RAM the machine could address, but the amount the machines actually had installed). I’m just plotting the ratio of installed RAM to execution speed – it has nothing to do with price (except insofar as price may have affected buying decisions). The ratio of RAM to machine speed has been steadily dropping. Why? I remember a rule of thumb, probably from the 1980s, that a practical computer typically has about 1 second of of RAM – that is, a typical machine is fast enough to access all its memory in about 1 second. This made sense at the time based on the idea that, in a command-line driven system, one second was about as long as users were willing to wait for a response. Longer was too slow, and shorter didn’t gain much. But this graph is illuminating. The only explanation I can think of is that with the gradual transition from batch computing (many minutes is an acceptable run time), to interactive command lines (seconds) to GUIs (tens or hundreds of milliseconds), the ratio of RAM to MIPS has been steadily dropping. But if that’s correct, I’d expect more in the way of a step function. I suspect it’s something else, and that it’ll keep going. Something more interesting. But what? About three years ago I spent a lot of time thinking about this. Recently Elon Musk has spoken about flying cars. So now seems a good time to publish this. It’s long, and it’s half-baked. I decided I had too much else on my plate, so I dropped it. Anyone who wants to pick this up and run with it – go for it! TLDR: Flying cars must be safe and cheapThe way to do that is automation and redundancy. Redundant systems make things cheap because (a) they don’t have to be highly reliable (as do conventional aviation components), and (b) more units means mass-production prices. Redundant brushless electric motors driving simple fixed-pitch props are the solution. Here’s how. (PDF version is here; 37 pages. PDF doesn’t have the crappy CSS formatting…) # 1 The vision “Liftoff” You step into your vehicle and settle into your seat as you say “liftoff”. Your voice is recognized as that of an authorized user – the vehicle actually belongs to your wife. There’s a quiet click as the charging plug automatically retracts into its compartment, then 100 thrusters – near-silent electric motors, each with a small fixed-pitch propeller – spin up all around the vehicle. Over a few seconds, they gradually take up the weight of the vehicle with you in it. As they do, the vehicle determines the total takeoff weight by measuring how much power it needs to send to the motors to lift you off the ground. It checks that all the motors are supplying the expected amount of thrust and are running smoothly and in balance. Oh no – it discovers that 2 of the 100 thrusters are producing less thrust than they should, one is producing no thrust at all, and a fourth is wobbling, probably due to a chipped prop or loose mounting bolts. It shuts down all four, noting the problems with each one in its maintenance log. (You meant to replace a couple of those, but things have been busy.) 96 out of 100 motors in good condition is still within the “green” zone for safe flight[1] and the batteries have enough charge, so the vehicle rises vertically toward it’s default hover height, 50 meters above the ground. It automatically maintains its balance, rising level and straight, directing a little extra power to the motors near the 4 failed units. You stretch out, putting your feet up and opening your magazine. The vehicle senses the beginnings of the tilt as you lean backwards (moving the center of gravity), and shifts some of the thrust that way to compensate. 20 meters up, you rise above the treetops and the gusty wind pushes on the vehicle, but you barely notice because the vehicle’s gyro sensors and accelerometers, together with the GPS receiver, sense the movement caused by the wind. Power is shifted to the opposite side as needed to keep you rising straight above your parking spot. To the garden You’re looking forward to your lunch at the rooftop restaurant (convenient free parking!). Normally, you’d just tell the vehicle “take me to Fred’s” and let it do the flying for you[2], but it’s a beautiful sunny day and you feel like a quick look at the progress with the cactus-planting at the little garden you designed for the parks department to replace the old freeway interchange, so you lean forward and grab the control knob. It’s a stubby rubber knob an inch high, that hardly moves at all. You give it a gentle twist to the left against its internal spring, and the vehicle yaws the same way, slightly increasing the speed of the clockwise-turning props and decreasing the speed of the counter-clockwise props, to torque the vehicle around. As those ugly apartment buildings across the river come into view, you let go of the knob. It returns to its neutral position and the vehicle stops turning. Then you press the knob forward and the vehicle tilts the same way, shifting a little power to the back and moving forward[3]. The vehicle holds it’s altitude and attitude as it moves toward the gap between the buildings. Your phone rings. You click the “hold” button on the knob and let go of the knob, reaching for the phone in your pocket. The vehicle keeps going exactly on the course and speed you had it. It’s your business partner, who is going to meet you for lunch. She’s wrapping up the design for the playground, due to the client this afternoon. Should the water slide empty into the duck pond or the mud bath? The client left it up to you. You find the alternative versions of the plans and stare at each, trying to decide – she can’t leave for lunch until this is done. While your head is buried in the plans, the vehicle has been flying toward the apartment buildings. You didn’t really aim it very well – you meant to go through the gap, but it’s a small gap and a ways off. On the course you set, the vehicle would collide with the larger building in a few seconds. Read the rest of this entry » I’ve been reading Edward Teller’s autobiography. In a footnote (p. 247), Teller mentions that “the electron in a hydrogen atom will eventually jump to a proton if it is close enough”. Teller and Francis Owen Rice calculated how long it would take, if the proton is 1 centimeter away. Their answer was 10100,000,000. A long time. A “big number”. That’s the same as 10108, which is more than a googol (10100), but much less than a googolplex (1010100). What’s that? You want to know what units? You mean is the 10100,000,000 in Planck times (5.4 x 10-44 seconds), or seconds, or years, or time periods since the Big Bang? Doesn’t matter. (Think about it.) That’s how big a number it is. Have you ever had a huge complicated folder tree with thousands of files buried layers deep in folders-within-folders? And wanted to flatten them out so all the files are in a single folder, but without filename collisions (that is, lots of files with the same name)? I did. The closest thing I could find off-the-shelf was this, so I wrote the Python script below. I hope it’s helpful to someone. To run it (assuming you have Python installed – you’ll need Python 3 in case some of your pathnames have Unicode characters), do this: python flatten.py [root folder to be flattened] DOIT If you leave off “DOIT” (all caps), then it will simulate what it’s going to do, without actually doing anything. The way it works is by copying all the files to the root folder, renaming them with the original path to the file, but substituting “¦” for the “/” or “\” (Windows, Unix respectively). So if you have (using the example from the link above) this inside “Folder0″: Folder0 Folder1 File1.1.txt File1.2.txt FolderA FileA.txt FolderB FileB.1.txt FileB.2.txt Folder2 FolderC FileC.txt Then doing: python flatten.py c:\path\to\Folder0 DOIT Gets you these six files inside Folder0: Folder1¦File1.1.txt Folder1¦File1.2.txt Folder1¦FolderA¦FileA.txt Folder1¦FolderB¦FileB.1.txt Folder1¦FolderB¦FileB.2.txt Folder2¦FolderC¦FileC.txt Enjoy, and if you make improvements, please post a comment here. # -*- coding: utf-8 -*- # for Python3 (needs Unicode) import os, shutil, sys def splitPath(p): """Returns a list of folder names in path to p From user1556435 at http://stackoverflow.com/questions/3167154/how-to-split-a-dos-path-into-its-components-in-python""" a,b = os.path.split(p) return (splitPath(a) if len(a) and len(b) else []) + [b] def safeprint(s): """This is needed to prevent the Windows console (command line) from choking on Unicode characters in paths. From Giampaolo Rodolà at http://stackoverflow.com/questions/5419/python-unicode-and-the-windows-console""" try: print(s) except UnicodeEncodeError: if sys.version_info >= (3,): print(s.encode('utf8').decode(sys.stdout.encoding)) else: print(s.encode('utf8')) def flatten(root, doit): """Flattens a directory by moving all nested files up to the root and renaming uniquely based on the original path. Converts all occurances of "SEP" to "REPL" in names (this allows un-flatting later, but at the cost of the replacement). If doit is True, does action; otherwise just simulates. """ SEP = "¦" REPL = "?" folderCount = 0 fileCount = 0 if not doit: print("Simulating:") for path, dirs, files in os.walk(root, topdown=False): if path != root: for f in files: sp = splitPath(path) np = "" for element in sp[1:]: e2 = element.replace(SEP, REPL) np += e2 + SEP f2 = f.replace(SEP, REPL) newName = np + f2 safeprint("Moved: "+ newName ) if doit: shutil.move(os.path.join(path, f), os.path.join(root, newName)) fileCount += 1 safeprint("Removed: "+ path) if doit: os.rmdir(path) folderCount += 1 if doit: print("Done.") else: print("Simulation complete.") print("Moved files:", fileCount) print("Removed folders:", folderCount) """ if __name__ == "__main__": print("") print("Flatten v1.00 (c) 2014 Nerdfever.com") print("Use and modification permitted without limit; credit to NerdFever.com requested.") if len(sys.argv) < 2: print("Flattens all files in a path recursively, moving them all to the") print("root folder, renaming based on the path to the original folder.") print("Removes all now-empty subfolders of the given path.") print("") print("Syntax: flatten [path] [DOIT]") print("") print("The DOIT parameter makes flatten do the action; without it the action is only simualted.") print("Examples:") print(" flatten //machine/path/foo Simulates flattening all contents of the given path") print(" flatten //machine/path/bar DOIT Actually flattens given path") else: if len(sys.argv) == 3 and sys.argv[2] == "DOIT": flatten(sys.argv[1], True) else: flatten(sys.argv[1], False) What a way to ruin a great brand. For no apparent reason at all. They could have called it “Pewlett Hackard”. Heck, they could have called it “Tektronix”. (Those guys in Beaverton seem to have no use for that name anymore.) The monkeys are running the henhouse. (Or, um, something like that.) Oh, and…get off my lawn! I’ve had this thing in my drawer for 2 years; just got to use it for the first time yesterday. It’s fantastic – really worth$150.

Saleae Logic Analyzer

Now they have new versions that do analog, too (low-bandwidth, tho).

The nice thing about the Saleae thing is the software – it’s really amazingly simple and effective (you can download a demo from their website without the hardware).

I’ve used other logic analyzers – this is miles ahead. (Also way, way, better than the protocol decode on my new Rigol DS2072A DSO.)

https://www.saleae.com/logic

[No, they didn’t pay me anything to write this.]