David Lynch’s Lost Dune 2 Script Has Been Found

https://i.kinja-img.com/image/upload/c_fill,h_675,pg_1,q_80,w_1200/1819fc12e0867c8f7c11daf5cc425139.jpg

We’re all ready to see just what Denis Villeneuve and his crew do with Dune: Part Two in a few months, but what if nearly four decades ago we’d had a chance to get a sequel to compare it to? David Lynch’s planned script for a sequel to his wild 1984 movie has been missing for years, but now, an unfinished draft has been found.

Spoilers of the Week April 24-29

Over at Wired, Max Evry—author of A Masterpiece in Disarray: David Lynch’s Dune—An Oral Historyhas revealed details from an unfinished draft of Lynch’s Dune sequel, Dune Messiah, discovered last year in archives at California State University, Fullerton. There’s a ton of fascinating details in there, like how Lynch’s script opened with a notably new set of scenes compared to Herbert’s novel—picking up in the aftermath of the Harkonnen’s attack on Arrakeen that saw Duncan Idaho (Richard Jordan) killed in action.

Lynch’s Messiah would’ve revealed that Leonardo Cimino’s mysterious doctor from the first film was actually a major figure from Herbert’s novels: Scytale, a “face-dancer” of the sinister genetically enhanced beings known as the Bene Tleilax. Scytale takes Idaho’s body amid the chaos of the assault on Arrakeen, and what follows in Lynch’s script is a suitably Lynchian exploration of Scytale resurrecting Idaho as the clone “Ghola” Hayt, a surrealist trip into the Bene Tleilax’s homeworld that would’ve opened the film:

Scytale’s friends are laughing and wildly rolling marbles under their hands as they watch Scytale sing through eighteen mouths in eighteen heads strung together with flesh that is like a flabby hose. The heads are singing all over the pink room. One man opens his mouth and a swarm of tiny people stream out singing accompaniment to Scytale. Another man releases a floating dog which explodes in mid-air causing everyone to get small and lost in the fibers of the beautiful carpet. Though small they all continue to laugh, a laughter which is now extremely high in pitch. Scytale (now with only one head) crawls up a wall laughing hysterically.

There’s a lot more over at Wired, including how Lynch would’ve set the stages for the various political machinations surrounding Paul, now Maud’Dib, and his rule of Arrakis, and how the draft cuts off almost right as Lynch would’ve had to start exploring just how his sequel would’ve framed Paul’s ascension to power. It’s a fascinating insight into what could’ve been—and although Lynch himself, declining to speak about the script’s finding, cites his work on Dune as “a failure in his eyes, and not a particular time that he likes to think of or talk about” to Wired—it holds up a very compelling alternate mirror as to what we’re going to see when Dune: Part Two finally hits theaters on March 1.


Want more io9 news? Check out when to expect the latest Marvel, Star Wars, and Star Trek releases, what’s next for the DC Universe on film and TV, and everything you need to know about the future of Doctor Who.

Gizmodo

How To Build A Tire Hammer

http://blademag.com/wp-content/uploads/Tire-Hammer-Clutch.jpg

How To Build A Tire Hammer
The author’s power hammer uses a tire and a drive wheel. Stepping on the treadle lifts the drive wheel into the tire, engaging the hammer. This is similar to the Clay Spencer tire clutch but in a different configuration. The author added some 3/8-inch plate to the tire rim for weight, and added several attachment points so the stroke can be adjusted.

A clutch player in the knifemaker’s shop, the tire hammer gives more control than other D.I.Y. power hammers.

Like a variable-speed hand drill, your backyard power hammer should be able to run slowly, at full speed or in between, depending on the task. The simplest way to guarantee it does this is to use a slipping clutch.

There are two main designs of slipping clutch. One uses a slack belt, a flywheel and pulleys. The drive pulley rotates within a slack belt. The foot pedal linkage pushes an idler wheel into the slack belt, increasing the belt tension to the point that the belt begins to turn the pulley on the flywheel.

spring-arm-to-pitman attachment
The author modified the spring-arm-to-pitman attachment to make it adjustable. Depending on which attachment point is used, the leverage of the stroke changes.

Another design uses a tire clutch, where the foot pedal linkage pushes a drive wheel into an automobile tire, with the hub of the tire serving as the flywheel. The most common “tire hammer” design uses a similar clutch but turned the other way and connected to a linkage. Your available parts will dictate your design. 

Why A Clutch

A function of the clutch is to reduce the RPM of the motor speed to get the hammer rate of beats per minute (BPM) into a safe and useful range. You want the hammer rate to generally end up between 150 and 250 BPM, though many variables change with each hammer. In general, a heavier tup (aka hammer head assembly) requires a slower BPM, whereas a lighter hammer can have a higher BPM. You do not want your hammer running faster than you can control it, nor so fast that the inherent forces tear it apart. My hammer uses a 24-inch tire and a 3-inch drive wheel for an 8:1 reduction of a 1750 RPM motor, yielding a calculated 218 BPM at full speed. Your hammer will run differently depending on your motor RPM, your drive and driven wheel diameters, and the hammer’s overall design. I rarely run my hammer full speed during general forging work, and the tire clutch gives good speed control. Full speed works acceptably well for drawing out damascus billets or breaking down large stock.

My tire clutch has an integral flywheel bolted to the hub. On the flywheel I welded several different nuts for attaching the pitman arm (for more on the pitman arm, see part three last issue). Each nut is a different distance from the center of the hub. This allows me to vary the length of the stroke, in my case between 6.5, 7 and 7.5 inches, based on where I connect the arm to the flywheel. Coupled with an adjustable-length pitman arm, this setup allows a degree of tuning to get the hammer hitting in a way that transfers the power directly to the workpiece with efficiency, yet in a way that doesn’t place undue stress on the hammer itself.

Choosing A Motor For Your Tire Hammer

As for motors, the size may vary a bit depending on the overall tup weight of your hammer. For most homebuilt hammer sizes, a 1 or 1.5 HP motor is plenty. My 40-pound hammer uses a 1.5 HP motor running on 110v and does not trip a standard 15-amp breaker, suggesting that 1.5 HP is more than plenty for a 40-pound head. Whether the motor runs on 110v or 220v will depend on your shop setup and what you have available, but you’d be best served either way with a motor that runs in the 1700 RPM range, not one that runs in the 3400 RPM range. There’s no need to go three phase or variable speed unless you’re already set up for either.

