How Has the Hunting Rifle Evolved Over the Last 300 Years?

https://www.alloutdoor.com/wp-content/uploads/2023/03/How-Has-the-Hunting-Rifle-Evolved-Over-the-Last-300-Years-Img-1.jpg

Modern humans have been around for thousands of years, so guns are a relatively new tool. The first firearm goes back to around the 10th century in China, where fire lances used bamboo and gunpowder to launch spears. Now, there are numerous types of guns for various recreational uses, with hunting among the top activities. Rifles have been the gun of choice for hunters for nearly 300 years. How did the modern hunting rifle make it here?

1. Pennsylvania Rifle

Nowadays, the standard for hunting rifles centers around models like the current hunting rifle from Christensen Arms. But to understand rifles in 2023, you’ll have to go back to the early 1700s.

North America was growing with European settlers from England, France, Spain and more. Though, the Germans inspired the first rifle — the Pennsylvania rifle. This firearm was an upgrade over the musket because it had a much better range. The Pennsylvania rifle drew inspiration from jäger rifles used in German hunting, which started at around 54 inches long but could expand to over 6 feet.

2. Medad Hills’ Long Rifle

The Pennsylvania rifle — also known as the Kentucky rifle — was successful in the American colonies and led to similar models in the 18th century. For example, gunsmith Medad Hills crafted fowling pieces for hunting. Hills produced guns in Connecticut and helped hunters by creating long-barreled guns for increased accuracy. He later served in the Revolutionary War and made muskets for Connecticut in 1776.

3. Plains Rifles

After the Revolutionary War, rifle manufacturing began to take off in the United States, starting with the plains rifles. The new Americans began to expand westward and used plains rifles on the flat lands. Also known as the Hawken rifle, the plains rifle was shorter than its Pennsylvania predecessor but had a larger caliber, typically starting at .50. They were popular among hunters and trappers who needed to take down large animals from a distance.

4. Winchester 1876

A few decades later, the country broke out into a civil war. This era used military rifles from manufacturers like Springfield. However, it wasn’t until after the war that you’d see the hunting rifle that would inspire hunting rifles for decades.

Winchester was critical for late 19th-century rifles, starting with its 1876 model. This rifle was among the most high-powered yet for hunters. The Winchester 1876 was among the earliest repeaters and it had powerful capabilities with sizable ammunition — the intense bullets were necessary to take down large game like buffalo.

5. Winchester 1895

The success of the 1876 model led Winchester to create the 1895. This rifle was a repeater that featured smokeless rounds. Unlike its predecessors, the 1895 model was innovative because it included a box magazine below the action. It may be less powerful than models today, but it was incredibly potent for the time.

6. Winchester Model 70

Fast forward a bit to 1936. The country was in the Great Depression, but Winchester still produced excellent hunting rifles. Hunters called the Model 70 from Winchester the rifleman’s rifle, taking inspiration from Mauser, the German manufacturer. Winchester made the rifle with a controlled feed until 1964 before switching to a push feed and it still makes variations of the Model 70 today.

7. Marlin 336 (1948)

After World War II, Marlin introduced the 336 model as a successor to its 1893 rifle. It’s a lever-action rifle your grandfather may have owned to go deer hunting. Its specs may vary, but you’ll typically see it with a .30 or .35 caliber. The barrel can be as short as 20 inches or extend to 24 inches long. Marlin no longer makes the 336, but, Ruger — who purchased Marlin — plans to bring it back in 2023.

8. Remington 700 (1962)

1962 saw what could be the best hunting rifle ever made — the Remington Model 700. This rifle is the most popular bolt-action firearm, with over five million sold since its inception. In the last 60 years, Remington has made numerous variations to keep up with modern demand. This model is famous for its pair of dual-opposed lugs and a recessed bolt face.

The Remington 700 became the hunting rifle of choice for many across America, leading to its adoption by the U.S. military and law enforcement. Remington also makes 700s for the police — the 700P. The manufacturer makes the M24 and M49 sniper rifles for the military based on the 700.

The Evolution of Hunting Rifles

Rifles have come a long way since the beginning. Imagine picking up a Pennsylvania rifle and comparing it to your Mauser 18 Savanna. The hunting rifle helped settlers and early Americans hunt and sustain themselves and the evolution has led to the great rifles you know today, like the Remington 700.

How Has the Hunting Rifle Evolved Over the Last 300 Years?
How Has the Hunting Rifle Evolved Over the Last 300 Years?

The post How Has the Hunting Rifle Evolved Over the Last 300 Years? appeared first on AllOutdoor.com.

AllOutdoor.com

We Didn’t Start the Fire: Heavy Metal Edition

https://theawesomer.com/photos/2023/03/we_didnt_start_the_fire_leo_moracchioli_t.jpg

We Didn’t Start the Fire: Heavy Metal Edition

Link

Wheel of Fortune, Sally Ride, heavy metal suicide. Leo Morachiolli didn’t start the fire, but he did an impressive job covering Billy Joel’s wordy 1989 hit, adding fuel to the inferno with his hard-edged guitar and gravelly vocals. If you’re waiting for Joel to update the song for the 21st century, don’t hold your breath.

The Awesomer

Valet 4.0 is released

https://laravelnews.s3.amazonaws.com/images/laravel-valet-version-four.png

