Pages

20190131

How to Find Out Anything by Don MacLeod


  • Research is the process of finding out for yourself what somebody else already know.
  • Getting past a dependence on Google and other search engines is the focus of this book. As all good librarians know, there’s a lot more useful information in the world than what search engines can deliver.
  • Knowing how to work through a research problem will allow you to reliably find whatever it is that you need to know, be it frivolous or profound.
  • The first thing a researcher needs to learn is the art of crafting a question. This is where all good librarians begin their searches, and you should too.
  • If you don’t know what you are looking for, how will you know when you’ve found it?
  • Questions come in two varieties: open-ended and factual. The difference between the two is remarkable.
  • Open-ended questions ask for opinions and offer no definitive answer. Such questions, although frequently very interesting, do not readily allow for a solution.
  • To become a skilled researcher, step number one is learning how to craft the answerable question.
  • As long as the questions you ask yourself begin with the words what, when, where, or who--the classic four Ws of journalism school, with the occasional addition of how--then you are well on the way to constructing questions that, when answered, might also illuminate the larger, open-ended question.
  • Understanding precisely what you need to know is the difference between successful reasearach and a never-ending slog through the back alleys of the Internet or the dusty shelves of libraries.
  • Knowing just how much information you need is another critical aspect of successful research.
  • Never compile information yourself if someone else has already done it.
  • Don’t take anything you read online at face value.
  • Reliable information is as free from bias as possible.
  • When you’re evaluating a resource, take into account the source’s inevitable bias, even when it’s presenting seemingly factual information.
  • Accurate information withstands scrutiny. The standard for scientific research is that experiment results need to be replicable. The laws of nature don’t change. What happens in one lab ought to also occur in another, so long as the experimental conditions are the same.
  • Likewise, facts are the same the world over. They don’t require belief to be true.
  • The root of the word detective is “detect”, which means to “discover or determine the existence of”. That’s a fair way to think about research, too.
  • One of the best secrets of good research is the ability to use on bit of information to find even more information.
  • Footnotes, callouts, and references to other works are the hidden gems that researches should read as closely as the primary text. Don’t ignore them.
  • People love to talk; you’ll find that asking for advice can produce tips for finding more information quickly.
  • Get into the habit of keeping copious notes.
  • Skepticism (not cynicism) is the ally of the researcher. You should always weight the credibility of any source in light of what you already know and never take a fact, opinion, or conclusion at face value until you can verify it.
  • Healthy skepticism requires proof; misinformation is more common than the true.
  • Double-sourcing is always a good idea. This is the simple process of seeing if reputable sources agree on the facts.
  • The smart researcher doubts everything and assumes nothing. The only worthwhile exception to this rule is to assume that an answer to your question exists and that if you follow the correct steps for research, you will find it.
  • Tenacity is as much a tool of successful research as curiosity and intelligence. Sticking to the task is important. There are times when locating a needed piece of information is, frankly, tough and tedious and the information you are looking for is as elusive as a hat blowing down the sidewalk in a windstorm.
  • Continuing in the face of frustration is as important a research skill as correctly framing your initial question.
  • Tenacity is as much a tool of successful research as curiosity and intelligence.
  • Google is a paradox. Without it, the Internet is nothing more than an incomprehensible jumble of websites, but, believe it or not, Google actually misses more information than it finds.
  • Online information should go through the same critical vetting process material does in print.
  • The term deep web refers to the universe of web-accessible information locked away in databases where Google’s spidering computers can’t see it. That limitation is a very serious knock against Google and the most important reason for never depending on it exclusively for online information.
  • These days, the bulk of the interesting data is in the database, not on a web page where Google’s computers can find it.
  • For academic research, in-depth business searches, tracking down people, or locating historic or hard-to-find data, Google searching doesn’t cut it.
  • Searchable databases and their contents are the bread and butter of good research.
  • Although the numbers from the experts are always inexact, the deep web is estimated to contain at least four or five times the amount of information that sites publish directly to the web and that is available to Google and other search engine.
  • IncyWincy focuses its search power on locating websites that are equipped with queryable database.
  • DeepPeep is figuring out how to use a single search page to search multiple databases.
  • If you’re interested in learning more about the deep web, try Bright Planet, a company that has pioneered identification of the features of the deep web and is devising a means to exploit it.
  • ALthough Google cannot search the deep web, its “Advanced Search” can be an important tool for finding the databases that will lead you there, as you’ll see in the next chapter.
  • The tools of Google’s “Advanced Search” deliver the holy grail of search results--namely, a small number of highly relevant hits. Since the average Google search routinely returns an absurd number of hits, getting your list whittled down to a manageable scale is a necessity for the busy researcher.
  • “Advanced Search” is how we force Google to be more precise.
  • Smart researchers benefit from more control of Google queries when using the quotation marks.
  • Quotes around a search phrase tell Google to search for the phrase as a single concept and not as multiple isolated words.
  • When your search term has more than one meaning, use the minus sign to knock out meanings you don’t want from the results list: That little minus sign (hyphen) slays a horde of a billion or more false hits.
  • An asterisk acts as a wild card, inviting Google to fill in the blank.
  • Using brackets tells Google to treat what’s inside literally and to search for it in results.
  • Of all the tools Google provides to help you search the web, none is as powerful or as useful as the site/domain search.
  • Because most sites have flabby, low-power, built-in search boxes and elaborate menu systems that suck up time as you try to find something, having a way to use Google to reach inside a website and pull back exactly what you need is ideal.
  • Of all of Google’s powers, nothing will make your online search better faster than using domain and site restrictions.
  • The date filter is a godsend for the researcher who needs to look for time-sensitive information.
  • Google normally searches everywhere on a web page, but you can direct the search engine to focus on the title of a page, the URL, or the text a page when needed.
  • To look for prices within a range of values, use the numeric range control. You can type out a range in the main Google search box using two periods to separate the values.
  • The Wayback Machine, a service of the Internet Archive, stores entire websites dating back to 1996 by periodically copying the sites whole. It is a great archival service that provides an easy way to see the web preserved in electronic amber.
  • Google Alerts will email you when new results arrive on a web page or when a news story matching your query is posted to a recognized news site.
  • A mash-up of public information on public companies, Google Finance, an aggregation of corporate and financial information, pulls together real-time (or close to real-time) stock quotes, EDGAR filings, business news, blogs, chats, and analytical information all on a single page.
  • For one-stop shopping for up-to-the-minute information on companies around the world, Google Finance is a tough act to beat.
  • For information, for research, for learning, or for entertainment, there is no other institution quite as willing to share the wealth as a library.
  • Even with the internet, a library and its resources still play a critical role in most research projects.
  • Most libraries make available a wide range of services designed to boost your research.
  • Part of any researchers due diligence is seeing what has been written in the press.
  • In addition to providing access to current information, a library also serves as an archive.
  • There’s nothing that a self-respecting librarian likes better than a challenging question. To them, research is not a task, it’s a calling, and the satisfaction of locating an answer to a difficult question is the most rewarding part of the profession.
  • Reference librarians are every researcher’s secret weapon.
  • The best advice I can give you is to take a cue from sensible librarians everywhere and fashion a reference collection of your own.
  • To generate a demographic profile of towns, cities, and counties around the nation, use the U.S. Census Bureau’s American FactFinder.
  • Frequently, an encyclopedia can jump-start your research by providing a nutshell view of the topic in question.
  • A good library catalog is a near-perfect tool for finding experts.
  • Living authors are more helpful than dead ones, fi only because they have email.
  • DMOZ is a crowd-sourced collection of links organized into a logical taxonomy.
  • Reference resources solve one of the basic problems of research, which is knowing where to begin to look.
  • In short, if you need information on a subject, you can bet that there is an association just itching to lead you down the path to enlightenment.
  • An association is a repository of knowledge for a specific subject and can be counted on to deliver a credible point of view.
  • Associations are A-list go-to sources because they love to answer questions. If you show even the slightest bit of interest in an association's subject matter a reputable association will make sure you get to know everything you want.
  • Find the right association, and in one place you’ll have experts to quote, guides to additional information, and an attributable source.
  • Associations can provide everything from factual data to opinions. When you need to pick someone else’s brain for a change, turn to an association for the information.
  • For every political idea, social policy, or disease, an association stands by to explain and defend the cause to the public.
  • Advocacy groups bend over backward to publicize their causes and are delighted to share information with anyone who needs it. They do the no-glamour digging for facts, which they give away in hopes of earning attention for their cause.
  • Define your problem and think of who would have an interest in providing an answer. A relevant association can usually deliver an authoritative answer very quickly.
  • Associations are often made up of professionals who produce reports backed by academic credentials and experience in the field. But regardless of the author, associations stand behind their publications, giving you the benefit of an attributable source.
  • Mining the incidental data within white papers is the way professional researchers reduce the number of hours of online search and hit-or-miss emails to possible sources.
  • Associations are extraordinarily generous with their information.
  • Remember rule number one of research: You need to ask a question that can be answered.
  • When we talk about finding people, we’re talking about finding a person’s indicators.
  • The gold standard for personal identification, after a birth certificate, is a driver’s license or an equivalent state ID card.
  • Take the utmost care to get the correct individual and not someone with the same or very similar name of the person you are looking for.
  • The phone book query is the most basic person search of all.
  • So what about cell phones? How do you locate someone’s cell phone number? The short answer is that you can’t do it reliably. Unlike landlines, cellphones clearly do not need to be assigned to a specific location. Also, privacy laws that never applied to landlines protect cell phone numbers.
  • Reverse phone lookups correlate a phone with an address. With a phone number in hand, a reverse lookup reports on the name of the number's owner and usually an address as well. If you really want to play detective, you can use these address and phone number searches in conjunction with a map service like Google Maps to search for neighbors of the person in question.
  • Spokeo is a deep web service that trains its algorithms at public sources, which Spokeo describes as “including but not limited to: phone directories, social networks, marketing surveys, mailing lists, government census, real estate listings, and business websites.”
  • The explosion of social networking has made it much easier to chip away at those famed six degrees that theoretically separate everyone in the world.
  • For many businesses and certainly for many legal actions, an asset search is an important component of people searing. It is not enough to know where a person lives or what her phone number is. It is frequently important to know what assets an individual controls.
  • Hunting for assets is a hunt for the records that document ownership of certain tangible objects.
  • It always helps to look into the compensation of a corporation's officers--the salaries and other compensation paid to the five most highly compensated individuals is listed in the 10K or proxy statement.
  • Any individual or group who owns 5% or more of the outstanding stock of a company must tell the SEC, and hence the public, about it by filing a Form 13-D. It’s a good way to see how individual investors are loading up on a stock.
  • The easiest people in the world to locate are licensed professionals. Precisely because doctors and lawyers and others in the learned professions need to demonstrate to the wider world their qualifications to practice, licenses are required.
  • State law varies on exactly which jobs require a bureaucratic stamp of approval, but the way to find out is always the same.
  • Pilots also require licensure. Information about them, a group the Federal Aviation Administration quaintly calls “airmen”, is available from the Airmen Inquiry database.
  • Licenses are required not only to work in certain occupation but for certain privileges, such as flying a private airplane, owning a horse or a dog, or operating a store that sells alcoholic beverages. Any diligent searcher should go through some of these license databases to obtain addresses and proper names for elusive individuals.
  • Part of finding people is finding people with expertise so that they can share with you what they know.
  • Experts abound in all fields, and what qualifies a person to be one varies with the discipline.
  • Experts come in unlikely packages. A teenager who spends eight hours a day with thumbs securely glued to a cell phone may not be able to name the chemical weight of iridium, but you can count on her, in my humble opinion, to be expertly fluent in the telegraphic language of texting.
  • The world opens up when we understand how much learning is walking around in people’s heads, many of whom don’t hold PhDs.
  • The ability to tap into the expertise of other people is a very powerful tool.
  • Find the expert, find the answer.
  • One positive thing to say about criminals--once they’ve been sentenced to prison, they’re easy to find. State jailers and the Federal Bureau of Prisons new offer searchable inmate locators.
  • It’s not impossible to track down the famous; you’ll need to work through intermediaries--namely, their agents or publicity people.
  • To a great extent, the field of tracking down the details of peoples past is dominated by genealogists, amateur and professional.
  • The library is still a viable option for people searching.
  • The first step in all company research is to determine the type of company you are looking at.
  • Because the sources and techniques of corporate research depend very much on which type of company you’re researching, be clear about what you need to find out from the beginning. Remember, the first rule of research is to know what it is you’re looking for.
  • Familiarizing yourself with EDGAR and learning how to comb through its documents are critically important.
  • If you had to pick one single EDGAR document to provide the best portrait of a company, you’d choose Form 10-K.
  • Exhibits are like a corporation’s legal filing cabinet of important documents.
  • Before a company can start selling stocks or bonds, it first has to register with the SEC. The registration statement is an exhaustive collection of information, with an emphasis on the company’s history.
  • Rifling through EDGAR documents is the best way to see the nastiest and dirtiest details of a company’s operations.
  • Google Finance offers at-a-glance information about public companies from around the globe.
  • The laborious part of private company research is cobbling together information from a variety of sources to get a clear portrait of the company.
  • Every state secretary of state maintains a searchable database of companies that have registered to do business within the state.
  • In short, Form 990 is the window into the operation of tax-exempt organizations.
  • Skill at looking up company info should be a basic tool in your reference repertoire.
  • Before setting out on any industry research, though, make sure you have a good grasp of the industrial classification codes. These codes are used to precisely describe a specific industry and to sort online databases by industry.
  • The two classifications systems that are most widely used are the Standard Industrial Classification Code (SIC) and the North American Industry Classification System (NAICS).
  • It’s well worth the time to look over the SIC system simply because it is a basic tool for filtering online information systems with precision and accuracy.
  • Every industry has one or two periodicals covering the news.
  • There is a treasure trove of factual information hiding in plain sight in documents and databases maintained by public agencies.
  • Public records are essentially the facts that various branches of government compile as they go about enforcing, interpreting, or creating the law. They’re the documents and data we create by virtue of living in a society that needs to know something about us to function smoothly.
  • As the name quite clearly says, public records are accessible to anyone who wants to see them.
  • Public records can be categorized into three neat pigeonholes: records that anyone can look at by walking in off the street (or searching online), records that are available for inspection by anyone who can prove a legal need to see them, and records that a public agency doesn’t routinely make public but that must be disclosed when asked.
  • Documents or databases that are open to public inspection are the most public of public records.
  • Certain records are maintained by public agencies but access to them is restricted to individuals or companies that can prove they have legal interest in them. Likewise, access to vital records--birth certificates, death certificates, marriage licenses--is entirely restricted to those who have a legal right to them.
  • Government agencies create documents or keep records of their work that are not routinely made available for public inspection. These materials can be provided to the public, but they are produced only when someone asks for them. In the event that an agency refuses to hand over the records, a citizen may file a Freedom of Information Act (FOIA) letter to formally request that the agency produce the information.
  • Public records research can provide insight about people and companies that can’t be dredged up with a Google search.
  • Avail yourself of the now-computerized records from filing clerks around the nation.
  • The records held by the executive agencies under the president are where the vast majority of interesting stuff will be found.
  • All the rules that federal agencies write are compiled into the multivolume rule book, the Code of Federal Regulations (CFR).
  • Answers to many a research question can be found from the right federal agency.
  • The docket is the comprehensive list of documents filed with the court during a trial. When a case commences in court, it is assigned a docket number, and from then on, all papers, motions, and other documents submitted to court in the case are filed on the docket under that number.
  • The docket number is the unique identifier for each case and thus is critical to federal case research.
  • In many ways the records that the secretary of state collects and manages are some of the most useful of all to the business researcher.
  • State courts are where the grittiest legal action takes place. While federal courts listen to disputes about bankruptcy, securities fraud, and tax matters, state courts hear cases about homicides, narcotics, arson, and other criminal matters.
  • To obtain any court records, you’ll need to know at least the name of the party or parties in the case and preferable the docket number of the action.
  • County clerk’s offices are rich hunting grounds for factual information, particularly liens and real estate records.
  • In short, use the county clerk's office as your personal information bank for locating assets, values of buildings and homes, and as a guide to who owns it all.
  • Data.gov collects info from around the federal government and applies some interesting algorithmic magic to it.
  • The much lauded Wolfram|Alpha is another computational search engine that digests sets of public data and produces interesting results by finding new patterns and insights from the materials it analyzes.
  • The almost natural reaction of most public officials is to be secretive. Prying loose what is, after all, information that belongs to the citizenry is good policy. When you come across a federal agency that obstinately refuses to turn over reports or data or other materials that are not otherwise specifically protected, the Freedom of Information Act puts a powerful tool in your hands to compel the officials to comply.
  • Know the correct procedure for requesting the records you want to see because agencies are well within their rights to refuse requests that don’t follow the game plan.
  • Public records research is like a treasure hunt. By going from one agency to another with your list of needed information in hand, you will secure item after item until you’ve collected all the facts you need.
  • Tapping into the vast repositories of the public record is one of the basic skills that all researchers should master. It is hard to overstate the value of being able to get at the billions of bits of data held by public agencies at every level of government.
  • The Bureau of Justice Statistics has an extensive collection of searchable databases that illustrates the state of the criminal union.
  • Few things are truly hidden anymore.
  • The days of obscurity are over. Thanks to Google, the databases of the deep web, online research materials, electronic books, and the knowledge stored in the minds of smart people with whom we can talk, even the most arcane fact is waiting in the open for us.
  • The process of finding things out means making connections.
  • Research tools are merely ways for you to find out what someone else already knows.
  • Ultimately the secret to knowing how to find out anything means learning how to connect with people.