Doug Davis’ homemade hammer
Doug Davis’ homemade hammer uses a series of pulleys and an idler. When you step on the treadle, the idler tightens the belt and engages the hammer.

You will need an on/off switch for your motor. To run the hammer, turn the motor on, then use the foot pedal linkage to engage the clutch.

Sourcing Dies

Most power hammers have a set of dies in between the anvil and the hammer shaft. Dies may be built in a variety of shapes and sizes, depending on how you want your hammer to move the metal. Two basic die designs are flat and crowned. Flat dies move the metal somewhat equally in all four directions, while crowned dies will draw out the length of your workpiece perpendicular to the crown on the dies. Some smiths design their hammers to accommodate various top or bottom tools, or spring swages as well.

Tire Hammer Die Attachment
The die attachment on Doug Davis’ power hammer is more robust on the ram-to-die connection, but time will tell how the bottom-die direct-weld works out. (Erik Greiner image)

On my personal hammer, the dies are built out of 1.5-inch square 4140 steel bar stock, heat treated and ground essentially flat, with slightly radiused corners. Some hammers are set up with dies that are interchangeable but mine is not. Full disclosure: My die attachment is one point of weakness in my design. I ultimately welded my bottom die plate straight to the anvil, and I’ve had to reinforce the top die connection and re-weld it several times. Perhaps a more skilled welder could have done better!

Creative Necessity

I can’t emphasize enough the creativity necessary to build a functioning power hammer from scrap. It’s one thing to watch a YouTube video and think, “It must be nice to have a power hammer.” It’s another thing entirely to watch the same video and try to discern how the rocker arm connects to the center post, or how the tire clutch axle is set up.

At the time of my hammer build, there was an online gallery hosted in Czechoslovakia that had hundreds of pictures of various homebuilt and factory built hammers. I couldn’t have built mine without those examples. I don’t speak Czech but the pictures tell the story well.

Read More On Power Hammers:


Download BLADE's Knife Guide Issue!NEXT STEP: Download Your Free KNIFE GUIDE Issue of BLADE Magazine

BLADE’s annual Knife Guide Issue features the newest knives and sharpeners, plus knife and axe reviews, knife sheaths, kit knives and a Knife Industry Directory.

Get your FREE digital PDF instant download of the annual Knife Guide. No, really!

We will email it to you right now when you subscribe to the BLADE email newsletter.

BLADE Magazine

The Most Prolific Guns Ever Made, By The Numbers

https://www.alloutdoor.com/wp-content/uploads/2024/01/HK-G3.jpg

The Small Arms Survey estimates that, as of 2018, there are over one billion guns in circulation. A significant majority – around 85% – rest in the hands of the civilians, leaving about 133 million to military stores and 23 million for law enforcement agencies. That ten-digit figure grew by around 200 million in just a single decade, and the number in 2024 is likely to be even higher. After all, more than 7 million Americans became gun owners during the Pandemic alone. But which of those billion guns is the most popular or prolific guns in circulation? Many of the firearms contributing to that striking figure are archaic: World War and conflict relics, many of which were manufactured decades ago. Here are the top ten most prolific guns ever made, by the numbers. You have any preemptive guesses to what are the most prolific guns in history?…

Gun Coverage on AllOutdoor

#10 – Prolific Guns – Heckler & Koch G3

The Top 10 Most Prolific Guns Ever Made, By The Numbers

  • Number Produced: ~7.8 million
  • First Manufactured: 1959
  • Country: Germany
  • Caliber: 7.62×51 NATO

Sharing a contended title with the FN FAL as the “most successful battle rifle ever made,” the Heckler & Koch-produced G3 has seen service with over 70 countries’ militaries, with at least 15 of those nations manufacturing the rifle under license. The G3 remained the official rifle of the German armed forces until it was replaced by the G36 in the 90s. Some may claim the G3 is not deserving of this spot: They say other guns, like Russia’s Makarov, Japan’s Arisakas, Israel’s Uzis, and America’s M1 Garand were produced in greater numbers. But the production estimates of those and other guns that might fit here are poorly recorded, with figures attributed to secondhand accounts or otherwise lacking manufacturers’ citations. The Germans, however, are quite good at keeping numbers. Per a report from the Armament Research Services (ARES) in 2015, Heckler & Koch affirmed production of the G3 exceeds 7.8 million units; this is often rounded up to 8 million. The G3 is still produced, too, ensuring that – if it hadn’t already – it will exceed production numbers of those contested guns.

#9 – Prolific Guns – Marlin Model 60

The Top 10 Most Prolific Guns Ever Made, By The Numbers

  • Number Produced: ~11 million
  • First Manufactured: 1960
  • Country: U.S.
  • Caliber: .22 LR

If you’re an American who grew up in the 20th century, chances are high your first experience with a firearm involved shooting at cans with some .22 LR fired from a Marlin Model 60. Based on the defunct Marin Model 99, designed by Marlin engineer Ewald Nichol in 1959, the Model 60 became the most successful rimfire rifle ever sold to the American public, with approximately 11 million units sold – a figured collated by Walt Kuleck and Scott A. duff, author and publisher of of The Ruger 10/22 Complete Owner’s and Assembly Guide, respectively.

Its bull barrel contained a then-new “Micro Groove” technology introduced by Marlin a few years earlier. This rifling used 16 shallower lands and grooves – as opposed to the typical 5 deep grooves in competing barrels – to provide stabilization of the round while imparting less deformation upon it, resulting in greater accuracy. Coupled with factory taps for bolt-on scopes, the Marlin 60 became a top choice for varmint hunters. Although its manufacture ceased in 2020, the Model 60’s production numbers still eclipse that of its modern replacement, the Ruger 10/22.

#8 – Prolific Guns – Remington 870

The Top 10 Most Prolific Guns Ever Made, By The Numbers

  • Number Produced: 11+ million
  • First Manufactured: 1951
  • Country: U.S.
  • Caliber: Varies

The Model 870, produced by Remington and favored as the pump shotgun of choice by militaries and police departments globally, was made to replace the expensive and handcrafted Remington Model 31, designed by John Moses Browning in 1931. The Model 31 was produced to compete with the Winchester Model 1912 which was, at the time, the most popular shotgun sold on the civilian market. The M12 designation also served as a trench gun for the U.S Army, Navy, and Marine Corps in World Wars I and II.