Valet 4 is officially released! Let’s look into what v4 offers and how you can upgrade your local install today.

The backdrop

Valet was originally introduced in May 2016 with this incredible video. Valet v2 was released soon after, bringing about the move from Caddy to Nginx. But after that, development on Valet slowed; as Taylor has often pointed out, “at that point, Valet was feature complete.”

However, when I picked up maintenance of Valet a few years back, there were two things I noticed: first, that many people needed different versions of PHP for their different sites; and second, that miscellaneous features and bug fixes addressed over the years made the codebase a bit difficult to reason with at times.

Valet v3 was released in March 2022, with the primary focus on adding support for multiple versions of PHP running in parallel on the same machine.

And now, we’re looking at Valet v4.

What’s new in Valet 4?

The most important change to Valet 4 is something you can’t even see from the outside: the internals of the project has been re-architected and tested heavily. Just to be clear, they’ve been re-architected back toward the style of simplicity Taylor and Adam’s original code had. But they’re now covered with all forms of unit and integration tests, and the changes made since Valet 2 are now much better integrated.

What does that mean?

Valet 4 is the most stable, easy to debug, and easy to fix version of Valet yet.

New features in Valet 4

There are a few user-facing new features:

  • valet status command: If you run valet status, you’ll get a table showing you the “health” of a few important aspects of your Valet application. This is helpful both because you can use it when you’re debugging, but, like any good CLI tool, it’ll also return codes for success or failure that other CLI tools can consume.
  • Upgrades to ngrok: If you use ngrok to share your sites, older versions of Valet bundled ngrok as an install. Now, Valet will prompt you to install ngrok through Homebrew, allowing you to have one universal version installed, and allowing you to keep it up to date as you please.
  • Expose as a share option: If you use Expose to share your sites, it’s now integrated into Valet! Run valet share-tool expose and, if you don’t have Expose installed, it’ll prompt you to install it. Once you’ve set up your Expose token, you’re ready to share using the same valet share command you’re familiar with.

Upgrade notes

If you’re upgrading from Valet 3, here’s my preferred way to upgrade:

  1. Edit your ~/.composer/composer.json file and update your Valet requirement to "^4.0"
  2. Update: composer global update laravel/valet
  3. Run valet install

Make sure you run valet install, as it’ll check your system’s compatibility and upgrade some configuration files for you.

Custom drivers

If you have any custom drivers, you’ll want to update them to match the new syntax (basically, drivers are now namespaced and have type hints and return types).

.valetphprc

If you use .valetphprc to define your sites’ PHP versions, you’ll want to rename those files to .valetrc and change their contents; .valetphprc files just contain a PHP Brew formula (e.g. php@8.1), but the new .valetrc files are broader config files, so you’ll need to prefix the formula with php=.

So if your project had this .valetphprc file:

php@8.1

You’ll want to rename it to .valetrc and update its contents to this:

php=php@8.1

Backwards compatibility: PHP 7.1-7.4

Valet 4 requires PHP 8.0+ to be installed on your system via Homebrew. As I mentioned already, you can use Valet’s isolation feature to set individual sites to use older versions of PHP, back to 7.1.

However, if you have a reason you need to use PHP 7.1-7.4 as your primary linked PHP (meaning if you just type php -v you see something between 7.1 and 8.0), you can do that! Just make sure that you have a modern version of PHP installed on your machine, and Valet will use that version to run its internal commands.

However, a quick warning: If you use Valet 4 and your primary linked version of PHP is lower than PHP 8, all of your local Valet CLI commands will run a bit more slowly, as they have to find your modern PHP install and proxy their calls through it.

The future

That’s it! The primary goal of Valet 4 is stability, but it also opens up some great new options for the future. First, the .valetrc file is much more powerful than .valetphprc was, and we can make it a lot more configurable. And second, I dropped a concept called Extensions that was basically entirely unused, with the hope of building a plugin system sometime in the near future.

If you followed my journey of rebuilding Valet for v4 on Twitter, you might have seen that I attempted to make it work on Linux. Sadly, that wasn’t successful, but I still have dreams of one day attempting it again. No promises… but it’s still a dream!

I hope you all love Valet 4. Enjoy!

Laravel News

Laravel Open Weather Package


README

Packagist
GitHub stars
GitHub forks
GitHub issues
GitHub license