20190129

Make: AVR Programming by Elliot Williams


  • Microcontrollers are often defined as being complete computers on a singly chip, and this is certainly true.
  • Any way you slice it, digital output is the heart and soul of microcontroller programming. It’s how you “speak” to the outside world.
  • One of my favorite uses of microcontrollers is as the connector between a real computer and interesting hardware.
  • The AVR has three serial communications peripherals built in. Plain-vanilla USART serial is useful for communicating with your desktop computer, radio modems, and GPS units. SPI is good for ultra-fast communication over very short distances with peripherals like memories, ADCs, and DACs. I2C is like a small network, allowing you to connect up to 127 different sensors to the same couple of wires. Devices that move around a moderate amount of data tend to use I2C. That’s a good choice for the network of accelerometers.
  • An interrupt service routine is a software function that you can write that automatically executes whenever an interrupt condition is met. They’re called interrupt routines because the processor stops whatever it was doing in the main flow of your program and runs the appropriate function. After it’s done with the interrupt routine, the processor picks up your program’s normal operation where it left off.
  • Flash programmers are just USB devices that send bytes of your code across to the AVR chip.
  • The flash programmer is a piece of hardware that sites in between your computer and the target AVR microcontroller. The AVR microcontrollers, when put into programming mode, listen over their serial peripheral interface (SPI) bus for incoming data to flash into program memory. The flash programmer’s job is to relay the compiled machine code to the target AVR over the SPI bus.
  • A lot of you will have an Arduino sitting around. If so, it turns out to be fantastically easy to turn that Arduino (temporarily) into an AVR programmer.
  • Far and away the most popular software uploader is AVRDUDE, which is available for all platforms and supports a wide variety of programmers.
  • A flash programmer works by grounding the RESET line, which halts the CPU and signals the AVR to start listening on the SPI bus. The programmer then transmits programming instructions over the SPI bus. After each instruction or section of code, the AVR writes the received data to flash memory.
  • One very real advantage of the Arduino hardware setup is that the chip comes pre flashed with a bootloader, which is code that enables the chip to communicate with your computer over the serial line in order to flash the program itself. This means that you can do away with the requirement for an external bit of hardware to flash the chip--there’s a tiny bit of bootloader code already running in your Arduino that’ll flash the chip for you!
  • The second highlight of the Arduino package is that it comes with a built-in USB-to-serial converter, so you don’t have to buy a separate one just yet.
  • Atmel’s current official USB in-system programmer, the AVRISP mkII is a very nice programmer that’s capable of programming the whole AVR line, including the newest XMega devices. It’s a bit more expensive than other programmers, but it’s rock solid and is quite a bargain all in all.
  • Digital output is both the simplest and most common way that your microcontroller programs are going to control other devices in the outside world.
  • The preamble is where you include information from other files, define global variables, and define functions.
  • After the preamble comes the main() function. The name “main” is special--regardless of how many other functions are defined, your C program must have exactly one main() function. Main is where the AVR stats executing your code when the power first goes on. It’s the entry point.
  • Inside the main function you’ll find a while(1) loop, often referred to as the “main loop” or “event loop”. while() loops are loops that continue running over and over as long as the condition inside the parentheses is true. And in C, 0 always resolves as false, and 1 always resolves as true. So everything that’s within this loop will run over and over again.
  • Return codes are totally superfluous for AVR code, which runs freestanding without any supporting operating system; nevertheless, the compiler raises a warning if you don’t end main with return().
  • The way we’re going to configure the pin as either input or output is deceptively simple in code--assigning a variable a certain value--but what goes on inside the dark wiring heart of the chip is interesting.
  • When you want to configure a microcontroller pin, it looks the same in code as saving a value into a variable. And that’s because the same thing is going on inside the chip. The chip’s hardware registers are just like the RAM storage slots that you use for variables, only they each have side effects.
  • Because hardware registers are special memory location, the compiler can’t treat them exactly the same as variables. When you create a normal variable, the compiler can pick and convenient place in memory for it. Because hardware registers are physically connected to the input/output circuitry, the location can’t change.
  • Hardware registers can be accessed just like “normal” variables from your code, but inside the chip they have extra connections that let them influence the way the rest of the chip behaves.
  • Each bank of pins (B, C, and D on the Mega series AVRs) has three hardware register memory locations associated with it. Let ‘x’ stand for each bank’s letter: so DDRx will be the DDRB, DDRC, or DDRD depending on which bank of pins you mean.
  • DDRx data-direction registers. These registers control whether each pin is configured for input or output--the data direction.
  • When the DDRx bits are set to one (output) for a given pin, the PORT register controls whether that pin is set to logic high or logic low.
  • The PIN register addresses are where you read the digital voltage values for each pin that’s configured as input. Each PINx memory location is hooked up to a comparator circuit that detects whether the external voltage on that pin is high or low.
  • A common beginner mistake is trying to write to the PORT register and expecting a voltage out when the DDR hasn’t been set to output yet.
  • Bit shifts have the effect of rolling all the bits’ ‘n’ positions to the left or right, depending on your command. Bits that fall off either end just disappear, and any new bits added are all zeros.
  • Zero-indexing is natural if you think of everything in terms of a base location and an offset, which is why it’s done in C.
  • We use a bitmask, along with a bitwise logical operator, to change some bits in a target.
  • If you XOR any bit with a fixed 0, you get a 1 if that bit is a 1 and a 0 if that bit is 0. Remember, this is the “exclusive” or and is only true if one or the other is true, but not both. So XORing with a 1 seems a good way to toggle bits!
  • If we AND any bit with 0, the result is guaranteed to be 0. There’s no way they can both be 1 if one of them was a 0 to start with.
  • Set a bit: BYTE |= (1 << i);
  • Clear a bit: BYTE &= ~(1 << i);
  • Toggle a bit: BYTE ^= (1 << i);
  • Serial communication is the simplest possible way to interface your microcontroller with your desktop or laptop computer, your first step toward bridging the world of the physical and the virtual.
  • Almost all modern serial protocols are specified this way: pins with the same names are connected together.
  • When using (old-school) USART serial, you connect RX to TX, and vice versa.
  • The essential outline of the hardware configuration is that there are a handful of registers for each of the AVR’s built-in peripherals. Each bit in a register byte is a switch that enables or disables some functions of the peripheral. Setting up the hardware to do its job, then, is just a matter of figuring out which switches you need to set and bit twiddling them into the right states.
  • Microcontrollers are not meant to drive speakers. Speakers have a very low resistance to direct current (DC), around 8 ohms. The solution is to add a blocking capacitor to the circuit.
  • When a capacitor is subject to a DC voltage, it lets a little current through until it is “charged up” to that voltage, then it blocks further current. This means that capacitors pass current only for changes in voltage.
  • A wire that’s just dangling in the air, on the unconnected side of a switch, can act as an antenna. The voltage on that wire will wiggle around between high and low logic estates at whatever frequency the strongest local radio stations (or even “noisy” electrical appliances) broadcast. The only thing you do know about this voltage is that it’s unreliable.
  • This physical open-close-open-close nature [bounce] of switches makes the voltage on the circuit bounce between high and low logic voltages over a timescale from a few microseconds to a few milliseconds. The really annoying thing about button bounce is that most of the time it doesn’t happen.
  • The easiest solution is to have the AVR wait a few milliseconds and then check to see if the button is still dressed or not before making any decisions. Because the buttons bounce only for a “short” time, waiting for a little bit longer and then double-checking will ensure that we’re not mistaking bounce for a true change.
  • The trick with debouncing-by-waiting is getting the timing right.
  • Fundamentally, you need to debounce whenever you’re counting button press events. This goes equally for on/off toggling, scrolling through elements of a menu, or switching among modes.
  • Putting a capacitor across the two contacts of a switch forces the voltage to rise slowly, and can ensure that it will not jump up and down along the way.
  • In industry, almost everyone deb ounces in code, saving a few cents per capacitor.
  • A lot of the real world is analog: voltages, currents, light levels, forces, etc., all take on continuously variable values. Deep inside the AVR, on the other hand, everything is binary: on or off. Going from the analog world to the digital is the job of the analog-to-digital converter (ADC) hardware.
  • Mastery of microcontrollers starts with good use of the interrupt system.
  • The event loop in a polling-style program is essentially a list of things that we’d like to check up on. The AVR then runs through that list repeatedly as fast as it can. If we keep our event loop short enough that any given part comes around frequently enough, it’s hard to tell that we’re polling.
  • One problem with polling in event loops is that there's no concept of priority.
  • Handling multiple jobs at once is where interrupts excel. Interrupts do just what they sound like--they interrupt the normal flow of the program. When an interrupt is triggered, all of the variables that you’re using are stashed in memory and then a special function, called an interrupt service routine (ISRs), is run. After the ISR is done, your program picks up again where it left off.
  • There are internally triggered interrupts that respond to the internal AVR hardware peripherals.
  • There are also externally triggered interrupts that can react to a voltage change on any of the AVRs pins.
  • Without interrupts, you have to check each button in the system to see if it’s pressed, which waste shoe processor cycles and can result in serious delay if parts of the event loop take a long time. By using interrupts for each AVR pin, you can dispatch code that executes within a microsecond of the button press.
  • ISRs are special routines that run when their interrupt flag is set, and their interrupt vector is called.
  • sei() turns all interrupts on, and cli() turns them all off.
  • For some timing-sensitive sections of code, especially if you have long-running interrupt service routines, you may want to disable interrupts before you call critical functions and re enable interrupts after you return.
  • Also note that interrupts are automatically turned off when entering an ISR and turned back on again when finishing. This prevents a situation where an interrupt gets called from inside another interrupt, which itself had been called from inside another interrupt, and so on.
  • Always remember that enabling interrupts is a two-step process; enable your specific interrupt vector, then enable the overall interrupt system with sei().
  • Volatile warns the compiler that the declared variable can change at any time without warning, and that the compiler shouldn’t optimize it away no matter how static it seems.
  • Forgetting to make global shared variables as volatile is probably pitfall #1 in advanced AVR programming. If you're ISR seems not to be working, and you’re sure you’ve run sei(), double-check your volatiles.
  • Another place you’ll want to define a variable as volatile is when you’re using a loop to do nothing but delay. Because it’s doing nothing, the compiler will optimize it away.
  • If you share a global variable between a function and an ISR, you must declare that variable as volatile.
  • AM radio allows for a particularly simple receiver. When you tune the radio to the correct frequency, the antenna receives a time-varying voltage signal--the carrier modulated by the signal. To get rid of the carrier, you simply run the receive voltage through a diode, so that you get only the positive voltages. Now you’ve got a signal that varies from roughly zero to 1.6V, which you can output directly to a speaker with a capacitor.
  • Indeed, the simplest version of AM radio receivers are crystal radios, which really only have four parts: an inductor and tuning capacitor to select the right carrier frequency, a diode to separate the signal from the carrier, and a high-impedance earpiece that doesn’t require amplification (and has the blocking capacitor built in).
  • The worst thing you can do is change the SPI-programming bit, which disables your ability to further program the chip using your flash programmer.
  • PWM is such a common method of creating analog voltages from digital devices that almost all microcontrollers, including the AVR, have dedicated internal peripheral hardware that takes care of this high-speed bit toggling for you, and I recommend using this feature whenever you can.
  • When you’re playing with the LED demo, you may also notice that the human eye doesn’t respond to equal changes in brightness equally.
  • The human eye is much better at telling the difference between low levels of light than higher ones. That is, the human eye’s response to light is nonlinear. Many LEDs are driven in PWM mode to exploit this fact.
  • The reason that PWM-driven LEDs are so prevalent is that your eyes can’t really tell the difference between 90% and 100% duty cycles, so the city can run the traffic lights at 90% and pocket the 10% energy savings.
  • Servos are positioning motors with a built-in feedback circuit, and it’s this internal circuitry that makes them so simple to use. As positioning motors, they don’t spin around and around like traditional motors. Instead, they only rotate through 180 degrees or so, and they can move to the desired position to roughly the nearest degree on command.
  • You send position controls to a servo with a signal pulse that ranges nominally from 1 ms to 2 ms.
  • The reason behind the lousy accuracy is that the AVR’s internal CPU clock isn’t really meant for time-keeping. It’s meant to give you a quick-and-dirty clock pulse so that the chip can run without any external parts.
  • Measuring higher voltages is actually easy enough. We simply redivide the voltage down to our 5V range using a voltage divider.
  • To get extra resolution in the measurement, we’ll use oversampling, which is a tremendously useful technique to have in your repertoire. The idea behind oversampling is that we take repeated measurements from our ADC and combine them. This almost sounds like averaging, but it’s not the same.
  • When we oversample 4x we add the four numbers together and divide by two, increasing the number of bits in our result by one.
  • The point is that you make the best use of the ADC’s resolution when the voltage range of the ADC matches the voltage range of the sensor.
  • The piezoelectric disk, or piezo for short, is a crystal that deforms (slightly) when you apply a voltage to it, or conversely develops an electric voltage when you deform it.
  • The more terms you choose to average together in your moving average, the better you’ll average out the noise signal. [...] There is always this trade-off between smoothing the values out better and having the average be up to date.
  • To create audio that’s more interesting than square waves, we’re going to use PWM to create rapidly changing intermediate voltages that’ll trace out arbitrary waveforms.
  • The secret to driving large loads is using transistors between the AVR and a motor.
  • Bipolar transistors can be thought of as a way of taking an input current and using that to allow a much bigger, proportional current to flow between collector or emitter. For most transistors, this current gain is around 100x, which means that if you pass 10 mA through the base, the transistor will allow up to 1A to flow from collector to emitter.
  • This is the sense in which transistors are amplifiers: small changes in a small current can create big changes in a bigger current.
  • Darlington transistors are just a pair of transistors built together into the same chunk of silicon so that the first one supplies drive current to the second. Because the first transistor amplifies the current that is again amplified by the second transistor, instead of having a gain of around 35-100, Darlingtons have a current gain around 1,000 to 10,000.
  • Unlike BJTs, MOSFETS are voltage-controlled devices, which means that you don’t have to include a base resistor when hooking them up to an AVR I/O pin--just wire up the AVR pin directly to the gate. Even better, small MOSFETs draw very little current when they’re switching on or off, and almost none when they’re in a steady state, so you don’t have to worry about the AVR’s current sourcing capabilities.
  • Another nice feature with MOSFETs, although it’s kind of a hack, is that because they only require a little current when turning on, you can easily run a few in parallel off of one AVR pin, especially at low frequencies.
  • Modern power MOSFETs are just like their smaller switching MOSFET cousins, only larger and with a geometry that’s adapted to deliver more current with less resistance, and this less wasted heat. The trade-off is that power MOSFETs usually require a higher gate voltage to turn fully on and a little more current as well if you’d like to turn them on and off quickly.
  • Triacs are like transistors but used for AC current instead of DC. Solid State Relays (SSR) are basically triacs with some extra circuitry to help isolate the control side form the AC line voltage.
  • The flyback diode is important to provide a path for the current that’s flowing through the motor to continue on after we’ve switched the motor off.
  • Microstepping lets you drive a stepper motor to intermediate positions between the half steps by controlling the ratio of coil currents in the two coil pairs. You can control the coil currents by using PWM, changing the driving voltage, or using other current-limiting circuits, but the basic idea is that be varying the magnet pull on the rotor coming from the two coils you should be able to make the motor move to any angular position you’d like.
  • One reason the SPI is so fast is that, unlike our old friend UART, it’s a clocked, or synchronous, protocol.
  • Because the SPI bus is fast, you’ll find that it’s mostly used by devices that need speed: ADCs and DACs for audio or much faster signals, output expanders, and memory.
  • I2C is a tremendously popular protocol for interfacing microcontrollers with small sensors and these days even with devices that require more speed. Its main advantage is that you can talk to a large number of devices with just a couple of wires, which makes it much more like a network than the SPI bus.
  • The pointer is a special variable type that should be used specifically for stoner memory addresses.
  • Pulse-code modulation is just producing audio by changing the binary data that you feed into a digital-to-analog converter over time.
  • EEPROM provides low-power, long-term storage of fairly large amounts of data.
  • The floating-point-compatible math libraries end up taking up a bunch of memory and are slow. In my experience, there’s almost always a way to rephrase your problem that can avoid using floating-point numbers.
  • The most valuable (and fun) thing about EEPROM is that it’s nonvolatile. You can power down your chip completely, and the data in EEPROM will still be there when you turn the chip back on, even thirty years later.
  • The watchdog system is a very slow timer that can be configured to run from 16 milliseconds all the way up to 8 seconds. It is special in that when it reaches the end of its time, it can fire an interrupt or reset the chip.
  • The primary use of the watchdog timer is as a safeguard against runaway code.
  • My first choice for lowering power consumption is just to stay in sleep mode as much as possible. Following that, I’ll shut down whatever peripherals I can, but this gets tricky if you’re actually using some of them. A no-code-change method to reduce your power usage is just to use a lower voltage for VCC--all of the A series chips run on 3.3-3.6 V just fine.