After its debut in 1951, the Model 870 quickly became a commercial success and sold more than two million units by 1973, eclipsing all sales of the Model 31. A decade later, the Model 870 became the most sold shotgun in history, reaching 3 million units. The 870’s popularity again surged in 1996 with the introduction of its Express variant, an economy model that brought total sales up to 7 million units. Just over a decade later – on April 13, 2009 – Remington celebrated production of the ten millionth 870. With at least twelve factory variants available – and dozens more retailer-built configurations dotting store and digital shelves – for applications ranging from competition and self-defense to hunting, law enforcement, maritime and military use, the Remington 870 remains an affordable, utterly reliable everyman’s gun that can satisfy just about every shooting niche.

#7 – Prolific Guns – Mossberg 500

The Top 10 Most Prolific Guns Ever Made, By The Numbers

  • Number Produced: 12+ million
  • First Manufactured: 1961
  • Country: U.S.
  • Caliber: Varies

Trailing its direct competitor by a decade, the Mossberg 500 is to the Remington 870 what Coke is to Pepsi, or Ford to Chevy: A nearly identical peer in form and function, commanding as much popularity and proliferation as its counterpart – a statement certain to sound reductive and which will certainly rustle the feathers of staunch fans of either camp. But it’s true. The Mossberg 500 is, like the Model 870, one of the most popular shotguns ever produced, with O.F. Mossberg & Son declaring over 12 million variants have rolled off its factory floors. Though lighter and cheaper than its competitor – the 500 uses an aluminum receiver and some more plastic bits than the 870 – it is practically indecipherable from Remington’s gun at a glance, and police and military rely on the Mossberg as much as the Remington.

But unlike its peer, the Mossberg was made initially for military use only. It wasn’t until 1987 – 26 years after its initial manufacture – that Mossberg sold the 500 to the public and instead designed a newer variant, the M590, as the gun for uniformed use (though the 500 continued military service, too, as the M500). The 590A1 became the standard-issue shotgun for the United States Military and saw its first combat use in the 1991 Gulf War.

#6 – Prolific Guns – SKS

The Top 10 Most Prolific Guns Ever Made, By The Numbers

  • Number Produced: ~15 million
  • First Manufactured: 1945
  • Country: USSR
  • Caliber: 7.62x39mm

With an estimation of 15 million units produced – per data collated by Janes author and firearm historian Ian Hogg – The Samozaryadny Karabin sistemy Simonova, or SKS, became the most widely produced semiautomatic battle rifle, perhaps ever. Designed between 1941 and 1944 and first manufactured in 1945, the SKS was the Soviets’ answer to the Germans’ G43 and the Americans’ M1 rifles. Mechanically, the SKS was immediately inferior to those rifles and to its own Soviet counterpart, the SVT-40. While other semiautomatic battle rifles had detachable magazines, the SKS relied on an integral box magazine fed by stripped clips, limiting its reload speed and capping capacity at just 10 rounds. Some variants of the SKS also lacked a detention spring on the firing pin. The pin was instead allow to float inside the bolt – meaning that a forceful drop could slam the pin into the primer on a loaded round, allowing for potential slam fires.

The SKS was also rendered obsolete by its own nation with the production of the AK-47 just a decade later. But in spite of its limitations (and its short life in the limelight before being overshadowed by the AK-47) its simple, cheap design made it a favorable weapon for licensed production in China and dozens of other countries in the mid-20th century. Between 1988 and 1993, millions of Chinese and Russian SKS rifles were imported to the U.S. At publication, they’re still readily available on the secondhand market for between $600 and $2500, depending on condition and rarity.

#5 – Prolific Guns – Lee-Enfield

The Top 10 Most Prolific Guns Ever Made, By The Numbers

  • Number Produced: ~17 million
  • First Manufactured: 1895
  • Country: Britain
  • Caliber: .303 British

One of the first repeating rifles to use smokeless powder, the Lee-Enfield was Britain’s response to the Germans’ then-new Gewehr 88, a bolt-action rifle that also relied on smokeless powder and smaller 8mm rounds to obtain higher velocity and accuracy. A direct descendant of the Lee-Metford rifle, the Lee-Enfield’s new cartridge and detachable, 10-round box magazine provided British troops with significant advantages over opposing forces, many of which still relied on rifles fed by integrated magazines with lower capacities. The Lee-Enfield’s high capacity and reliability made it capable of providing some of the fastest rates of fire possible with a bolt action. Though citations are questionable, anecdotes from World War One include reports from German soldiers who claim they thought they’d encountered machine gunfire, when they had merely been fired upon by groups of British marksmen using Lee-Enfield rifles. The Lee-Enfield remained in service with the British military until the 1990s, when the sniper variant (the L42A1) was retired. But the rifle remains in service with some militaries and law enforcement organizations today – including the Bangladesh Police – making it one of the longest-serving rifles in existence.

#4 – Prolific Guns – AR-15/M4/M16 (and GLOCK)

The Top 10 Most Prolific Guns Ever Made, By The Numbers

  • Number Produced: ~20 million
  • First Manufactured: 1959 (AR-15), 1982 (GLOCK)
  • Country: U.S. (AR-15), Austria (GLOCK)
  • Caliber: Varies (both)

The AR-15

Two of the most popular modern firearms ever made share the next spot on this list. With over 20 million units sold, the AR-15 and GLOCK – and their endless variants – tie for the 4th most widely produced gun(s) in history. Originally developed by Eugene Stoner for ArmaLite in 1956, the AR-15 would first serve as an automatic rifle issued to U.S service members in the Vietnam War. ArmaLite sold the design to Colt in 1959; shortly after, the rifle would receive the M16 designation and be fielded by troops in 1963. Colt later introduced the semiautomatic variant of the M16 for civilian purchase, retaining the AR-15 namesake.

when Colt’s patent on the design expired in the 1970s, other manufacturers began producing AR-15 rifles. The rifle enjoyed widespread adoption and favorable review for its lightweight profile, simplicity, and good accuracy with little recoil thanks to its small, fast 5.56 NATO and .223 Remington loads. But the AR-15 would only become a rifle with a nearly occult following after it was thrust into the political theater. When the Assault Weapon Ban of 1994 expired in 2004, sales of the AR-15 exploded – as did the political commentary surrounding its legality and civilian ownership.