Laravel OpenWeather API (openweather-laravel-api) is a Laravel package to connect Open Weather Map APIs ( https://openweathermap.org/api ) and access free API services (current weather, weather forecast, weather history) easily.

Supported APIs

Installation

Install the package through Composer.
On the command line:

composer require rakibdevs/openweather-laravel-api

Configuration

If Laravel > 7, no need to add provider

Add the following to your providers array in config/app.php:

'providers' => [
    // ...
    RakibDevs\Weather\WeatherServiceProvider::class,
],
'aliases' => [
    //...
    'Weather' => RakibDevs\Weather\Weather::class,	
];

Add API key and desired language in .env

OPENWAETHER_API_KEY=
OPENWAETHER_API_LANG=en

Publish the required package configuration file using the artisan command:

	$ php artisan vendor:publish

Edit the config/openweather.php file and modify the api_key value with your Open Weather Map api key.

	return [
	    'api_key' 	        => env('OPENWAETHER_API_KEY', ''),
    	    'onecall_api_version' => '2.5',
            'historical_api_version' => '2.5',
            'forecast_api_version' => '2.5',
            'polution_api_version' => '2.5',
            'geo_api_version' => '1.0',
	    'lang' 		=> env('OPENWAETHER_API_LANG', 'en'),
	    'date_format'       => 'm/d/Y',
	    'time_format'       => 'h:i A',
	    'day_format'        => 'l',
	    'temp_format'       => 'c'         // c for celcius, f for farenheit, k for kelvin
	];

Now you can configure API version from config as One Call API is upgraded to version 3.0. Please set available api version in config.

Usage

Here you can see some example of just how simple this package is to use.

use RakibDevs\Weather\Weather;

$wt = new Weather();

$info = $wt->getCurrentByCity('dhaka');    // Get current weather by city name

Access current weather data for any location on Earth including over 200,000 cities! OpenWeather collect and process weather data from different sources such as global and local weather models, satellites, radars and vast network of weather stations

// By city name
$info = $wt->getCurrentByCity('dhaka'); 

// By city ID - download list of city id here http://bulk.openweathermap.org/sample/
$info = $wt->getCurrentByCity(1185241); 

// By Zip Code - string with country code 
$info = $wt->getCurrentByZip('94040,us');  // If no country code specified, us will be default

// By coordinates : latitude and longitude
$info = $wt->getCurrentByCord(23.7104, 90.4074);

Output:

{
  "coord": {
    "lon": 90.4074
    "lat": 23.7104
  }
  "weather":[
    0 => { 
      "id": 721
      "main": "Haze"
      "description": "haze"
      "icon": "50d"
    }
  ]
  "base": "stations"
  "main": {
    "temp": 26
    "feels_like": 25.42
    "temp_min": 26
    "temp_max": 26
    "pressure": 1009
    "humidity": 57
  }
  "visibility": 3500
  "wind": {
    "speed": 4.12
    "deg": 280
  }
  "clouds": {
    "all": 85
  }
  "dt": "01/09/2021 04:16 PM"
  "sys": {
    "type": 1
    "id": 9145
    "country": "BD"
    "sunrise": "01/09/2021 06:42 AM"
    "sunset": "01/09/2021 05:28 PM"
  }
  "timezone": 21600
  "id": 1185241
  "name": "Dhaka"
  "cod": 200
}

Make just one API call and get all your essential weather data for a specific location with OpenWeather One Call API.

// By coordinates : latitude and longitude
$info = $wt->getOneCallByCord(23.7104, 90.4074);

4 day forecast is available at any location or city. It includes weather forecast data with 3-hour step.

// By city name
$info = $wt->get3HourlyByCity('dhaka'); 

// By city ID - download list of city id here http://bulk.openweathermap.org/sample/
$info = $wt->get3HourlyByCity(1185241); 

// By Zip Code - string with country code 
$info = $wt->get3HourlyByZip('94040,us');  // If no country code specified, us will be default

// By coordinates : latitude and longitude
$info = $wt->get3HourlyByCord(23.7104, 90.4074);

Get access to historical weather data for the previous 5 days.

// By coordinates : latitude, longitude and date
$info = $wt->getHistoryByCord(23.7104, 90.4074, '2020-01-09');

Air Pollution API provides current, forecast and historical air pollution data for any coordinates on the globe

Besides basic Air Quality Index, the API returns data about polluting gases, such as Carbon monoxide (CO), Nitrogen monoxide (NO), Nitrogen dioxide (NO2), Ozone (O3), Sulphur dioxide (SO2), Ammonia (NH3), and particulates (PM2.5 and PM10).

Air pollution forecast is available for 5 days with hourly granularity. Historical data is accessible from 27th November 2020.

// By coordinates : latitude, longitude and date
$info = $wt->getAirPollutionByCord(23.7104, 90.4074);

Geocoding API is a simple tool that we have developed to ease the search for locations while working with geographic names and coordinates.
-> Direct geocoding converts the specified name of a location or area into the exact geographical coordinates;
-> Reverse geocoding converts the geographical coordinates into the names of the nearby locations.

// By city name
$info = $wt->getGeoByCity('dhaka');

// By coordinates : latitude, longitude and date
$info = $wt->getGeoByCity(23.7104, 90.4074);
  • 60 calls/minute
  • 1,000,000 calls/month
  • 1000 calls/day when using Onecall requests

License

Laravel Open Weather API is licensed under The MIT License (MIT).

Laravel News Links

A menu for the manly man

https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMbtjUuceQaJ_JiqGW2aJ7bzET2TPRNs-7O888yvYKFxk8rgzPuhjVvS1eZPFQ7wU55UJIqYmKSoW2iC-CiucemUrlb_T_TTOMLPkEG-fOsKu9tO3hOlHeLWM8xvcFSVIgPSAfQSBchQTrmm6o7MCFkzT-90PlwsI9WVx_xL62ZqR9v5FAjclOFtsO/w400-h254/Elephant%20stew.png

 

Found on Gab (clickit to biggit):

I had to laugh at the instructions.

I’ve been present when an elephant that was destroying crops was shot near an African village.  The villagers swarmed the carcass, armed with machetes, axes and other edged instruments, and proceeded to have a gigantic meat-eating binge that lasted three days.  They dismembered that carcass from inside and out, literally:  some people crawled inside the belly cavity and cut their way out, while others stood on the ribs and cut their way in.  When an errant machete blade from one side or the other cut into someone on the other side of the skin, there were screams of outrage and anger;  but mostly they were too busy eating (yes, even raw meat!) to care.

At the end of three days, all that was left were the remains of the entrails, and the huge bones of the elephant skeleton.  Sixty-odd villagers had eaten until they bulged (literally):  their stomachs were so distended I was surprised they could still move.  Of course, in African heat, with no refrigeration available, the meat had already spoiled by the third day, but they ate and ate and ate so as to waste as little as possible of the precious nutrition deposited on their doorsteps by the Game Department.

Perhaps they should have tried this recipe . . .

Peter

Bayou Renaissance Man

Coiling Molten Steel Rod

https://theawesomer.com/photos/2022/03/molten_steel_coiling_t.jpg

Coiling Molten Steel Rod

Link

Redditor arcedup works in a steel mill and wanted to test out the video capabilities of their phone. While they were at it, they captured this wonderfully satisfying clip of molten hot steel being turned into a coiled rod. Is it wrong that we want to make the world’s largest Slinky with it?

The Awesomer

Argument: It is not an “arm” under the Second Amendment?

B.L.U.F. An analysis/opinion of the State’s attempt to move certain arms out from the protection of the Second Amendment.


This is a long running argument from the anti-gun rights people. The gist is always of the “this modern thing didn’t exist in 1791 so it isn’t covered by the second amendment.” These same people are saying this on phones, computers, The Internet, which the firmly believe are covered under the first Amendment, even though those things would not have been known at the time of the founding.

The question is legitimate, so lets take it to an extreme.

Are Nuclear Weapons Protected Arms Under the Second Amendment?

Hagar reported to me that she often times has discussions with anti-gun people and they will ask something like “Well, do you think people should be able to own nuclear weapons!?!?!?”

She reports that most of them are shocked when she replies in the affirmative “Yes, they should be able to legally own nuclear weapons.” There is more to our discussion, I’ll get to that later.

Before addressing the verbs “keep” and “bear,” we interpret their object: “Arms.” The 18th-century meaning is no different from the meaning today. The 1773 edition of Samuel Johnson’s dictionary defined “arms” as “[w]eapons of offence, or armour of defence.” 1 Dictionary of the English Language 106 (4th ed.) (reprinted 1978) (hereinafter Johnson). Timothy Cunningham’s important 1771 legal dictionary defined “arms” as “any thing that a man wears for his defence, or takes into his hands, or useth in wrath to cast at or strike another.” 1 A New and Complete Law Dictionary; see also N. Webster, American Dictionary of the English Language (1828) (reprinted 1989) (hereinafter Webster) (similar).

The term was applied, then as now, to weapons that were not specifically designed for military use and were not employed in a military capacity. For instance, Cunningham’s legal dictionary gave as an example of usage: “Servants and labourers shall use bows and arrows on Sundays, & c. and not bear other arms.” See also, e.g., An Act for the trial of Negroes, 1797 Del. Laws ch. XLIII, § 6, in 1 First Laws of the State of Delaware 102, 104 (J. Cushing ed.1981 (pt. 1)); see generally State v. Duke, 42 Tex. 455, 458 (1874) (citing decisions of state courts construing “arms”). Although one founding-era thesaurus limited “arms” (as opposed to “weapons”) to “instruments of offence generally made use of in war,” even that source stated that all firearms constituted “arms.” 1 J. Trusler, The Distinction Between Words Esteemed Synonymous in the English Language 37 (3d ed. 1794) (emphasis added).
District of Columbia v. Heller, 554 US 570 – Supreme Court 2008 P.2791

Here we have the short of it [w]eapons of offence, or armour of defence.Id, citing Samuel Johnson’s dictionary of 1773

Are “nuclear weapons” weapons of offence? Yes, by the clear text of the Second Amendment supported by multiple sources at the time of the ratification of the Bill of Rights.

But nuclear weapons were not in existence at the time of the founding and the Founding Fathers could not have anticipated the horrific destructive power of such weapons. Again, Justice Scalia answers us.

Some have made the argument, bordering on the frivolous, that only those arms in existence in the 18th century are protected by the Second Amendment. We do not interpret constitutional rights that way. Just as the First Amendment protects modern forms of communications, e.g., Reno v. American Civil Liberties Union, 521 U.S. 844, 849, 117 S.Ct. 2329, 138 L.Ed.2d 874 (1997), and the Fourth Amendment applies to modern forms of search, e.g., Kyllo v. United States, 533 U.S. 27, 35-36, 121 S.Ct. 2038, 150 L.Ed.2d 94 (2001), the Second Amendment extends, prima facie, to all instruments that constitute bearable arms, even those that were not in existence at the time of the founding.
Id. At P 2791,2792

Under the instructions given by the Supreme Court in Heller it is clear that nuclear weapons are arms.

But the argument goes on that the arm must be “bearable” to be considered covered under the Second Amendment. We know from historical fact that this was not the understanding at the time of the founding. We know this because many civilians owned cannon and even warships. In fact the US Government was known to issue sanctions to warship owners to have them engage in combat on the high seas with the enemies of the United States.

Justice Scalia addresses this issue. He is addressing the question in Heller in regards to individual right vs. collective right so his analysis is not a direct answer for us.

At the time of the founding, as now, to “bear” meant to “carry.” See Johnson 161; Webster; T. Sheridan, A Complete Dictionary of the English Language (1796); 2 Oxford English Dictionary 20 (2d ed.1989) (hereinafter Oxford). When used with “arms,” however, the term has a meaning that refers to carrying for a particular purpose—confrontation. In Muscarello v. United States, 524 U.S. 125, 118 S.Ct. 1911, 141 L.Ed.2d 111 (1998), in the course of analyzing the meaning of “carries a firearm” in a federal criminal statute, Justice GINSBURG wrote that “[s]urely a most familiar meaning is, as the Constitution’s Second Amendment . . . indicate[s]: `wear, bear, or carry . . . upon the person or in the clothing or in a pocket, for the purpose . . . of being armed and ready for offensive or defensive action in a case of conflict with another person.’” Id., at 143, 118 S.Ct. 1911 (dissenting opinion) (quoting Black’s Law Dictionary 214 (6th ed.1990)). We think that Justice GINSBURG accurately captured the natural meaning of “bear arms.” Although the phrase implies that the carrying of the weapon is for the purpose of “offensive or defensive action,” it in no way connotes participation in a structured military organization.
Id. at P. 2793

This leaves the question slightly open as to the question of size limitations on arms that are protected by the Second Amendment. We know that Heller clearly states that pistols and other handguns are. This has been extended to the sorts of long guns and shotguns that can be shouldered. It has been extended to weapons that are too heavy to shoulder but can be fired by one man from a bipod. I.e. a .50 cal semi-auto or bolt action rifle.

What about crew served weapons? Is a 60mm M224A1 mortar covered? How about the 81mm M252A1? How about the 120mm M120/M121, are they covered?

If those are covered are the M119 105mm Howitzer covered and the M777 155mm Howitzer? Or even the M110 Self-Propelled Howitzer. Those are huge. Are they covered?

The answer to all of that seems to be “yes”. The text of the Second Amendment does extend to “arms” that can not be carried by just one man but must instead have some other way of conveyance. It seems clear that a 16″ 3 Gun turret from a Wisconsin class Battleship would be covered arms.

From this, it seems clear that nuclear weapons are covered under the Second Amendment.

What laws are constitutional in regards to nuclear weapons?

According to the Constitution the answer is shall not be infringed According to the Supreme Court, there are acceptable regulations and limitations on the right to keep and bear arms.

To be clear, analogical reasoning under the Second Amendment is neither a regulatory straightjacket nor a regulatory blank check. On the one hand, courts should not “uphold every modern law that remotely resembles a historical analogue,” because doing so “risk[s] endorsing outliers that our ancestors would never have accepted.” Drummond v. Robinson, 9 F.4th 217, 226 (CA3 2021). On the other hand, analogical reasoning requires only that the government identify a well-established and representative historical analogue, not a historical twin. So even if a modern-day regulation is not a dead ringer for historical precursors, it still may be analogous enough to pass constitutional muster.
New York State Rifle & Pistol Assn, Inc. v. Bruen, 142 S. Ct. 2111 – Supreme Court 2022 P. 2133

…is neither a regulatory straightjacket nor a regulatory blank check… which leads to the question of when it the analogical reasoning within the limits? That is not relevant here.

Under Heller, when the Second Amendment’s plain text covers an individual’s conduct, the Constitution presumptively protects that conduct, and to justify a firearm regulation the government must demonstrate that the regulation is consistent with the Nation’s historical tradition of firearm regulation. Pp. 2125-2134.
Id. at P.2117.

This allows the state to raise the question of what laws are consistent with Nation’s historical tradition of firearm(arms) regulation.

So far the state has not been able to produce any law, in my opinion, from the correct time period that supports the banning of a class of weapon.

What they have been able to do is to find multiple laws regarding fire safety in regards to gunpowder. I submit that since the possibilities of a radiation mishap does exist and that does not infringe on your ability to keep and bear the nuclear weapon, that the state could have storage requirements that are for safety purposes.

Note, when I say “safety purposes” that doesn’t mean stuff like “It must be kept disassembled with its fissionable materials in a different county.” It means things like radiation sensors that are tested and monitored. Containers that are designed to low radiation leakage to a reasonable level and so forth.

In my opinion this type of safety law would fall within the text, history and tradition requirements of both Heller and Bruen.

Currently, the Supreme Court has put another limitation on what arms are covered within the scope of the Second Amendment.

None of the Court’s precedents forecloses the Court’s interpretation. Neither United States v. Cruikshank, 92 U.S. 542, 553, 23 L.Ed. 588, nor Presser v. Illinois, 116 U.S. 252, 264-265, 6 S.Ct. 580, 29 L.Ed. 615, refutes the individual-rights interpretation. United States v. Miller, 307 U.S. 174, 59 S.Ct. 816, 83 L.Ed. 1206, does not limit the right to keep and bear arms to militia purposes, but rather limits the type of weapon to which the right applies to those used by the militia, i.e., those in common use for lawful purposes. Pp. 2812 – 2816.
Heller
The rabbit hole called to me and I went to take a read of United States v. Cruikshank et al. If you think legal geek speak is bad today, it was harder still in 1876. 10 pages into the opinion I’m still not sure what the opinion was nor what the question asked was. It seems that I’ll have to do a deeper read into it at some point.

Chief Justice Waite ruled that neither the First nor Second Amendments limited the powers of the state government or individuals. Wikipedia

The right to keep and bear arms exists separately from the Constitution and is not solely based on the Second Amendment, which exists to prevent Congress from infringing the right.Justia

[T]hose in common use for lawful purposesHeller is the phrase that much of our current litigation is founded on. If an arm is in common use for lawful purposes then that arm is not “Unusual”.

This links back to …finds support in the historical tradition of prohibiting the carrying of dangerous and unusual weapons.Id. at P. 2786 is the other part of this.

What this means is that nuclear weapons fail “in common use for lawful purposes” so they are unusual weapons and they are also “dangerous” which means that laws from the founding that prohibited carrying “dangerous and unusual” weapons can be used to justify carry regulations in regards to nuclear weapons today.


More to come.

Gun Free Zone

Terraform your Laravel deployments

https://kbouzidi.com/img/containers/assets/terraform-your-laravel-deployments.jpeg/aede5dcfccc966770807a2c35c7ec2b5.jpeg

In this article we will use terraform to provision a lemp stack for a laravel application with all its configurations (database, php, nginx, firewall, ssl, etc).

PHP Stack Provisioning

Every PHP project you worked on has that phase when you need to deploy it to a desired environment that match the application requirement usually its a LEMP or a LAMP stack.

That may require you to install and configure all these applications on the server every time manually, which can be boring, time consuming and redundant.

Terraform-php-stack

Is a terraform project that i was working on to solve my PHP stack provisioning and configurations.

if you are dealing with that manually this will speed up your applications deployments. It can also help if you are migrating to a new server.

The good part is that you can also test it locally before deciding to run it on a production server.

I tried to make the project as user-friendly as possible, so you don’t need to know Terraform to use it.

However, I will still provide a step-by-step explanation:

  1. Installing Terraform

  2. Setup Target machine

  3. Configure terraform-php-stack

  4. Deployment

  5. Contribution

In fact terraform installation is very simple, i will only cover ubuntu/debian installation for other OS, you can check the official documentation (=>).

wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update && sudo apt install terraform

You can use this terraform project against a fresh linux instance (vps) or a local virtual machine which is cool to test stuff before a real deployment.

For local testing i use vagrant & VirtualBox, you can use any other hypervisor.

This is my Vagrantfile :

Vagrant.configure("2") do |config|
 
  config.vm.box = "ubuntu/jammy64"
  config.vm.hostname = "kbouzidi"

  config.vm.provision "shell", inline: <<-SHELL
      apt update &&  hostname -I
     
  SHELL
 
  config.vm.network "private_network", type: "dhcp"

  config.vm.provider "virtualbox" do |vb|
   
  end
   
end

COPY SSH KEY

You need to copy your public ssh key to your target server.

ssh-copy-id user@targetIP

🚨 if you skip this probably you will be lost into a desert 🏜️

Well only if you will use vagrant with its own private key.

In this part, I will walk you through how I used this for a Laravel 10 project, and don’t worry, you don’t need to know Terraform at all.

First, you need to clone the project

git clone git@github.com:Safemood/terraform-php-stack.git

To start, you need to copy the example files to create your own configurations.

cd terraform-php-stack
cp terraform.tfvars.example terraform.tfvars

As you can see, this is the folder structure :

├── main.tf
├── modules
│   ├── install_dependencies
│   │   ├── configure.sh
│   │   ├── main.tf
│   │   └── variables.tf
│   ├── install_node
│   │   ├── main.tf
│   │   └── variables.tf
│   ├── install_mysql
│   │   ├── create_db.sh
│   │   ├── main.tf
│   │   └── variables.tf
│   ├── install_nginx
│   │   ├── default.tftpl
│   │   ├── main.tf
│   │   └── variables.tf
│   ├── install_php
│   │   ├── main.tf
│   │   ├── php.ini
│   │   ├── setup.sh
│   │   └── variables.tf
│   └── setup_app
│       ├── main.tf
│		├── .env.tftpl
│       └── variables.tf
├── terraform.tfvars.example

What is important in here :

  • main.tf where we can set all the required modules.

  • modules folder where the supported modules exist.

  • terraform.tfvars where we can set our environment variables && configurations.

  • .env.tftpl the template .env file for your php project.

We will configure the whole deployment only from terraform.tfvars

ssh_host            = "target ip"
ssh_user            = "ssh user"
ssh_key             = "private_key path"
php_version         = "8.2"
webmaster_email     = "example@test.com"
mysql_root_password = "crazySecurePassword"
git_repo            = "git@github.com:laravel/laravel"
db_connexion        = "mysql"
db_host             = "localhost"
db_port             = "3306"
db_name             = "kbouzidi"
db_user             = "safemood"
db_password         = "terraform"
domain_name         = "kbouzidi.com"
app_env             = "production"
app_debug           = false
scheme              = "http"  // 'https' will auto assign ssl certificates to your domain
stack_modules       = ["dependencies", "node", "nginx", "php", "app", "mysql"] // dependencies","mysql", "nginx", "php","app" , "node"
system_dependencies = "git tmux vim zip unzip htop fail2ban"
installation_steps = [
  # Set Folder Permissions
  "sudo chgrp -R www-data storage bootstrap/cache",
  "sudo chmod -R ug+rwx storage bootstrap/cache",
  # Installation
  "composer install --optimize-autoloader --no-dev",
  "php artisan key:generate --force",
  "php artisan storage:link --force",
  "php artisan migrate --seed --force",
  "sudo php artisan optimize:clear",
  "npm install && npm run build",
  "php artisan optimize"
]

What you need to know :

stack_modules is an array of the modules that you wanna install :

  • dependencies : to install required system dependencies and make other necessary configurations.

  • php : to install php on the system with the required version “php_version“.

  • node : to install nodejs & npm on the system with the required version “node_version“.

  • nginx : to install nginx and setup an nginx web server.

  • mysql : to install and setup a mysql server and a dadicated database to your project with the required permissions.

  • app : to setup and install our application.

Some other important notes:

  • scheme : https will auto assign ssl certificates to your domain using certbot.

  • git_repo : when its a private repo, you will need to add a deploy key to your project (link).

🚨 for private github repo make sure to use deploy keys so the token has access only to the related project only.

Deployment is the simplest part; just access the ‘terraform-php-stack’ folder and hit :

terraform init // only the first time
terraform apply 
// or if you know what your doing 💥
terraform apply --auto-approve

You can see how the deployment process works in action.

As you have seen, the whole LEMP stack took only 4 minutes!

You can destroy this infrastructure with :

terraform destroy 

I created this with Laravel ❤️ in mind and i really love to expand it to be helpful for all major PHP framework and stacks, so contributions are very welcome 🤗🥰.

Just keep in mind these main points :

  • The ability to use the project without being a terraform expert.

  • Simplify the process of deploying and managing infrastructure for PHP developers using Terraform.

  • Make PHP developers happier 😁.

What i have in mind for this project:

  • Add Symfony support .

  • Add a fully docker version to provision the whole stack with containers.

  • Add support for major cloud providers (aws, google cloud, azure) to make PHP stack provisioning easier on these platforms.

I hope the information I provided was helpful. If you have any questions or need further clarification, don’t hesitate to reach out to me. I’m always open to feedback, so please feel free to share any thoughts or suggestions you may have.

You can find me on LinkedIn || Twitter || Github!

Feel free to drop by and say hello – I’m always up for meeting new people and expanding my network!😊

Laravel News Links

QR Code Generator in Laravel 10

https://harrk.dev/content/images/2023/03/QR-Code-Generator-in-Laravel-10-Tutorial.webp

In this post, we will look at generating QR codes within your Laravel applications.

First, we will need to require the simple-qrcode package that provides first-party support for Laravel. The package itself wraps the Bacon/BaconQrCode package which itself is a port of the ZXing library but for PHP.

If you wish – you may directly interact with the BaconQrCode package without using simple-qrcode. However, simple-qrcode provides a better developer experience when used with Laravel. Additionally, with out-of-the-box support for overlaying images on QR codes.

With the context blurb out of the way. Let’s dig in!

Step 1: Setting Up

Spin up a new Laravel 10 project (or step over this if you already have a project ready).

$ laravel new qrcodegenerator

Set up your database connection as per your own preference. Then install the simple-qrcode package via Composer.

$ composer require simplesoftwareio/simple-qrcode "~4"

Optional! If you want to create QR codes in .png format. You will need to install the imagick extension. In most cases, all you need to do is install via pecl with pecl install imagick. If that does not work for you, then Google is your friend here as it goes beyond the topic of this article.

Step 2: Creating The Controller

Now we need to wire up a controller and route before we can pull back a QR code in our browser.

Create a new QrCodeController.

$ php artisan make:controller QrCodeController

And then reference the controller in our routes/web.php file.

<?php

use App\Http\Controllers\QrCodeController;
use Illuminate\Support\Facades\Route;

Route::get('/', [QrCodeController::class, 'show']);

Opening up the URL in our browser gives us a blank page at this point. Also as I’m using Valet here, I only need to enter the foldername.test to view the project in my browser. Your setup may be different so you do you, whether that’s php artisan serve or something else.

A very empty page

Step 3: Generating QR Codes

At the very bare minimum, you can call the QrCode facade alongside generate with something to render. And you’ll get a QR code back.

In my QrCodeController I am creating a QR code with all the default settings with the following content “Hello, World!”.

<?php

namespace App\Http\Controllers;

use SimpleSoftwareIO\QrCode\Facades\QrCode;

class QrCodeController extends Controller
{
    public function show()
    {
        return QrCode::generate(
            'Hello, World!',
        );
    }
}

Refresh the page in the browser and…

A rendered QR code
wollah!

Step 4: Customising the Generated QR Code

Alright so how about something a little more interesting? A splash of colour? Let’s use a couple of methods that allow us to change the background colour, foreground colour, and margin.

public function show()
{
    return QrCode::size(200)
        ->backgroundColor(255, 255, 0)
        ->color(0, 0, 255)
        ->margin(1)
        ->generate(
            'Hello, World!',
        );
}

And here’s the result:

QR Code with colour

Let’s try something that makes our QR codes stand out. And I’m not talking about colours anymore.

We can actually modify the style and eye (the three corners) of the QR code. Try this out:

return QrCode::size(200)
        ->style('dot')
        ->eye('circle')
        ->color(0, 0, 255)
        ->margin(1)
        ->generate(
            'Hello, World!',
        );

Result:

QR Code with Style

Before closing this section. One more on colours: gradients.

$from = [255, 0, 0];
$to = [0, 0, 255];

return QrCode::size(200)
    ->style('dot')
    ->eye('circle')
    ->gradient($from[0], $from[1], $from[2], $to[0], $to[1], $to[2], 'diagonal')
    ->margin(1)
    ->generate(
        'Hello, World!',
    );

By specifying a from and to colour, alongside a type of gradient (vertical, horizontal, etc). You can create something really cool!

A QR Code with a gradient

Merging Images

To overlay an image in a QR code – we’ll need to change the way we do a few things.

To prepare for this I have dropped an image (twitter.jpg) in my storage/app folder. Then by calling ->merge($filepath), simple-qrcode will load that image and overlay it onto the QR code.

If you want to pull in the image data yourself, you can replace merge with mergeString. Eg: ->mergeString(Storage::get($path)).

Merging an image is only supported with png QR codes, so we need to specify the format on this, too.

public function show()
    {
        $data = QrCode::size(512)
            ->format('png')
            ->merge('/storage/app/twitter.jpg')
            ->errorCorrection('M')
            ->generate(
                'https://twitter.com/HarryKir',
            );

        return response($data)
            ->header('Content-type', 'image/png');
    }

Then the result of all this:

QR Code with Twitter Logo in Centre

You may have noticed the line in regards to errorCorrection. When we overlay an image, part of the QR code’s data becomes obscured.

By default, the errorCorrection is set to the lowest value (‘L’). If you attempt to scan your QR code like this, it’s likely that the QR code will not scan. To remedy this we adjust the errorCorrection level up a notch until our code is scannable.

The various levels are:

  • L: Low (7% correction)
  • M: Medium (15% correction)
  • Q: Quartile (25% correction)
  • H: High (30% correction)

The higher the correction level, the more “noisy” the QR code becomes. Preferably you want the lowest correction level alongside a scannable QR code for the sake of keeping up appearances.

Downloading Generated QR Codes

To return a download response, you can either store the QR code as a file and return the path with return response()->download($path); or stream the contents of the QR code without using the filesystem.

An example of using streamDownload to do this:

public function download()
{
    return response()->streamDownload(
        function () {
            echo QrCode::size(200)
                ->format('png')
                ->generate('https://harrk.dev');
        },
        'qr-code.png',
        [
            'Content-Type' => 'image/png',
        ]
    );
}

Generating QR Codes in Blade

Since we’ve been using a Facade all along, generating a QR code in Blade is as simple as repeating the above steps. Call the facade, customise as required, and call generate.

{!! QrCode::size(256)->generate('https://google.com') !!}

Or another approach, encode the data within an image tag manually. For example, if you need to change the image type for whatever reason.

<img src="data:image/png;base64, {!! base64_encode(QrCode::format('png')->size(256)->generate('https://google.com')) !!} ">

QR Code Data Types

Alright, so we’ve been using URLs in these examples. Mobile devices are clever enough to figure out how to handle these when scanned, but we can go a step further.

If you want to read the long version of this. Check out the ZXing’s Wiki page.

To summarise: simple-qrcode has a couple of helpers to specify the data the QR code will contain. You can replace the generate method with any of these.

Here are a few examples:

Email

Open a blank email addressed to “hello@example.com”.

QrCode::size(200)->email('hello@example.com');

Open an email with a predefined subject and body.

QrCode::size(200)->email('hello@example.com', 'Hello World', 'This is a test message.');

Phone Number

QrCode::size(200)->phoneNumber('555-555-5555');

SMS Text Message

Send an SMS text message to 555-555-5555 with a prewritten message, “Hi!”.

QrCode::size(200)->SMS('555-555-5555', 'Hi!');

Wi-Fi

Share Wi-Fi credentials for your visitors.

QrCode::size(200)->wiFi([
    'encryption' => 'WPA/WEP',
    'ssid' => 'SSID of the network',
    'password' => 'Password of the network',
    'hidden' => 'Whether the network is a hidden SSID or not.'
]);

Geolocation

Share a location by providing a latitude and longitude.

QrCode::size(200)->geo(51.378638, -0.100897);

Conclusion

To see more advance options for QR code customisation, refer to the documentation for simple-qrcode.

As for some real world examples of this package in action. I use simple-qrcode for generating QR codes for my QR code tracking SaaS.

QRMetric – Your Dynamic QR Code Buddy

Create Dynamic QR Codes that can be modified without requiring you to redistribute a new QR code. Can be changed any time, any place, anywhere.

Otherwise, if generating QR codes with Javascript is your thing. Consider checking out the node-qrcode library. I use this for generating QR codes on a static site, without any server involvement altogether.

Random QR Code Generator

RandomQR is a QR Code Generator for those times when you just need a random QR image and nothing more. Simple, easy, and fast.

Laravel News Links