20190128

Meditations on Violence by Rory Miller


  • People are weird. They have an almost infinite ability to learn and communicate. At the same time, this amazing ability is used as much for fantasy and entertainment as it is for information and survival.
  • The minute you don a black belt, the minute you step in front of a class to teach, you are seen as an expert on violence.
  • The simple truth is that many of these experts, these priests of Mars, have no experience with violence. Very, very few have experienced enough to critically look at what they have been taught, and what they are teaching, and separate the myth from reality.
  • Fair doesn’t happen in real life, not if the bad guys have anything to say about it and not if the professional good guys do, either.
  • One of the ways we complicate things is by telling stories, especially stories about ourselves. This story we tell ourselves it our identify. The essence of every good story s conflict. So our identify, the central character of this story that we tell ourselves, is based largely on how we deal with conflict. If there has been little conflict in the life, the character, our identity, is mostly fictional.
  • You are what you are, not what you think you are. Violence is what it is, not necessary what you have been told.
  • Never, ever, ever delegate responsibility for your own safety. Never, ever, ever override your own experience and common sense on the say-so of some self-appointed “expert”.
  • Never, ever, ever ignore what your eyes see because it isn’t what you imagined. And strive to always know the difference between what your eyes are seeing and what your brain is adding.
  • No matter how good you are at generalizing, there is a point where it doesn’t work and you descend into philosophy at the cost of survival.
  • Here’s a rule for life: You don’t get to pick what kinds of bad things will happen to you. You may prepare all your life to take on a cannibalistic knife-wielding sociopath. You may get stuck with a soccer riot. Or a road rage incident with a semi. Or a pickup full of baseball bat swinging drunks. Or nothing at all. You don’t get to choose.
  • For martial artists, it is important to understand that preparing for one thing is not preparing for all things.
  • Fights are dangerous. Even when you win, there is a possibility of injury, exposure to bloodborne pathogens such as HIV and hepatitis, or a lawsuit.
  • Cardiovascular fitness is extremely important for health and longevity and should be the cornerstone of any fitness regimen, yet fighting for your life is profoundly anaerobic.
  • Martial arts and martial artists often try to do it all. They teach self-defense and sparring and street fighting and fitness and personal development, as if they were the same thing. They aren’t even related.
  • Self-defense is about recovery. The ideal is to prevent the situation. The optimal mindset is often a conditioned response that requires no though (for the first half-second of the attack) or a focused rage.
  • If you can truly flip the switch from surprised, overwhelmed, and terrified to the assault mindset, I can’t teach you much. This is the opposite of the “frozen” response often triggered by a sudden assault, and we train hard to trigger that freeze in others.
  • Combat is a very different experience for generals than for soldiers. Generals can look at percentage killed, take risks, sacrifice, and maneuver men. For the generals, there are acceptable losses and you can continue to fight if you suffer twenty percent killed. For the soldier, it is binary: You are alive or you are dead.
  • Fitness is objectively the most important effect of martial arts training. The physical skills and self-defense aspects of training will never save as many people from violence as the conditioning will save from early heart attacks.
  • If you study Judo, Jujutsu, or Aikido, you will probably never use the skills to throw an attacker, but I can almost guarantee that you will and have used the breakfalls to prevent injury.
  • Fitness will never hurt you in a self-defense situation.
  • Self-defense is largely about dealing with surprise and fear and pain, none of which is useful in developing fitness.
  • People who imagine the harmony of nature are often willfully blind to the savagery between wolf and rabbit. The assault mindset can revel in that savagery.
  • The assault mindset in a sporting competition is completely unacceptable. From the assault mindset, if you are scheduled to fight a world champion heavyweight boxer on Thursday, you shoot him on Tuesday.
  • Cheating has no meaning in the mind of a predator.
  • True predators are unpredictable and that makes the chain of command uncomfortable. They will get the job done but they will ignore any parameter or rule of engagement set by command that does not seem important to them. Because of this, they are idolized in times of serious conflict and marginalized, ignore, or pushed aside when combat is rare.
  • The predator mindset is a choice. No one is in that mind at all times--it has too many blind spots to function in normal society.
  • Self-defense is never a choice. The attacker is in the predator mindset, not the victim. The victim will have to deal with shock and total surprise, the predator won’t.
  • The essence of self-defense is breaking out of the frozen mindset you have been shocked into. If you can access the predator mindset a few seconds into the attack, yo can turn the attack into something else. That’s powerful, but takes great experience.
  • Police solutions to military problems are doomed to fail just as military solutions to police problems will never be allowed in a free society.
  • Police solutions to military problems are doomed to fail just as military solutions to police problems will never be allowed in a free society.
  • Assumptions are those things you believe to be true without really considering them. They provide the background for much or how you see the parts of the world that you have never experienced.
  • Assumptions, in a large part of our daily life, are necessary and usually harmless.
  • We get into trouble when we base our assumptions on either irrelevant comparison or bad sources.
  • Personal experience would seem to be a no-brainer but very, very few people will trust their own experience against the word of either many people or a single “expert”.
  • Look at your beliefs, and the source of those beliefs. Some of your beliefs came from early training or bad sources. Some of your sources were chosen because you knew they supported your pre existing point of view. Look very deeply at those sources that you accept without question.
  • Violence, for most of us, is unknown territory. Though martial artists have studied “fighting”, and everyone has been raised in a culture where stylized violence is everywhere, very little of what we know is based on experience, and very much is based on word of mouth. It is, for many people, entirely assumption.
  • I want to be very clear here. What you have trained in and been taught is “word of mouth”. Until you do it for yourself, for real, you can’t evaluate it with accuracy. Experience in the dojo is experience in the dojo. Experience in the ring is experience in the ring. Experience on the street is experience on the street. There is some overlap in skills; some lessons transfer. But a black belt in Judo will teach you as much about sudden assault as being mugged will teach you about Judo. And my experience will always be your word of mouth.
  • If you study a formal martial art, there is another set of assumptions that you must deal with: the assumptions of your style. The first major assumption is a belief in what a “fight” is and looks like. The second is what defines a “win”.
  • Most styles and instructors are remarkably well adapted to getting the win in the right kind of fight, and crippled when the fight doesn’t match their expectation or when the conditions of a win change.
  • Every style is for something, a collection of tactics and tools to deal with what the founder was afraid of. A style based on the founders fear of losing a non-contact tournament will look different, even if it is just as well-adapted for that idea of a fight as my Jujutsu is for its time and place.
  • Understand thoroughly what your style is for. Violence is a very broad category of human interaction. Many, may instructors attempt to apply something designed for a very narrow aspect of violence, such as unarmed dueling, and extrapolate it to other incompatible areas, such as ambush survival.
  • Each instructor also has assumptions based on his or her experience, training, and (too often) television and popular culture.
  • Some of our assumptions are so closely held that we will cling to them, even in the face of overwhelming evidence. Many, many people discount their own experience as an “aberration”, preferring to trust in “common sense” or tradition or the word of an “expert”.
  • Lessons from life are gifts and they should not be ignored.
  • One of the reasons that it is hard to find an experienced instructor for real violence is that it is hard to survive enough encounters to learn what worked and what didn’t.
  • Do not let yourself be crippled by something that only exists in your mind.
  • I like experience. It helps to winnow the BS from the truth.
  • But realistically, how many instructors have enough hands-on experience in real violence to pass anything along? Very few. The instructors who have experienced enough violence to be able to generalize are even more rare.
  • Additionally, violence is extremely idiosyncratic.
  • I was discussing this with one of my students, explaining that unlike almost anything else, the more experience of violence you have the less sure you are that things will work out. Jordan put it in perspective: “Sounds like a case of the more you know, the more you realize you don’t know.”
  • Experience, in my opinion, could not give rise to a new martial art. Given the idiosyncratic nature and the improbability of surviving enough high-end encounters, it would be hard to come up with guiding principles or even a core of reliability techniques. I am painfully aware that things that worked in one instant have failed utterly in others.
  • Just because something makes perfect sense doesn’t mean it is true.
  • Most people don’t recognize the shear chaos of survival fighting or the effects that the stress hormones dumped into your bloodstream will have. Seeing a need for training in this area, instructors have a tendency to look at an area they are familiar with and extrapolate it to violence.
  • Things that should work don’t all the time.
  • Most people and organizations plan from a “Resources Forward” model. Basically, they look at what they have and figure out what they can do with it. “Goals Backwards” looks at the problem and then creates the resources. “What do I need to do, and what do I need to get to accomplish that?”
  • Look at what you need, not what you have. Then you gather what you need instead of trying to stretch resources where they were never meant to go.
  • In theory, there is no difference between theory and reality. In reality, there is. Reason, by itself, is only theory.
  • Anything that is taught becomes tradition. Even a tradition of questioning traditions. Students have a right to know which of their lessons are based on experience and which on reason.
  • Too many people, students of martial arts, concerned citizens, self-defense “experts”, and rookie officers learned most of what they think they know from television, movies, or sports events. The purpose of all of these venues is to entertain , not to educate. What they show has been modified to look more interesting.
  • In a lethal fight, one party has the advantage or gets it as early as possible and presses it to the quick, brutal end. It’s fast. There is very little drama.
  • In combat sports, three major factors make it difficult to extrapolate from the ring to uncontrolled violence. The most critical and hardest to train for his surprise. [...] The second factor is similar--you know what is likely to happen in a combat sport. [...] Rules and safety considerations are the third factor.
  • Real violence is a very broad subject and no two encounters are the same. What is a “win” in one situation may not be in the next. The goal is how you define the win in that particular encounter.
  • If the goal changes, so does everything else. If you have only trained for one goal, you will be hampered when the goal is different.
  • One of the simplest drills is “Breakthrough” where the student must, as fast as possible, get through a door blocked by two opponents.  Fighting each or both of them takes too long.
  • The goal is what needs to happen; parameters are what need to NOT happen, what you can’t do.
  • A parameter too few self-defense instructors address is “not getting sued”.
  • Goals and parameters combine to dictate strategy. Strategy is the general plan for accomplishing the goal. Fight, run, and hide are the three classic survival strategies.
  • The goal of a quick victory and the parameters of minimal casualties (and the real lack of a parameter in cost and material) result in the military strategy of “Shock and Awe”.
  • Strategy and environment dictate tactics. Tactics are the “how” of implementing strategy. Environment here is used in a very broad sense. Availability of weapons, targets, escape routes, as well as lighting, footing, and space are all elements of the environment that will affect your choice of tactics, as does the information you have and available time.
  • Tactics and the “totality of circumstances” dictate the specific technique you will use. Totality of circumstances (ToC) is the law enforcement term for all of the infinite details of the moment that influence a decision.
  • If your goals or parameters change, so does everything else. Different situations require different ways of moving, thinking, and acting. Everything changes. Striving for perfection of a single goal, the hallmark of dojo training, is far too narrow for real life.
  • The legal essence of self-defense is that you are required to use “the minimum level of force” which you “reasonably believe” is necessary to safely resolve the situation.
  • Knifes and guns, in many places, are interchangeable. Both are considered deadly force.
  • Be aware that in many, if not most jurisdictions, even if you do not use it and have no intention of using it as a lethal weapon, it is still legally considered a lethal weapon.
  • The minimum level of force will change in the course of an encounter, sometimes every second. If the threat runs or goes unconscious, stop. You’re done. He no longer presents an immediate threat.
  • Reasonably believe, simple means, would whatever you did be outside the box for another citizen with similar experience and training?
  • Reasonably believe applies to and ties together “minimum level” and “necessary”.
  • Some states have a “duty to retreat” clause written into their self-defense laws that required you to exhaust all available options to get out before you fight back.
  • To safely resolve: It is not a contest, not a game, and you are under no requirements to play fair or take chances. If you think you might be able to handle it in a wrestling match but you are sure you can handle it with your umbrella, use the umbrella.
  • The officer is required to handle situations, not at the level in which he will probably prevail, but at the level where he won’t get hurt.
  • In general, defense of yourself or a third person from imminent harm is legally good self-defense. From that point on, you have to look at state laws.
  • Lastly, in order to use force, the person you are using it on must be immediate threat, the threat must exhibit and you must be able to clearly articulate three things: intent, means, and opportunity.
  • You must be able to clearly explain how you know he was going to hurt you, hurt someone else, kill you, kill someone else, destroy or steal property...whatever the situation you need to resolve.
  • Whatever you feel he was going to do, whatever the situation you had to resolve, you have to be able to articulate that he was able to do it.
  • If the threat can’t reach you, you can’t argue that he was an immediate threat.
  • Be aware that in any classroom or dojo setting, there is a gap between the perceived goal and the real goal. The perceived goal is what you think you are teaching. The real goal, the goal the student strives for never changes: Make the instructor happy.
  • Strategy and tactics, assumptions and epistemology are all critical to thinking about violence and preparing for violence. In the moment of sudden attack, however, your brain will change. The way you think will change.
  • The OODA loop, described by U.S. Air Force Colonel John Boyd, has become the standard nomenclature for combative decisions-making. In essence, each person must: Observe what is happening; Orient to the observations (interpret the sensory input); Decide what to do about it; and Act.
  • In combat or self-defense, the usual problem is to try to get too much information.
  • The most fatal decision in an ambush is the “why” question. You won’t get the answer and if you did get an answer, it wouldn’t help you. But many, many victims free right here, with the “why”.
  • Decide is the second time waster. Hick’s Law, which states that the more options you have, the longer it takes to choose one. Makes sense. I call this the Brown Belt Syndrome. It’s what happens when you have too many cool ways to win and you get your ass kicked while you are weighing your options.
  • One of the goals of training must be to expose yourself to the widest variety of situations possible to prevent this.
  • You must be able to act with partial information. You will never have all the answers or know exactly what is going on. People who wait for too much information before acting get hurt.
  • The speed of your OODA loop depends on your comfort level of information.
  • Most humans fight for status or territory like other animals. Most conflict is about “face” or “respect”, not about necessity. The need to establish a place in the hierarchy of humans is a very powerful drive, one that influences many humans for much of their lives. The fear of being challenged on this basis is also overwhelming and is expressed in many ways.
  • This story you tell yourself is something you have built up since birth. In a very real sense, it is your life’s work. The damage to the story can have longer-term effects than damage to the body. The risk to the story, to your self-image, status, and ego can generate far more fear than mere physical risk.
  • Humans are apes and we have our own built-in ritual combat to establish social dominance or defend territory. It is nearly always lethal. I call it the Monkey Dance.
  • Acting bored and thoughtful can be very powerful. By not questioning your own status, it makes it harder for someone to challenge you for it. There is more, however. Boredom itself is one of the big indicators of confidence, and even status. Whether it is in a boardroom, a job interview, a duel, or a football game, nervousness is the sign of the underdog, the probably loser. The opposite of nervousness can go beyond calm and bored. Powerful.
  • The Monkey Dance is based on gaining status and many who play it want a quick back-down with minimal risk. Very few people challenge children, for instance. There is no status to gain. No one plays the Monkey Dance with a crazy person--there is little chance for status, no guarantee of a quick back-down, and crazy people don’t always follow the steps.
  • If it’s appropriate, circumvent the Monkey Dance by jumping steps. If the threat is at any level beloved contact and you attack, you will cause him to freeze. The dance is a biological game and it takes a small amount of time to adjust when someone cheats.
  • Just be sure that you can articulate intent, means, and opportunity.
  • Rarely can anyone make a joint lock work against a strike outside the conditions of a dojo with people trained to strike in a certain and ineffective way.
  • The Monkey Dance described here is a male phenomenon. It is very rare in nature for the female of the species to dispute for status and territoriality.
  • Remember that the Monkey Dance is biologically designed to be nonlethal. Damage when it occurs is usually cosmetic.
  • Women are used to handling men in certain ways, with certain subconscious rules--social ways, not physical ones. These systems are very effective within society and not effective at all when civilization is no longer a factor, such as in a violent assault or rape.
  • The Group Monkey Dance (GMD) is another dominance game. In this ritual, members of a group compete for status and to show their loyalty to the group by showing how vicious they can be to someone perceived as an “outsider”. It is purely a contest to prove who is more a part of the group by who can do the most violence to the outsider.
  • Violence with a goal beyond domination is not like the Monkey Dance. It more closely mimics the violence between different species.
  • In predatory violence, the victim is the resource. The attack is planned, efficient, and safe way for the attacker to get what he wants from that resource.
  • Generally, human predators use two distinct strategies to approach and disable their human victims. The blitz attack is the sudden, brutal assault from ambush. The threat will get as close as he can without being noticed or triggering a defensive response and then attempt to overwhelm the victim physically and mentally with a fast, vicious attack. The second attack strategy uses charm and persuasiveness to get close enough and keep the victim off-guard. It then progressives like a blitz, with an overwhelming onslaught.
  • For now, think of one key point: People are not charming, it is not an inherited trait. Charm is something people use, a conscious act to get what they want. There are no charming people, only people who use charm.
  • Very, very few martial artist have a realistic idea of a predatory attack in their training assumptions.
  • The four truths: Assaults happen closer, faster, more suddenly, and with more power than most people believe.
  • One of the most common and artificial aspects of modern martial arts training is that self-defense drills are practiced at an optimum distance where the attacker must take at least a half step to contact. Real criminals rarely give this luxury of time. They strike when they are sure of hitting, positive that their victim is well within range before initiating the attack.
  • Because the threat has chosen the time, the place, and the victim, he can attack all-out, with no thought given to defense. The speed of this flurry, the constant rain of blows, can be mind numbing.
  • An assault is based on the threat assessment of his chances. If he can’t get surprise, he often won’t attack. Some experts say that there is always some intuitive warning. Possibly, but if the warning was noted and heeded, the attack would be prevented. When the attack happens, it is always a surprise.
  • The unexpectedness of an attack can negate nearly any skill.
  • There is a built-in problem with all training. You want to recycle your partners. If you or your students hit as hard as they can every time they hit, you will quickly run out of students. Truthfully, the average criminal does not hit nearly as hard as a good boxer or karate can hit. They do hit harder than the average boxer or karate has ever felt.
  • Skilled technique degrades under stress. It degrades a lot. If you’ve ever heard or said, “If it was for real, I would have done better,” you’ve bought into a huge lie. When the stakes are higher, people do much, much worse than when the pressure is low.
  • Complex motor skills, essentially your coordination, will be hampered with a strong enough cocktail. Trapping, combinations, throws--anything that requires hands and feet working together will be gone.
  • There is an optimal stage of adrenalization. There is a point, you know it when you feel it, when you are on your game. You’re alert, ready.
  • In general, men get a big surge of adrenaline early that dissipates fairly quickly. Women have a much slower build up and a longer cool down time. Hence, a man will be ready to go berserk (or freeze) as soon as the engagements tarts and a woman will be able to think clearly for several minutes before she hits her “deer in the headlights” mode.
  • With enough exposure, it is possible to become inured to certain types of violence.
  • When someone threatens you but you are pretty confident you can handle it, you’ll get some serious adrenaline but you probably won’t freeze. This is the best of the bad situations.
  • In order to train, you will need someone you can trust to be ruthless and unpredictable. The key is to trigger this state so that you can recognize it.
  • Experience is no substitute for training. Training is no substitute for experience.
  • In the moment, like breaking the freeze, you must force yourself to act. Once a few steps are taken on the new path and you haven’t died, the primitive brain will ease up a bit.
  • Violence happens where people get their minds altered. Drugs and alcohol at the most basic level change the way people think and act.
  • Violence happens where young men gather in groups. Lots of violence, minor and major, is based on the Monkey Dance or Group Monkey Dance models. The Monkey Dance is primarily a young male phenomenon, as older men have usually established their status. Young men, still struggling to establish status or identify, are extreme risks for MD attacks.
  • A reputation for violence is very valuable in establishing status with this group. It does not need to be real ability, just a reputation.
  • Violence happens where territories are in dispute. Lots of gang violence, lots of military violence--let’s just call it social violence--happens in places where two or more groups are trying to run things.
  • People fight and kill to defend imaginary territory--respect and honor, symbols, membership in a group. They are not fighting to defend their lives but only to defend the way that they see themselves.
  • Predatory violence happens in lonely places. Attacks happen where the predator believes he is unlikely to be disturbed and witnesses are rare. A sudden assault with intent to murder, rape, or rob is a planned action. The predator has taken care to choose a place and time that benefit him.
  • The first crime scene is where the human predator takes his victims so that he can spend more time and have greater privacy.
  • Home invasion crimes have many of the elements of a secondary crime scene. Your home is private and secure, exactly what a predatory criminal may want. In addition, threat against family members can be used as leverage to force cooperation with the predator. This cooperation will not be to the victim’s benefit.
  • Whereas predatory assaults happen in lonely places, fishing for victims can happen in crowds. The predator is looking for an easy mark. There are a handful of victim personalities and the predator hunts for them. Using eye contact, body language, and proximity, the predator sees who will back down without eye contact, who will pretend an inappropriate touch didn’t happen, who will try to curry favor with those they see as strong.
  • Defending yourself is not an never has been about rights--rights are those things that the civilized members of society agree everyone deserves.
  • It’s better to avoid than run; better to run than to de-escalate; better to de-escalate than to fight; better to fight than to die. The very essence of self-defense is a thin list of things that might get you out alive when you are already screwed.
  • There is a difference between violence and the threat of violence. That distance is time.
  • The threat of violence is a gift, someone communicating to you that they intend or are considering using violence, but they haven’t yet. Someone threatening to hurt you has given you information and precious time. Use that time.
  • Use of discretionary time is one of the most valuable concepts in emergency response and one of the hallmark difference between a veteran and a rookie.
  • If you have time to plan, even a second, use it.
  • There is no good result of a violent criminal wanting to be alone with you.
  • Most people--even dangerous, violent people--can’t kill “cold”. They need to work themselves up, need the adrenaline.
  • Personalize yourself. It is much harder to kill someone you know than a stranger. If at all possible, make sure the hostage takers know your name and face. If conversations happen, look for common areas of interest, but don’t be phony. The goal is to make it harder to see you as an outsider.
  • Do not allow yourself to be tied, handcuffed, or moved to a secondary crime scene. [...] Once you are restrained, you are out of option. When and if it becomes appropriate or necessary to act, you will not be able to.
  • Once the violence starts, it is too late to plan. Your options are limited. This is very simple. You either run or fight or hide.
  • Making distance is more likely to make someone miss with a handgun than any fancy evasive maneuvers.
  • The statistics on misses are encouraging. Most people miss most of the time, even at extremely close range.
  • Statistics on survivability are also good. Most people recover fully. Corollary--Do not let your imagination kill you. If you are shot or stabbed, keep running! Do not curl up and die because that’s what you’ve seen on TV.
  • Almost all humans have a self-referencing test for effectiveness: if it works on me, it works. This is almost true. If it works on you, it will work on the majority of normal, sane people without drugs or alcohol in their stems who aren’t really scared or really angry.
  • To live a criminal lifestyle is to become a skilled exploiter. There is no program so noble, or (as yet) so well-designed, that a skilled exploiter can not only avoid changing, but actually abuse it to become enabling.
  • Predators see you as a resource. If they attack, it will be from the greatest advantage they can muster.
  • The serial predator is a process predator for whom the act is all important.
  • For most true predators, jail is meaningless. It just gives them a different victim pool.
  • The unpredictability of the mentally ill is extremely challenging.
  • Violence in the past is the strongest indicator of violence in the future: Predators rarely cease to pray.
  • If you have the sense to avoid places where violence happens, you should have the sense to avoid violent people.
  • In every drill you teach, you must consciously know what the flaw is and make your students aware of it.
  • Memorized combinations applied in air almost never work the same way on a body that reacts and resits. The feeling of impact and the feeling of being hit are also missing, which can lead to freezing in a real conflict when it doesn’t feel like you expected.
  • Especially with locks and immobilizations, you only transition from bad techniques to good ones. You never transition for the sake of the transition. If the first technique is good, you don’t give it away fro something that might go bad. That’s different for striking, where each technique is a small explosive slice of time, but you get the idea.
  • Outside of sport, it is important to practice the crippling techniques.
  • Sparring is often a chess match of distance and timing. Assault is an overwhelming onslaught. The skills don’t transfer.
  • To recap, assaults happen fast, hard, close, and with surprise.
  • Most importantly, the very concept of “fairness” has no place in the discussion of predatory assault. The victim can’t afford to be fair, and the attacker won’t be.
  • Condition for a quick, effective response to any unexpected aggressive touch. Trained properly, the counterattack will kick in before the chemical cocktail of stress hormones. This will give one technique at 100%, and possible the initiative, to the exposed victim. This level of conditioning is one of the few training methods that can address the suddenness of an assault.
  • Train to flip the switch. Make your students practice going from friendly, distracted, or any other emotion to full-on in an instant.
  • Slow-motion training is a valuable tool, but not if students do things in training that they physically can’t do at speed.
  • Get used to being hit, and get used to being touched, especially on the face.
  • Before anything bad happens, preferably years before, you should become familiar with the legal aspects of self-defense--how much force you can legally use, when you can use it, and when to stop. You also need to work out your moral and ethical issues with regard to violence.
  • Learn how to de-escalate someone verbally and learn the warning signs when it is too late to make de-escalation work. And don’t get hung up here--a true predator won’t give you a chance to use this level.
  • Optimally, you need to train a small group of counterattacks to sudden assault and train them to reflex speed. This is one of the few things that can derail a predator’s plan. If you have trained it well, this response will kick in before you freeze.
  • When you know or believe that the threat has decided to hurt you, you attack. It is the most effective physical defense but takes great skill to use and justify.
  • Train yourself to be aware of ambush zones, escape and evasion routes, threat concentrations, etc. The ideal is to not be where the violence is likely to happen.
  • Monkey dance violence is predicated on the idea that there is a contest for dominance or social status between two people. If one of them refuses to play the game, pretending to be unaware of the challenge, the situation often evaporates.
  • Charm is a verb. People are not charming; charm is something they use to get what they want. When someone attempts to use charm, ask yourself what they want. It might be bad.
  • Bad things happen in places. Bad things are done by bad people. If you avoid the bad people and bad places, you usually avoid the bad events.
  • If you are ever faced with extreme violence, you will have to make the decision to act. Make it now. You must decide what is worth fighting for, never forgetting that the question involves the risk of both dying and killing. You must decide now.
  • Once you have made the list, these are your “Go” buttons. You must commit that if one of them happens you will act ruthlessly and decisively. You cannot second-guess yourself in the moment.
  • The Golden Rule of Combat: Your most powerful weapon; Applied to your opponent’s greatest vulnerability; At his time of maximum imbalance.
  • Possibly the most overlooked aspect of power generation in the martial arts is one of the most effective: Use a tool. I will take a hickory baseball bat over the hardest fist on Okinawa. A weapon extends reach, increasing power, leverage, and speed.
  • Tools are everywhere, limited only by your imagination and experience.
  • The most effective unarmed practitioner will consistently lose to a mediocre practitioner who has a weapon.
  • Continuous striking is another power multiplier. Be very careful in training not to develop the habit of striking once or twice and then pausing to gauge the effect.
  • Attack hard. Attack ferociously. “Violence of action trumps technique.” Hitting hard, fast, and aggressively is more effective than hitting properly. Both are good, but violence of action wins.
  • Be cautious with gloves sparring. Gloves encourage closed-fist strikes to the head and real hands tend to break when they do that.
  • You must strike hard, fast, and with total commitment.
  • There are four combative physical effects you can have on your opponent:
    • You can move him, or part of him.
    • You can cause pain.
    • You can cause damage.
    • You can cause shock.
  • In self-defense, pain is always an extra, NEVER the primary goal of a technique. Some people can focus through pain. Many threats under the influence of drugs, alcohol, or mental illness are completely immune to pain.
  • Damage is destroying structural integrity to the point that all or part of the body is not useable. In your training, be very careful that you understand the difference between pain and damage.
  • A broken nose, while fairly painful, is not debilitating in any way. You can keep fighting through it and so could your opponent.
  • Cutting off blood supply works on everyone--regardless of drugs, rage, or size--which makes the strangles the big equalizer.
  • In the end at the deepest level, successful physical defense will depend on three things: Awareness, Initiative, and Permission.
  • Want to change your life forever? Commit right now to never make a half-assed decisions again.
  • In combat, if you are aware, you know what needs to be done. Do it. In life, you know what needs to be done, you know the right things to do. Do them.
  • Trained people often don’t generalize from skills they have to identical skills.
  • In acts of violence, what the world is comes into direct conflict with what we expect the world should be.
  • Exposure, especially repeated exposure to extreme violence, will change you. At the best, the fear of death and the decision to fight will clarify in your mind what is worth fighting for and what is worth dying for. That clarity is very powerful. You will realize how any people are attached to ideas and opinions that are meaningless, and how many of the passionate disagreements of your past were largely pointless.
  • One of the hardest things for civilians and even researches to grasp is that wears normal people need a reason to lie, criminals need a reason to tell the truth. In a violent, marginal world information is power and disinformation is habit.
  • Hopefully, one thing you learned from this book is that technique is not the answer. There is no recipe for survival. The answer is almost always inherent in the problem if you can see it and if you can act.
  • I collect old book on Judo and Jujitsu because some of the authors were brutal and knew the line between practice and breaking people. Fairbairn and Applegate are books by two mean who taught people how to survive in the bloodiest war of modern history.
  • When you find a nuggets of good information, keep it.