The GLOCK

Designed by Gaston Glock in Austria, the GLOCK handgun is, today, the most popular handgun manufactured and solid. The GLOCK was designed for the Austrian forces, earning its first contracts for military and police service in 1982 after becoming the favorite in field testing. The GLOCK beat competing designs from five manufacturers: H&K’s P7M and P9S; Sig’s P220 and P226; Beretta’s 92SB-F; an FN prototype based on the Browning Hi-Power; and the Steyr GB. Notably, Gaston Glock had no experience as a weapon designer. He was only an expert on synthetic polymers, but endeavored to use the material to produce a lightweight alternative to the steel and aluminum frames all handguns then relied upon. Glock assembled a team of firearm experts to compile the most desirable characteristics of a combat pistol to develop his first handgun. Friedrich Dechant, former Head of the Austrian Armaments and Defence Technology Agency, remarked on observing the GLOCK’s clear superiority over competing pistols. Today, GLOCK produces over 50 pistols of varying sizes and calibers, and it remains in service with thousands of police and military organizations globally.

#3 – Prolific Guns – Mosin-Nagant Rifle

The Top 10 Most Prolific Guns Ever Made, By The Numbers

  • Number Produced: ~37 million
  • First Manufactured: 1891
  • Country: Russia
  • Caliber: 7.62x54R

Holding the title as the longest-serving military rifle in existence, the Mosin-Nagant is one of the most recognizable bolt actions ever made. For collectors, the Mosin is usually the first “old war” gun to purchase. Just a decade ago, one could attend any public gun show and find the ever-present crates of Mosin rifles filled with M91/30s and M44s for less than $100 a piece. The Mosin-Nagant was designed to replace the Soviet empire’s aging stock of single-shot rifles, which contributed to heavy losses at the hands of the Ottoman Empire, whose troops were equipped with Winchester repeating rifles. In response, the Russian Ministry of Defense procured and tested the Lebel Model 1886, a French bolt action rifle, to spur development of what was officially called the 3-line rifle, M1891; the “3-line” refers to the Soviet rifle’s .30 caliber round. The Mosin also introduced the 7.62x54R cartridge, a round that became one of the most prolific machine gun cartridges ever fielded.

Although early Mosin rifles were finicky and suffered poor quality control, the M1891/30 – the “91/30” commonly available for sale on civilian marketplaces today – modernized the original design to improve feeding and disassembly. Since its widespread use by the Soviets in World Wars I and II, the Mosin-Nagant and its variants have traveled the globe, been used in more conflicts than any other bolt-action rifle – including present conflicts in the Middle East – and seen adoption by more than 40 countries.

#2 – Prolific Guns – Mauser 98

The Top 10 Most Prolific Guns Ever Made, By The Numbers

  • Number Produced: ~100 million
  • First Manufactured: 1898
  • Country: Germany
  • Caliber: M/88, 7.92x57mm

In spite of its relatively short lifespan – the rifle and its variants were only produced in large numbers between 1895 and 1945 – the Mauser Gewehr 98 (including rifles like the Karabiner 98k) remains the second most produced firearm in existence, with estimates placing total production north of 100 million guns. After initial delivery in 1898, the Mauser 98 saw immediate action during the Boxer Rebellion in the hands of German troops at Peking. By World War I, Germany had already produced nearly 2.3 million rifles; it would make an additional 7 million before the war ended. Originally chambered in M/88 – a long defunct, early smokeless cartridge – the Mauser 98 adopted the now infamous 7.92x57mm in 1903, commonly called 8mm Mauser.

The Mauser 98 also introduced the controlled feed method of cycling: the base of the shell casing is gripped by the bolt’s extractor claw before it’s stripped from the magazine and chambered; prior bolt action rifles relied on a simpler and less reliable “push feed” system, which relied on simple inertia and blunt contact to drive rounds into the chamber via the bolt face. The controlled feed system is relied upon to this day by all modern firearms that use conventional bolts and bolt carriers, and is regarded by many as one of the most important developments in modern rifle design. Although manufacture of the original 98 rifle ceased with Germany’s demise at the end of World War II, the rifle’s popularity spurred Mauser Jagdwaffen GmbH to resume production of 98 actions and rifles for civilian use in 1999. Modern iterations of the Mauser M98 are considered top-shelf safari guns, with big game models chambered in .30-06, .375, and .416 demanding $13,000 USD or more at retail.

#1 – Prolific Guns – AK-47

The Top 10 Most Prolific Guns Ever Made, By The Numbers

  • Number Produced: ~150 million
  • First Manufactured: 1948
  • Country: USSR
  • Caliber: 7.62x39mm

The Avtomat Kalashnikova needs no introduction. You’re probably not even surprised it’s number one. It is, after all, the single-most recognizable firearm ever made and, arguably, a creation that has defined humanity and influenced modern life as much as the automobile, airplane, and the internet. Conservative estimates place historical production figures of the AK-47 at a “measly” 75 million. But with licensed manufacturing and cloning of the most famous rifle spanning dozens of countries for decades, the figure is likely closer to 150 million.

If current production of modern variants like the Yugoslavian M70, American PSAK-47, Romanian WASR-10, and the Kalashnikov-licensed KR-103 (alongside other endless makes) are considered as part of the tally, the number of AK-47s roaming the planet is likely to climb in perpetuity. Even if the AK-47 were to disappear from all civilian markets, it would remain the most prolific firearm ever, as it continues to be the standard infantry rifle for 106 nations’ militaries. Speaking of AKs – Palmetto’s PSAK-47s ditch the archaic 7.62×39 in favor of decidedly superior cartridges, like 6.5 Grendel and 300 Blackout. Check ’em out here.

The post The Most Prolific Guns Ever Made, By The Numbers appeared first on AllOutdoor.com.

AllOutdoor.com

Newly updated Laravel Chart.js Package

https://opengraph.githubassets.com/9e1417cda6be8de3b732d6f87a48dfaa325b403c9cc0e961ddac0a1330482fb5/icehouse-ventures/laravel-chartjs

laravel-chartjs – A Chart.js wrapper for Laravel

Simple package to facilitate and automate the use of charts in Laravel
using the Chart.js library.

Setup:

This package provides a wrapper for Chartjs that allows it to be used simply and easily inside a Laravel application. The package supports a number of installation methods depending on your needs and familiarity with JavaScript.

1. Installing this package

composer require icehouse-ventures/laravel-chartjs

For older versions of Laravel (8 and below), add the Service Provider in your file config/app.php:

IcehouseVentures\LaravelChartjs\Providers\ChartjsServiceProvider::class

Publishing the config file to your own application will allow you to customise the package with several settings such as the Chartjs version to be used and the delivery method for the Chartjs files.

php artisan vendor:publish --provider="IcehouseVentures\LaravelChartjs\Providers\ChartjsServiceProvider" --tag="config"

2. Installing Chartjs

Next, you can install and add to your layouts / templates the Chartjs library that can be easily found for download at: http://www.chartjs.org

There are several installation options for Chartjs. By default, this package comes set to use the ‘custom’ self-managed delivery method (to avoid conflict with existing installations). You can also select from several other delivery methods:

CDN

For rapid development and testing between versions, you can easily set the delivery method to ‘CDN’ in the config\chartjs.php settings, this will load the specified Chartjs files via an external content delivery network. Chartjs versions 2, 3 and 4 are available by CDN. These also load Moment.js and Numeral.js which are commonly needed for business charts.

Publish

If you do not use JavaScript packages anywhere else in your application or are new to JavaScript development then you may not already have the Node Package Manager, Laravel Mix or Vite set up. In that case, this package includes pre-compiled versions of Chartjs that you can use in your application. To publish the chart.js binary to your application’s public folder (where JavaScript bundles are stored) you can publish the package’s pre-built distribution assets.

By default, the publish method will install Chartjs version 4 using the latest binary in the package. If you want to publish an older version, we have also included the latest stable Chartjs releases for version 3 and version 2. You can publish these to your public assets folder using the following commands:

// Publish Chartjs version 4 assets
php artisan vendor:publish --provider="IcehouseVentures\LaravelChartjs\Providers\ChartjsServiceProvider" --force --tag="assets"

// Publish Chartjs version 3 assets 
php artisan vendor:publish --provider="IcehouseVentures\LaravelChartjs\Providers\ChartjsServiceProvider" --force --tag="assets-v3

// Publish Chartjs version 2 assets 
php artisan vendor:publish --provider="IcehouseVentures\LaravelChartjs\Providers\ChartjsServiceProvider" --force --tag="assets-v2"

Binary

In some rare circumstances such as local development without an internet connection, private applications, shared servers or where you cannot access the public folder on your server, then you may wish to have end-users directly load the binary files. This method is not recommended because it streams the contents of the files from inside your application. This delivery method will load the Chartjs files normally published to your assets folder directly from inside your vendor folder. To use this method, set the delivery config variable to ‘binary’ and choose the Chartjs version you wish to use in the config file.

NPM (Recommended)

The recommended method to install Chartjs in a web application is to include it in your normal JavaScript and/or CSS bundle pipeline using NPM, Laravel Mix or Vite. For instructions on this method of installation please visit: https://www.chartjs.org/docs/latest/getting-started/

Usage:

You can request to Service Container the service responsible for building the charts
and passing through fluent interface the chart settings.

$service = app()->chartjs
    ->name()
    ->type()
    ->size()
    ->labels()
    ->datasets()
    ->options();

The builder needs the name of the chart, the type of chart that can be anything that is supported by Chartjs and the other custom configurations like labels, datasets, size and options.

In the dataset interface you can pass any configuration and option to your chart.
All options available in Chartjs documentation are supported.
Just write the configuration with php array notations and it works!

Advanced Chartjs options

The basic options() method allows you to add simple key-value pair based options, but it is not possible to generate nested options such as those used to do complex formatting on scales (Chartjs v3 example):

    options: {
        scales: {
            x: {
                type: 'time',
                time: {
                    displayFormats: {
                        quarter: 'MMM YYYY'
                    }
                }
            }
        }
    }

Using the optionsRaw() method it’s possible to add nested Chartjs options in raw format (Chartjs v2 example):

Passing string format like a json

        $chart->optionsRaw("{
 legend: {
 display:false
 },
 scales: {
 xAxes: [{
 gridLines: {
 display:false
 } 
 }]
 }
 }");

Or, if you prefer, you can pass a php array format and the package will convert it to the JSON format used by Chartjs:

$chart->optionsRaw([
    'legend' => [
        'display' => true,
        'labels' => [
            'fontColor' => '#000'
        ]
    ],
    'scales' => [
        'xAxes' => [
            [
                'stacked' => true,
                'gridLines' => [
                    'display' => true
                ]
            ]
        ]
    ]
]);

Examples

1 – Line Chart / Radar Chart:

// ExampleController.php

$chartjs = app()->chartjs
        ->name('lineChartTest')
        ->type('line')
        ->size(['width' => 400, 'height' => 200])
        ->labels(['January', 'February', 'March', 'April', 'May', 'June', 'July'])
        ->datasets([
            [
                "label" => "My First dataset",
                'backgroundColor' => "rgba(38, 185, 154, 0.31)",
                'borderColor' => "rgba(38, 185, 154, 0.7)",
                "pointBorderColor" => "rgba(38, 185, 154, 0.7)",
                "pointBackgroundColor" => "rgba(38, 185, 154, 0.7)",
                "pointHoverBackgroundColor" => "#fff",
                "pointHoverBorderColor" => "rgba(220,220,220,1)",
                'data' => [65, 59, 80, 81, 56, 55, 40],
            ],
            [
                "label" => "My Second dataset",
                'backgroundColor' => "rgba(38, 185, 154, 0.31)",
                'borderColor' => "rgba(38, 185, 154, 0.7)",
                "pointBorderColor" => "rgba(38, 185, 154, 0.7)",
                "pointBackgroundColor" => "rgba(38, 185, 154, 0.7)",
                "pointHoverBackgroundColor" => "#fff",
                "pointHoverBorderColor" => "rgba(220,220,220,1)",
                'data' => [12, 33, 44, 44, 55, 23, 40],
            ]
        ])
        ->options([]);

return view('example', compact('chartjs'));


 // example.blade.php

<div style="width:75%;">
    {!! $chartjs->render() !!}
</div>

2 – Bar Chart:

// ExampleController.php

