Original image

Fourth of July Fireworks

Original image

The celebration of American Independence Day has never been small, subdued, or quiet. From sea to shining sea, this Fourth of July will be illuminated with displays of fireworks in major cities, small towns, and backyards.

The beginning of pyrotechnics was around 2000 years ago, when the Chinese developed gunpowder by mixing sulphur, charcoal, and saltpeter. Even in its early form, "huo yao" (fire chemical) was used to make loud noises for celebrations. A monk named Li Tian is credited with the invention of firecrackers about 1000 years ago, made by stuffing huo yao into a bamboo tube. The use of gunpowder in weapons came later.


Gunpowder was brought to the western world by either Marco Polo or the Crusaders, or perhaps both. Most Europeans concentrated on the use of gunpowder in weapons, while the Italians developed pyrotechnic shows. Even today, many of the American pyrotechnic companies are run by families of Italian ancestry, such as Fireworks by Grucci and Zambelli Fireworks Internationale.

The Founding Fathers finished the final draft of the Declaration of Independence on July 2nd, 1776. On July 3rd, John Adams wrote to his wife Abigail about the momentous occasion.


The Second Day of July 1776, will be the most memorable Epocha, in the History of America. I am apt to believe that it will be celebrated, by succeeding Generations, as the great anniversary Festival. It ought to be commemorated, as the Day of Deliverance by solemn Acts of Devotion to God Almighty. It ought to be solemnized with Pomp and Parade, with Shews, Games, Sports, Guns, Bells, Bonfires and Illuminations from one End of this Continent to the other from this Time forward forever more. You will think me transported with Enthusiasm but I am not. I am well aware of the Toil and Blood and Treasure, that it will cost Us to maintain this Declaration, and support and defend these States. Yet through all the Gloom I can see the Rays of ravishing Light and Glory. I can see that the End is more than worth all the Means. And that Posterity will tryumph in that Days Transaction, even altho We should rue it, which I trust in God We shall not.


July 4, 1776 was the day the Continental Congress finalized the wording of the Declaration of Independence. The official signing didn't take place until later, but July 4th has ever since been the birthday of America. Celebrations of independence took place throughout the summer of 1776, as well as they could considering there was a war going on. The legacy of the revolutionary celebrations is to celebrate with artillery and cannonfire in addition to bonfires and illuminations. Firecrackers and rockets were a natural extension. The first anniversary of the date was celebrated with the pomp and circumstance we would recognize today. Even in 1777, fireworks were used.

The evening was closed with the ringing of bells, and at night there was a grand exhibition of fireworks, which began and concluded with thirteen rockets on the commons, and the city was beautifully illuminated. Every thing was conducted with the greatest order and decorum, and the face of joy and gladness was universal. Thus may the 4th of July, that glorious and ever memorable day, be celebrated through America, by the sons of freedom, from age to age till time shall be no more. Amen, and amen (Virginia Gazette, 18 July 1777).


The War of 1812 brought more fireworks traditions to Independence Day celebrations. Francis Scott Key wrote a poem entitled "Defence of Fort McHenry" while watching the battle rage in 1814. It was later set to the tune of a drinking song, retitled "The Star-Spangled Banner," and became the United States' national anthem. The lines "the rocket's red glare, the bombs bursting in air" reinforce the use of fireworks in patriotic displays. Another composition, "The 1812 Overture," has been co-opted to use in public fireworks displays, although the tune was written by Tchaikovsky about Napoleon's unsuccessful invasion of Russia. The sequence of cannon fire in the song lends itself to fireworks accompaniment much too usefully for us to quibble about its origins.

Today, fireworks are a unifying factor in the many ways America celebrates the holiday. You can have a parade, a picnic, a ballgame, a car race, or an eating contest, but it wouldn't be the same holiday without fireworks.