20190123

Clean Architecture by Robert C. Martin


  • My conclusion is that the rules of software architecture are independent of every other variable.
  • Getting software right is hard. It takes knowledge and skills that most young programmers haven’t yet acquired. It requires thought and insight that most programmers don’t take the time to develop. It requires a level of discipline and dedication that most programmers never dreamed they’d need.
  • The goal of software architecture is to minimize the human resources required to build and maintain the required system.
  • The measure of design quality is simply the measure of the effort required to meet the needs of the customer. If that effort is low, and stays low throughout the lifetime of the system, the design is good. If that effort grows with each new release, the design is bad. It’s as simple as that.
  • The fact is that making messes is always slower than staying clean, no matter which time scale you are using.
  • The only way to go fast, is to go well.
  • Their overconfidence will drive the redesign into the same mess as the original project.
  • In every case, the best option is for the development organization to recognize and avoid its own overconfidence and to start taking the quality of its software architecture seriously.
  • The first value of software is its behavior. Programmers are hired to make machines behave in a way that makes or saves money for the stakeholders.
  • Software was invented to be “soft”. It was intended to be a way to easily change the behavior of machines. If we’d wanted the behavior of machines to be hard to change, we would have called it hardware.
  • I have two kinds of problems, the urgent and the important. The urgent are not important, and the important are never urgent.
  • Those things that are urgent are rarely of great importance, and those things that are important are seldom of great urgency.
  • The first value of software--behavior--is urgent but not always particularly important.
  • The dilemma for software developers is that business managers are not equipped to evaluate the importance of architecture. That’s what software developers were hired to do. Therefore it is the responsibility of the software development team to assert the importance of architecture over the urgency of features.
  • Just remember: If architecture comes last, then the system will become ever more costly to develop, and eventually change will become practically impossible for part or all of the system.
  • Structured programming imposes discipline on direct transfer of control.
  • Object-oriented programming imposes discipline on indirect transfer of control.
  • Functional programming imposes discipline upon assignment.
  • The problem that Dijkstra recognized, early on, was that programming is hard, and that programmers don’t do it very well. A program of any complexity contains too many details for a human brain to manage without help. Overlooking just on small detail results in programs that may seem to work, but fail in surprising ways.
  • Structured programming allows modules to be recursively decomposed into provable units, which in turn means that modules can be functionally decomposed.
  • Science is fundamentally different from mathematics, in that scientific theories and laws cannot be proven correct.
  • That is the nature of scientific theories and laws: They are falsifiable but not provable.
  • Science does not work by proving statements true, but rather by proving statements false. Those statements that we cannot prove false, after much effort, we deem to be true enough for our purposes.
  • Inheritance is simply the redeclaration of a group of variables and functions within an enclosing scope. This is something C programmers were able to do manually long before there was an OO language.
  • The bottom line is that polymorphism is an application of pointers to functions.
  • The problem with explicitly using pointers to functions to create polymorphic behavior is that pointers to functions are dangerous. Such use is driven by a set of manual conventions. You have to remember to follow the convention to initialize those pointers. You have to remember to follow the convention to call all your functions through those pointers. If any programmer fails to remember these conventions, the resulting bug can be devilishly hard to track down and eliminate.
  • The fact that OO languages provide safe and convenient polymorphism mean that any source code dependency, no matter where it is, can be inverted.
  • Variables in functional languages do not vary.
  • All race conditions, deadlock, conditions, and concurrent update problems are due to mutable variables. You cannot have a race condition or a concurrent update problem if no variable is ever updated. You cannot have deadlocks without mutable locks.
  • Event sourcing is a strategy wherein we store the transactions, but not the state. When state is required, we simply apply all the transactions from the beginning of time.
  • Structured programming is discipline imposed upon direct transfer of control.
  • Object-oriented programming is discipline imposed upon indirect transfer of control.
  • Functional programming is discipline imposed upon variable assignment.
  • What we have learned over the last half-century is what not to do.
  • Software--the stuff of computer programs--is composed of sequence, selection, iteration, and indirection. Nothing more. Nothing less.
  • The SOLID principles tell us how to arrange our functions and data structures into classes, and how those classes should be interconnected.
  • The best structure for a software system is heavily influenced by the social structure of the organization that uses it so that each software module has one, and only one, reason to change.
  • For software systems to be easy to change, they must be designed to allow the behavior of those systems to be changed by adding new code, rather than changing existing code.
  • To build software systems from interchangeable parts, those parts must adhere to a contract that allows those parts to be substituted one for another.
  • Avoid depending on things that you don’t use.
  • The code that implements high-level policy should not depend on the code that implements low-level details. Rather, details should depend on policies.
  • The lesson here is that depending on something that carries baggage that you don’t need can cause you troubles that you didn’t expect.
  • Good software designers and architects work hard to reduce the volatility of interfaces. They try to find ways to add functionality to implementations without making changes to the interfaces.
  • Murphy’s law of program size: Programs will grow to fill all available compile and link time.
  • Gather into components those classes that change for the same reasons and at the same times. Separate into different components those glasses that change at different times and for different reasons.
  • For most applications, maintainability is more important than reusability. If the code in an application must change, you would rather that all of the changes occur in one component, rather than being distributed across many components. If changes are confined to a single component, then we need to deploy only the one changed component.
  • Gather together those things that change at the same times and for the same reasons. Separate those things that change at different times or for different reasons.
  • Don’t force users of a component to depend on things they don’t need.
  • Don’t depend on things you don’t need.
  • Allow no cycles in the component dependency graph.
  • The architecture of a software system is the shape given to that system by those who build it.
  • The purpose of that shape is to facilitate the development, deployment, operation, and maintenance of the software system contained within it.
  • The primary purpose of architecture is to support the life cycle of the system. Good architecture makes the system easy to understand, easy to develop, easy to maintain, and easy to deploy. The ultimate goals is to minimize the lifetime cost of the system and to maximize programmer productivity.
  • To be effective, a software system must be deployable. The higher the cost of deployment, the less useful the system is. A goal of a software architecture, then, should be to make a system that can be easily deployed with a single action.
  • Of all the aspects of a software system, maintenance is the most costly. The never-ending parade of new features and the inevitable trail of defects and corrections consume vast amounts of human resources.
  • The primary cost of maintenance is in spelunking and risk.
  • Spelunking is the cost of digging through the existing software, trying to determine the best place and the best strategy to add a new feature or to repair a defect. While making such changes, the likelihood of creating inadvertent defects is always there, adding to the cost of risk.
  • All software systems can be decomposed into two major elements: policy and details. The policy element embodies all the business rules and procedures. The policy is where the true value of the system lives. The details are those things that are necessary to enable humans, other systems, and programmers to communicate with the policy; but that do not impact the behavior of the policy at all.
  • The longer you leave options open, the more experiments you can run, the more things you can try, and the more information you will have when you reach the point at which those decisions can no longer be deferred.
  • A good architect pretends that the decision has not been made, and shapes the system such that those decisions can still be deferred or changed for as long as possible.
  • A good architect maximizes the number of decisions not made.
  • Good architects carefully separate details from policy, and then decouple the policy from the details so thoroughly that the policy has no knowledge of the details and does not depend on the details in any way.
  • Good architects design the policy so that decisions about the details can be delayed and deferred for as long as possible.
  • A good architecture must support:
    • The use cases and operation of the system.
    • The maintenance of the system.
    • The development of the system.
    • The deployment of the system.
  • Any organization that designs a system will produce a design whose structure is a copy of the organization’s communication structure.
  • A good architecture makes the system easy to change, in all the ways that it must change, by leaving options open.
  • Duplication is generally a bad thing in software. We don’t like duplicated code. When code is truly duplicated, we are honor-bound as professionals to reduce and eliminate it.
  • Recall that the goal of an architect is to minimize the human resources required to build and maintain the required system. What is it that saps this kind of people-power? Coupling--and especially to premature decisions.
  • GUIs change at different times and at different rates than business rules, so there should be a boundary between them. Business rules change at different times and for different reasons than dependency injection frameworks, so there should be a boundary between them.
  • Communications between components in a monolith are very fast and inexpensive. They are typically just function calls. Consequently, communications across source-level decoupled boundaries can be very chatty.
  • Software systems are statements of policy. Indeed, at its core, that’s all a computer program actually is. A computer program is a detailed description of the policy by which inputs are transformed into outputs.
  • Source code dependencies must point only inward, toward higher-level policies.
  • In every system, there is at least one component that creates, coordinates, and oversees the others. I call this component Main.
  • Think of Main as the dirtiest of all the dirty components.
  • The first rule of software design--whether for testability or for any other reason--is always the same: Don’t depend on volatile things.
  • Although software does not wear out, firmware and hardware become obsolete, thereby requiring software modifications.
  • Although software does not wear out, it can be destroyed from within by unmanaged dependencies on firmware and hardware.
  • It is not uncommon for embedded software to be denied a potentially long life due to being infected with dependencies on hardware.
  • Software and firmware intermingling is an anti-pattern. Code exhibiting this anti-pattern will resist changes.
  • A clean embedded architecture software is testable off the target hardware. A successful HAL provides that seam or set of substituting points that facilitate off-target testing.
  • To give your embedded code a good chance at a long life, you have to treat the operating system as a detail and protect against OS dependencies.
  • Milliseconds might not seem like a lot, but a millisecond is a million times longer than the cycle time of most processors. If that data was not on a disk, it could be accessed in nanoseconds, instead of milliseconds.
  • The relationship between you and the framework author is extraordinarily asymmetric. You must make a huge commitment to the framework, but the framework author makes no commitment to you whatsoever.
  • Don’t marry the framework!
  • Components are the units of deployment. They are the smallest entities that can be deployed as part of a system.
  • Be mindful that most software developers are not very architecture-aware.