$chartjs = app()->chartjs
         ->name('barChartTest')
         ->type('bar')
         ->size(['width' => 400, 'height' => 200])
         ->labels(['Label x', 'Label y'])
         ->datasets([
             [
                 "label" => "My First dataset",
                 'backgroundColor' => ['rgba(255, 99, 132, 0.2)', 'rgba(54, 162, 235, 0.2)'],
                 'data' => [69, 59]
             ],
             [
                 "label" => "My First dataset",
                 'backgroundColor' => ['rgba(255, 99, 132, 0.3)', 'rgba(54, 162, 235, 0.3)'],
                 'data' => [65, 12]
             ]
         ])
         ->options([]);

return view('example', compact('chartjs'));


 // example.blade.php

<div style="width:75%;">
    {!! $chartjs->render() !!}
</div>

3 – Pie Chart / Doughnut Chart:

// ExampleController.php

$chartjs = app()->chartjs
        ->name('pieChartTest')
        ->type('pie')
        ->size(['width' => 400, 'height' => 200])
        ->labels(['Label x', 'Label y'])
        ->datasets([
            [
                'backgroundColor' => ['#FF6384', '#36A2EB'],
                'hoverBackgroundColor' => ['#FF6384', '#36A2EB'],
                'data' => [69, 59]
            ]
        ])
        ->options([]);

return view('example', compact('chartjs'));


 // example.blade.php

<div style="width:75%;">
    {!! $chartjs->render() !!}
</div>

Advanced custom views

If you want to customise the appearance of all charts in your application (for example tweaking the mobile responsive css settings), then it is recommended to create a standard blade component and insert the {!! $chartjs->render() !!} reference inside your custom component (be sure to pass down the variable from your controller to your component). If for some reason need to edit the core blade template (for example to adjust the CDN logic or make deeper CSS changes to the canvas styling), then you can publish the blade template to your resources\vendor\laravelchartjs folder and edit the custom-chart-template.blade.php

To activate the custom blade template changes you can set the config option ‘custom_view’ to true.

php artisan vendor:publish --provider="IcehouseVentures\LaravelChartjs\Providers\ChartjsServiceProvider" --tag="views" --force

Issues

This README, as well as the package, is in development, but will be constantly updated, and we will keep you informed. Any questions or suggestions preferably open a discussion first before creating an issue.

License

LaravelChartjs is open-sourced software licensed under the MIT license.

Provenance

Some of the original logic for this package was originally developed by Brian Faust. The main package from which this current version of the package is forked was primarily developed and maintained by Felix Costa. In 2024 the package was adopted by Icehouse Ventures which is an early-stage venture capital firm based in New Zealand. We use Chartjs heavily in our Laravel applications and want to give back to the Laravel community by making Chartjs fast and easy to implement across all major versions and to streamline the upgrade path.

Laravel News Links

How to Call an External API Using Laravel (With Example)

https://laracoding.com/wp-content/uploads/2023/12/laravel-call-external-api.png

In this tutorial, we’ll create a Laravel application that interacts with an external API to fetch and display a paginated list of posts. We’ll also implement buttons that trigger delete and update calls to the external API. Calling external APIs allow us to integrate with any third parties that exposes their functionality accordingly.

Note the data will be fetched externally but the updates and deletes will be simulated since the test API (jsonplaceholder.typicode.com) we’re using is read-only.

We will be using the Laravel built-in Http facade to send the API calls. While you could also use Guzzle to do this, using the Http facade is the recommended way to go about it. Using the Http facade offers a concise syntax that is in line with Laravel and adds more features like mocking HTTP responses for automated testing.

Let’s get started!

Step 1: Set Up Your Laravel Project

Create a new Laravel project or use an existing one:

laravel new blog-cms
cd blog-cms

Step 2: Create Controller

Create a controller by running:

php artisan make:controller PostController

Step 3: Add Controller Code

Now let’s add code to the PostController to implement methods to show, update, and delete posts by triggering calls to the external posts API:

app/Http/Controllers/PostController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;

class PostController extends Controller
{
 public function index()
 {
 $response = Http::get('https://jsonplaceholder.typicode.com/posts');
 $posts = $response->json();

 return view('posts.index', ['posts' => $posts]);
 }

 public function edit($id)
 {
 $response = Http::get('https://jsonplaceholder.typicode.com/posts/' . $id);
 $post = $response->json();

 return view('posts.edit', ['post' => $post]);
 }

 public function update(Request $request, $id)
 {
 // Simulates update logic for a real application (not supported by this API)
 $response = Http::put('https://jsonplaceholder.typicode.com/posts/' . $id, [
 'title' => $request->input('title'),
 'body' => $request->input('body'),
 ]);

 // Simulated response for successful or failed update
 if ($response->successful()) {
 return redirect()->route('posts.index')->with('success', 'Post updated successfully!');
 } else {
 return redirect()->route('posts.index')->with('error', 'Failed to update post. Please try again.');
 }
 }

 public function destroy($id)
 {
 // Simulates deletion logic for a real application (not supported by this API)
 $response = Http::delete('https://jsonplaceholder.typicode.com/posts/' . $id);

 // Simulated response for successful or failed deletion
 if ($response->successful()) {
 return redirect()->route('posts.index')->with('success', 'Post deleted successfully!');
 } else {
 return redirect()->route('posts.index')->with('error', 'Failed to delete post. Please try again.');
 }
 }
}

Step 4: Define Routes

Define routes for post actions in routes/web.php as follows:

routes/web.php

use App\Http\Controllers\PostController;

Route::get('/', [PostController::class, 'index'])->name('posts.index');
Route::get('/posts/{id}/edit', [PostController::class, 'edit'])->name('posts.edit');
Route::put('/posts/{id}', [PostController::class, 'update'])->name('posts.update');
Route::delete('/posts/{id}', [PostController::class, 'destroy'])->name('posts.destroy');

Step 5: Create a Base Layout

Let’s use a simple layout that is based on bootstrap 5 that can show any content along with any success or error message that may occur. Create a file resources/views/layouts/app.blade.php and add:

resources/views/layouts/app.blade.php

<!DOCTYPE html>
<html lang="en">
<head>
 <!-- Other meta tags -->
 <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
 <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.css" rel="stylesheet">
 <!-- Other CSS -->