The Macy's display in New York City bills itself as the Largest Fireworks Display in America. Bristol, Rhode Island, has the longest continuous string of Independence day celebrations in the nation. This year will be number 222! Pop Goes the Fourth! is a Boston tradition featuring music of the Boston Pops Orchestra, and will be broadcast live on CBS-TV. A Capitol Fourth will be broadcast on PBS from Washington, DC. All the major events will include a massive fireworks display. Whether you attend a local fireworks display, watch one on TV, shoot some off in your own backyard, or enjoy virtual fireworks on the net, have a happy Fourth of July!

Original image
iStock // Ekaterina Minaeva
Man Buys Two Metric Tons of LEGO Bricks; Sorts Them Via Machine Learning
May 21, 2017
Original image
iStock // Ekaterina Minaeva

Jacques Mattheij made a small, but awesome, mistake. He went on eBay one evening and bid on a bunch of bulk LEGO brick auctions, then went to sleep. Upon waking, he discovered that he was the high bidder on many, and was now the proud owner of two tons of LEGO bricks. (This is about 4400 pounds.) He wrote, "[L]esson 1: if you win almost all bids you are bidding too high."

Mattheij had noticed that bulk, unsorted bricks sell for something like €10/kilogram, whereas sets are roughly €40/kg and rare parts go for up to €100/kg. Much of the value of the bricks is in their sorting. If he could reduce the entropy of these bins of unsorted bricks, he could make a tidy profit. While many people do this work by hand, the problem is enormous—just the kind of challenge for a computer. Mattheij writes:

There are 38000+ shapes and there are 100+ possible shades of color (you can roughly tell how old someone is by asking them what lego colors they remember from their youth).

In the following months, Mattheij built a proof-of-concept sorting system using, of course, LEGO. He broke the problem down into a series of sub-problems (including "feeding LEGO reliably from a hopper is surprisingly hard," one of those facts of nature that will stymie even the best system design). After tinkering with the prototype at length, he expanded the system to a surprisingly complex system of conveyer belts (powered by a home treadmill), various pieces of cabinetry, and "copious quantities of crazy glue."

Here's a video showing the current system running at low speed:

The key part of the system was running the bricks past a camera paired with a computer running a neural net-based image classifier. That allows the computer (when sufficiently trained on brick images) to recognize bricks and thus categorize them by color, shape, or other parameters. Remember that as bricks pass by, they can be in any orientation, can be dirty, can even be stuck to other pieces. So having a flexible software system is key to recognizing—in a fraction of a second—what a given brick is, in order to sort it out. When a match is found, a jet of compressed air pops the piece off the conveyer belt and into a waiting bin.

After much experimentation, Mattheij rewrote the software (several times in fact) to accomplish a variety of basic tasks. At its core, the system takes images from a webcam and feeds them to a neural network to do the classification. Of course, the neural net needs to be "trained" by showing it lots of images, and telling it what those images represent. Mattheij's breakthrough was allowing the machine to effectively train itself, with guidance: Running pieces through allows the system to take its own photos, make a guess, and build on that guess. As long as Mattheij corrects the incorrect guesses, he ends up with a decent (and self-reinforcing) corpus of training data. As the machine continues running, it can rack up more training, allowing it to recognize a broad variety of pieces on the fly.

Here's another video, focusing on how the pieces move on conveyer belts (running at slow speed so puny humans can follow). You can also see the air jets in action:

In an email interview, Mattheij told Mental Floss that the system currently sorts LEGO bricks into more than 50 categories. It can also be run in a color-sorting mode to bin the parts across 12 color groups. (Thus at present you'd likely do a two-pass sort on the bricks: once for shape, then a separate pass for color.) He continues to refine the system, with a focus on making its recognition abilities faster. At some point down the line, he plans to make the software portion open source. You're on your own as far as building conveyer belts, bins, and so forth.

Check out Mattheij's writeup in two parts for more information. It starts with an overview of the story, followed up with a deep dive on the software. He's also tweeting about the project (among other things). And if you look around a bit, you'll find bulk LEGO brick auctions online—it's definitely a thing!

Original image
Name the Author Based on the Character
May 23, 2017
Original image