</head>
<body>

 <div class="container mt-4">

 <!-- Display success or error messages -->
 @if (session('success'))
 <div class="alert alert-success">
 
 </div>
 @endif

 @if (session('error'))
 <div class="alert alert-danger">
 
 </div>
 @endif

 @yield('content')

 </div>
</body>
</html>

Step 6: Create a View to Show Posts From API

Generate a Blade view to display the paginated list of posts. Create a file resources/views/posts/index.blade.php and add:

resources/views/posts/index.blade.php

@extends('layouts.app')

@section('content')
 <div class="container mt-4">
 <h1>Posts</h1>
 <div class="table-responsive mt-3">
 <table class="table table-striped">
 <thead>
 <tr>
 <th>Title</th>
 <th>Body</th>
 <th>Actions</th>
 </tr>
 </thead>
 <tbody>
 @foreach($posts as $post)
 <tr>
 <td></td>
 <td></td>
 <td>
 <div class="d-flex">
 <a href="" class="btn btn-sm btn-primary me-2">
 <i class="bi bi-pencil"></i>
 </a>
 <form action="" method="POST">
 @csrf
 @method('DELETE')
 <button type="submit" class="btn btn-sm btn-danger">
 <i class="bi bi-trash"></i>
 </button>
 </form>
 </div>
 </td>
 </tr>
 @endforeach
 </tbody>
 </table>
 </div>
 </div>
@endsection

Step 7: Create Blade View for Edit Post From API

Create a Blade view for the post edit form in resources/views/posts/edit.blade.php. Include the form with populated data, the correct action/route, and @csrf:

resources/views/edit.blade.php

@extends('layouts.app')

@section('content')
 <div class="container mt-4">
 <h1>Edit Post</h1>
 <form action="" method="POST">
 @csrf
 @method('PUT')
 <div class="mb-3">
 <label for="title" class="form-label">Title</label>
 <input type="text" class="form-control" id="title" name="title" value="">
 </div>
 <div class="mb-3">
 <label for="body" class="form-label">Body</label>
 <textarea class="form-control" id="body" name="body"></textarea>
 </div>
 <button type="submit" class="btn btn-primary">Update</button>
 </form>
 </div>
@endsection

Step 8: Test the Application

Run your Laravel server using php artisan serve and navigate to http://localhost:8000 in your browser. You’ll have a paginated list of posts with functional delete and edit buttons, and an edit form ready for updates.

Note: The buttons will work to show edit form and trigger updates as well as deletes calls to the external API. However, the data in the API will not actually change since it is a public read-only API made for testing purposes.

Screenshot Showing Posts as Retrieved From The External API
Screenshot Showing a Form to Edit a Single Post as Retrieved From The External API

Conclusion

Good job! You’ve successfully created a Laravel application that fetches and displays posts from an external API. You’ve also added buttons to delete posts and update by sending the respective API calls from your controller. I’ve also covered some basic error handling that redirects with either a success or an error message whichever applies.

While the placeholder API I showed here is read-only and the edits and deletes have no effect on the data, the principle is the same for a real API.

With this knowledge you can go ahead and start integrating real-world REST API’s into your Laravel application. Happy coding!

References:

Laravel News Links

Discontinued and unreleased Microsoft peripherals revived by licensing deal

https://cdn.arstechnica.net/wp-content/uploads/2024/01/71V3DbiEJfL._AC_SL1500_-760×380.jpg

Microsoft Ergonomic Keyboard

Enlarge / The Microsoft Ergonomic Keyboard is making a comeback.

Microsoft

In April, Microsoft announced that it would stop selling Microsoft-branded computer peripherals. Today, Onward Brands announced that it’s giving those discarded Microsoft-stamped gadgets a second life under new branding. Products like the Microsoft Ergonomic Keyboard will become Incase products with "Designed by Microsoft" branding.

Beyond the computer accessories saying "Designed by Microsoft," they should be the same keyboards, mice, webcams, headsets, and speakers, Onward, Incase’s parent company, said, per The Verge. Onward said its Incase brand will bring back 23 Microsoft-designed products in 2024 and hopes for availability to start in Q2.

Some of the Microsoft-designed gear that Incase is relaunching.

Enlarge / Some of the Microsoft-designed gear that Incase is relaunching.

Incase also plans to launch an ergonomic keyboard that Microsoft designed but never released. Onward CEO Charlie Tebele told The Verge that there’s "potential" for Incase to release even more designs Microsoft never let us see.

Licensing deal

The return of Microsoft peripheral designs resurrects (albeit in a new form) a line of computer gear started in 1983 when Microsoft released its first mouse, the Microsoft Mouse.

Neither Onward nor Microsoft shared the full terms of their licensing agreement, but Onward claims that Incase will leverage the same supply chain and manufacturing components that Microsoft did, The Verge noted.

"Microsoft will still retain ownership of its designs, so it could potentially bring back classic mice or keyboards itself in the future or continue to renew its license to Incase," The Verge reported, pointing out that Onward isn’t licensing every single one of Microsoft’s computer peripherals. Some classics, like the Intellimouse or its modern iterations, for example, don’t make the Incase reboot list.

For its part, Microsoft is still "convicted on going under one single" Surface brand, Nancie Gaskill, general manager of Surface, told The Verge.

That said, in Microsoft’s old designs, Incase, whose website is currently filled with backpacks, bags, and laptop and AirPod cases, suddenly finds itself selling keyboards, mice, and other peripherals. Onward’s other brands, Griffin, Incipio, and Survivor, also don’t sell the types of products that Incase is licensing here. If all goes well, Incase could build its own computer accessories portfolio.

Microsoft’s initial departure from Microsoft-brand peripherals meant it would only focus on more expensive, higher-end designs worthy of Surface branding. But that left a gap for the numerous users who felt satisfied with Microsoft’s various designs that were simpler and more affordable. Incase’s venture could help serve those customers, while Microsoft’s legacy with such products can continue without major investment from the tech giant.

Here’s a full list of the Microsoft-designed peripherals that Incase plans to bring back in 2024:

Keyboards

  • Bluetooth Keyboard
  • Bluetooth Number Pad
  • Designer Compact Keyboard
  • Ergonomic Keyboard
  • Sculpt Comfort Desktop
  • Sculpt Ergonomic Desktop
  • Sculpt Ergonomic Keyboard
  • Wired Desktop 600
  • Wired Keyboard 600
  • Wireless Comfort Desktop 5050 AES
  • Wireless Desktop 850
  • Wireless Desktop 900

Mice

  • Bluetooth Ergonomic Mouse
  • Bluetooth Mouse
  • Mobile Mouse 1850
  • Modern Mobile Mouse
  • Sculpt Ergonomic Mouse

Audio

  • Audio Dock
  • Modern USB Headset
  • Modern USB-C Headset
  • Modern USB-C Speaker
  • Modern Webcam
  • Modern Wireless Headset

Ars Technica – All content

How Gaston Glock rocked the firearms world

 

The announcement of Gaston Glock’s death last week, at the age of 94, has brought forth a wave of obituaries and reminiscences about "the way things used to be" in the firearms industry.  Very few individuals can be said to have changed the way arms manufacturers designed, built and marketed their products.  Glock stands tall in the most illustrious of that group, including inventors such as John Moses Browning, Samuel Colt and Hiram Maxim.  He does so, not because he improved the technology in the market at the time, but because he drastically streamlined and improved the productivity of the industry.  Since then, no-one’s looked back.

Glock got into semi-auto pistol manufacturing in 1980 when by chance, he overheard two Austrian Army officers discussing the bidding process for a new service sidearm.  Initially rebuffed by the military powers that be, because he’d never built a firearm before and they presumed him to be ignorant, he took his case to the Austrian Minister of Defense and gained permission to compete for the Army’s handgun program.  He won the contest, and – over the next couple of decades – the worldwide handgun market as well.

"That I knew nothing [about guns] was my advantage," Mr. Glock said in an interview. He bought a number of handguns and disassembled them in his workshop, examining each component for its function while weighing potential improvements. He made prototypes and test-fired them with his left hand; if he was maimed by an explosion, he could still draw blueprints with his right. The product of his efforts was a nine-millimeter semi-automatic pistol that he designated the Glock 17 because it was his 17th invention.

Most notably, the frame of the new Glock pistol was built of industrial plastic, making it lighter and more resistant to corrosion than the conventional all-steel guns in use up to that time. The handgun’s various parts were housed in separate subgroups, making them easy to remove and replace. There was no safety or decocking lever to confuse the user. (The safety was built right into the trigger.) All told, the Glock 17 was a revolutionary new version of a weapon that had remained largely unchanged for a century.

There’s more at the link.

Glock was in the right place at the right time, with a thoroughly modern engineering approach to his work that defied older stereotypes.  While more "traditional" manufacturers made each of their successive models an improvement over their predecessor, never differing that much from their forebears, Glock was willing to ask every time, "Why should this be done like that?  Is there any good reason to uphold the status quo, or can we get rid of older, more time-consuming, more material-dependent processes and use modern engineering to come at the problem(s) in a completely new way?"  To everyone’s surprise, asking that question was the key to the handgun market;  and Glock made very sure to grab hold of that key and retain it as long as he possibly could.  Today, his firm dominates the handgun industry, with many clones of his designs available worldwide.

I liked the Glock from the first time I handled one.  It was lighter than most of its early competitors, and had far fewer parts (34 of them in most full-size Glocks).  That’s a major step forward in simplicity.  As one who’d seen combat in the worst terrain in Africa, where complex weapons systems tended to get chewed up and spat out by the surrounding landscape at the drop of a hat, I’d long been a believer in the old proverb, "Keep It Simple, Stupid!" (K.I.S.S.).  In my personal firearms today, I continue to maintain that perspective, which is why I own more Glocks than any other brand of pistol.  They may look and feel clunky compared to a race-tuned competition pistol, and lack all the little details that illustrate that a gun is a prized possession that’s been "tweaked" to express its owner’s pride of ownership;  but they’ve never let out a "Click" instead of a "Bang!" when failure was not an option.  That sort of reliability in a personal defense weapon is worth gold, and then some.

Well, Mr. Glock has now gone to his reward.  I wonder if he was met with an honor guard of Glock-toting angels at the Pearly Gates?  If ever a man deserved such an accolade, it’s him.

Peter

Bayou Renaissance Man

McMaster-Carr Impressed Me with an Email Update

https://i0.wp.com/toolguyd.com/blog/wp-content/uploads/2024/01/McMaster-Carr-Website-Screen-Capture-2024.jpg?resize=600%2C468&ssl=1

McMaster Carr Website Screen Capture 2024

McMaster-Carr is one of the best online suppliers, period.

I’ve ordered all kinds of tools, parts, and materials from McMaster-Carr over the years. While they are perhaps best known to engineers, fabricators, industrial professionals, and other such users, I’m sure they also cater to artists and all kinds of other people.

Looking back at my email history, I have been ordering from McMaster Carr for more than 17 years.

Not every experience has been perfect, but their excellent customer service is always quick to help.

There’s been one exception – I never succeeded in getting a printed catalog.

McMaster Carr Email Shipping Notification

I placed a new order the other day and received my shipping confirmation today via email.

With this shipping confirmation, I realized that McMaster is now highlighting what’s on the way.

The subject line reads:

Shipped: Dowel Pins, Shafts, and Socket Head Screws

The email more or less says the same, and includes a printable packing slip attachment and UPS tracking information:

We shipped the dowel pins, shafts, and socket head screws on your December 31st order. You will receive them tomorrow. Track your shipment using UPS [redacted]

It’s increasingly rare to see usability improvements like this.

Telling me that order 1234ABCDE has shipped with “2 items on the way” isn’t very helpful if it requires a couple of clicks to get more details.

In general, I feel that McMaster-Carr respects my time more so than a lot of other online suppliers.

When working on larger projects, I might place multiple McMaster orders over the course of a week or month. Highlighting the top parts of an order in the subject line is going to help me sort through order notifications more quickly.

This is a very minor change, but one that provides added convenience. That’s increasingly rare these days, as too often “improvements” end up making things less user friendly.

ToolGuyd

How Many Different Games of Tic-Tac-Toe Are There?

https://theawesomer.com/photos/2024/01/tic_tac_toe_t.jpg

How Many Different Games of Tic-Tac-Toe Are There?

Link

We assumed there were thousands of different ways that a game of tic-tac-toe could turn out. While the game board allows for more than 255,000 combinations of Xs and Os, there are far fewer gameplay outcomes. Musician and coder Marc Evanstein ran the numbers and argues there are only 14 different games to be played. (Thanks, Orion!)

The Awesomer