As developers, debugging apps is the task we do most of the time, and the essential part of it is accessing debug information, knowing what’s happening under the hood like seeing what queries are executed, knowing what commands are executed by your Laravel application will help you a lot to debug your application, and this is exactly what Laravel Telescope can do for you.
What is Laravel Telescope
Laravel Telescope is a first party Laravel package, its creators described it as:
An elegant debug assistant for the Laravel framework.
And this is exactly what it is, it’s your assistant while developing and debugging Laravel applications, it collects the important things you need to have an eye on like requests, database queries, queued jobs… basically everything’s happening in your application in one beautiful place so you can access them easily.
Laravel Telescope can also be helpful while improving the performance of your application, for example using its Queries feature that shows you all the database queries that are executed on every request, such thing can, for example, help you identify repetitive and unnecessary queries and fix them.
Laravel Telescope Installation
You can install it easily as any other Laravel package via composer:
composer require laravel/telescope
After installing it, you can publish its assets using the following command:
phpartisantelescope:install
Finally, you have to run migrations to create the tables needed by Laravel Telescope:
php artisan migrate
That’s it, to access Laravel Telescope’s dashboard and start using it, visit /telescope.
Laravel Telescope in the Production environment
Now this dashboard is accessible only in the Local environment, if you try to access it in the Production environment, you will get a 403 FORBIDDEN error and that’s because of the authorization gate defined in app/Providers/TelescopeServiceProvider.php and that’s for sure a good thing, you don’t want to let everyone access Laravel Telescope’s dashboard.
To access the dashboard in a Production environment, edit the authorization gate in the way you want it to be, for example:
https://i.ytimg.com/vi/DKd560Ps6xo/maxresdefault.jpgIn this video, we will be looking at 4 new things that are added to the latest version of Laravel which is v9.28.0Laravel News Links
The third part of a code review of an open-source repository called Skuul. This time, we’re talking about roles and permissions, with seeders, controllers, and policies.Laravel News Links
Laravel Scrubber is a Laravel package to scrub sensitive information that breaks operational security policies from being leaked on accident or not by developers.
You can use this package in a few ways:
First, this package detects log messages and context patterns and scrubs them:
1Log::info('some message', [
2'context'=>'accidental',
3'leak_of'=> [
4'jwt'=>'<insert jwt token here>'
5 ]
6]);
7
8// testing.INFO: some message {"context":"accidental","leak_of":{"jwt": '**redacted**'}}
9
10Log::info('<insert jwt token here>');
11
12// testing.INFO: **redacted**
Second, you can use the scrubber directly to process data in an array and mark it as redacted:
This package also provides customization options, such as configuring the replacement message when data is scrubbed (the default is **redacted**). You can also extend the package by adding custom regex scrubbers.
There are 2 major problems having a UUID as Primary Key in InnoDB:
generally they are random and cause clustered index to be rebalanced
they are included in each secondary indexes (consuming disk and memory)
Let’s have a look at this example:
MySQL > CREATE TABLE my_table (
uuid VARCHAR(36) DEFAULT (UUID()) PRIMARY KEY,
name VARCHAR(20), beers int unsigned);
...
MySQL > SELECT * FROM my_table;
+--------------------------------------+---------+-------+
| uuid | name | beers |
+--------------------------------------+---------+-------+
| 17cd1188-1fa0-11ed-ba36-c8cb9e32df8e | Kenny | 0 |
| 17cd12e2-1fa0-11ed-ba36-c8cb9e32df8e | lefred | 1 |
| 478368a0-1fa0-11ed-ba36-c8cb9e32df8e | Scott | 1 |
| 47836a77-1fa0-11ed-ba36-c8cb9e32df8e | Lenka | 0 |
+--------------------------------------+---------+-------+
Now, let’s insert 2 new records:
MySQL > INSERT INTO my_table (name, beers) VALUES ("Luis",1), ("Miguel",5);
We can check the content of the table:
MySQL > SELECT * FROM my_table;
+--------------------------------------+---------+-------+
| uuid | name | beers |
+--------------------------------------+---------+-------+
| 17cd1188-1fa0-11ed-ba36-c8cb9e32df8e | Yannis | 0 |
| 17cd12e2-1fa0-11ed-ba36-c8cb9e32df8e | lefred | 1 |
| 36f1ce9a-1fa1-11ed-ba36-c8cb9e32df8e | Luis | 1 | <--
| 36f1d158-1fa1-11ed-ba36-c8cb9e32df8e | Miguel | 5 | <--
| 478368a0-1fa0-11ed-ba36-c8cb9e32df8e | Scott | 1 |
| 47836a77-1fa0-11ed-ba36-c8cb9e32df8e | Lenka | 0 |
+--------------------------------------+---------+-------+
We can see that the two new records were not inserted at the end of the table but in the middle. InnoDB had to move two old records to be able to insert the two new before them. On such small table (all records are on the same page) that doesn’t cause any problem, but imagine this table is 1TB large !
Additionally, if we keep the VARCHCAR datatype for our uuid, the primary key could take 146 bytes per row (some utf8 characters can take up to 4 bytes + the 2 bytes marking the end of the VARCHAR):
UUID v1 : is a universally unique identifier that is generated using a timestamp and the MAC address of the computer on which it was generated.
UUID v4 : is a universally unique identifier that is generated using random numbers.
With UUID v4m it’s not possible to generate any sequential ouput and this is why those random UUID should never be used as Primary Key with InnoDB.
UUID v4
Some developers keep asking about UUIDv4 and how to generate them for MySQL. Browsing the Internet, you can find several store procedures trying to achieve this.
CREATE FUNCTION uuid_v4s()
RETURNS CHAR(36)
BEGIN
-- 1th and 2nd block are made of 6 random bytes
SET @h1 = HEX(RANDOM_BYTES(4));
SET @h2 = HEX(RANDOM_BYTES(2));
-- 3th block will start with a 4 indicating the version, remaining is random
SET @h3 = SUBSTR(HEX(RANDOM_BYTES(2)), 2, 3);
-- 4th block first nibble can only be 8, 9 A or B, remaining is random
SET @h4 = CONCAT(HEX(FLOOR(ASCII(RANDOM_BYTES(1)) / 64)+8),
SUBSTR(HEX(RANDOM_BYTES(2)), 2, 3));
-- 5th block is made of 6 random bytes
SET @h5 = HEX(RANDOM_BYTES(6));
-- Build the complete UUID
RETURN LOWER(CONCAT(
@h1, '-', @h2, '-4', @h3, '-', @h4, '-', @h5
));
END
Unfortunately this function cannot be used as default expression for a column.
But this new function is also not usable as default value expression.
MySQL error code MY-003770 (ER_DEFAULT_VAL_GENERATED_NAMED_FUNCTION_IS_NOT_ALLOWED): Default value expression of column '%s' contains a disallowed function: %s.
This means that every new record needs to provide the uuid column… this is not too complicated anyway.
Let’s see an example:
MySQL > install component "file://component_uuid_v4";
MySQL > select uuid_v4() ;
+--------------------------------------+
| uuid_v4() |
+--------------------------------------+
| 9944272b-e3f9-4778-9c54-818f0baa87da |
+--------------------------------------+
1 row in set (0.0002 sec)
Now we will create a new table, but as recommended, we won’t use the uuid as Primary Key ! We will use a new feature of MySQL 8.0.30: GIPK Mode !
MySQL > SET sql_generate_invisible_primary_key=1;
MySQL > CREATE TABLE my_table3 (
uuid BINARY(16) NOT NULL UNIQUE,
name VARCHAR(20), beers INT UNSIGNED);
MySQL > SHOW CREATE TABLE my_table3\G
*************************** 1. row ***************************
Table: my_table3
Create Table: CREATE TABLE `my_table3` (
`my_row_id` bigint unsigned NOT NULL AUTO_INCREMENT /*!80023 INVISIBLE */,
`uuid` binary(16) NOT NULL,
`name` varchar(20) DEFAULT NULL,
`beers` int unsigned DEFAULT NULL,
PRIMARY KEY (`my_row_id`),
UNIQUE KEY `uuid` (`uuid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
Now let’s insert some records and see if they are inserted sequentially and if the UUID’s value is completely random:
MySQL > INSERT INTO my_table3 (uuid, name, beers)
VALUES (UUID_TO_BIN(uuid_v4()),'Kenny', 3),
(UUID_TO_BIN(uuid_v4()), 'lefred', 1);
MySQL > SELECT * FROM my_table3;
+------------------------------------+--------+-------+
| uuid | name | beers |
+------------------------------------+--------+-------+
| 0x5A28E5482CDF4B3D89A298ECA3F3703B | Kenny | 3 |
| 0x94662BF4DC2F469489D868820B7B31E5 | lefred | 1 |
+------------------------------------+--------+-------+
MySQL > SELECT BIN_TO_UUID(uuid), name, beers FROM my_table3;
+--------------------------------------+--------+-------+
| bin_to_uuid(uuid) | name | beers |
+--------------------------------------+--------+-------+
| 5a28e548-2cdf-4b3d-89a2-98eca3f3703b | Kenny | 3 |
| 94662bf4-dc2f-4694-89d8-68820b7b31e5 | lefred | 1 |
+--------------------------------------+--------+-------+
So far, so good.. let’s add some more records:
MySQL > INSERT INTO my_table3 (uuid, name, beers)
VALUES (UUID_TO_BIN(uuid_v4()),'Scott', 10),
(UUID_TO_BIN(uuid_v4()), 'Lenka', 0);
MySQL > SELECT BIN_TO_UUID(uuid), name, beers FROM my_table3;
+--------------------------------------+--------+-------+
| bin_to_uuid(uuid) | name | beers |
+--------------------------------------+--------+-------+
| 5a28e548-2cdf-4b3d-89a2-98eca3f3703b | Kenny | 3 |
| 94662bf4-dc2f-4694-89d8-68820b7b31e5 | lefred | 1 |
| 615fae32-d6c8-439c-9520-5d3c8bfa934b | Scott | 10 |
| 80a01a29-489b-419d-bca1-05a756ad9d9d | Lenka | 0 |
+--------------------------------------+--------+-------+
We can see that indeed, the UUIDs are completely random and sequentially added to the table. The reason of that optimal sequential insertion is that the invisible Primary Key is an auto_increment.
In summary, if you want to use UUID’s in MySQL, it’s recommended to use UUID v1, those generated by MySQL, and store them as binary using the swap flag.
If for some reason you need UUID v4, it is recommended to let MySQL and InnoDB handle the primary key by enabling GIPK mode.
Window functions in MySQL offer developers an efficient way to view and compare data across a result set. In this post we will talk about using aggregate functions as window functions and break down the different sections of a window frame.Planet MySQL
Whilst not part of the LAMP stack per-se, you will need a MySQL client in order to be able to upload and make changes to your database schema. MySQL clients that could be used include: the traditional MySQL client; MySQL shell; MySQL Workbench as well as phpMyAdmin. At the stage the most efficient of these clients will be MySQL Shell.Planet MySQL
To build the infrastructure you will both need an account and a tenancy within Oracle Cloud Infrastructure (OCI) account. If you do not have these, then please click here. Note the Oracle very often offers a free trial period which provides more than enough credits to complete the architecture described in this blog.Planet MySQL
In the last few years, the Marine Corps has been modernizing its infantry forces en masse.
The average Marine Infantryman has seen a significant upgrade in their guns and gear in the last decade.
Marine fires the M27 (Photo: Cpl. Michaela Gregory)
In the wake of F-35s, remote control missile launching trucks, and drones, the infantry rifle doesn’t seem all that special.
Or is it?
Today, we’re going to walk through the current infantry rifle and the gear that adorns it. If you’ve been curious about what Marines are carrying (or what to grab similar gear for your own rifle), keep reading!
Table of Contents
Loading…
How Did We Get Here?
The Marine Corps created the A2, for better or worse, and stuck to the A4 model of the gun.
Everyone moved to the M4, but the Marine Corps clung to the M16A4 for longer than necessary.
The M4 saw adoption by the infantry in 2015, and only two years later, the M27 would go on to be the rifle fielded by infantry forces.
M4
Marines picked up the M27 in 2009 and began issuing the gun in 2010, starting with the 2nd Battalion 7th Marine regiment.
The M27 would replace the M249 SAW and would become an automatic rifle tasked with laying down suppressive fire. Marines in Afghanistan fell in love with the weapon, and the Marine Corps was impressed.
Ya’ boy with an ACOG equipped M249 Helmand Province Afg 2009
Impressed enough, they replaced the M4 for infantry forces without needing a very long and drawn-out testing procedure.
By now, the average active-duty infantryman is armed with an M27. It seems as though Marines in weapons platoons and companies are still carrying the M4.
The Infantry Rifle
Look at the M27 and the M4. They look pretty dang similar, right? We can call it Stoner’s grandchild.
Well, not just Stoner’s. It has some Hans in it too.
HK designed the HK 416, a piston-driven rifle that’s very clearly related to the M4 series of rifles. To put it simply, the HK 416 is an M4 with the short-stroke gas piston of the G36.
A student assigned to the U. S. Army John F. Kennedy Special Warfare Center and School fires a German HK 416 during foreign weapons training at Fort Bragg. (U.S. Army photo by K. Kassens)
HK took the 416, made a few changes to accommodate the Marine Corps, and called it good. The differences are minimal, and it’s the same rifle at its core.
That base Marine Corps rifle utilizes a 16.5-inch barrel, features a collapsible stock, and utilizes the same STANAG magazines.
Clearly, we aren’t ready for M-LOK in the military because the Marines clung to the quad rail they know and love.
Livin’ that quad rail life.
This was the first time Marines got an ambidextrous safety, but they didn’t bring the HK 416 A5 total ambidextrous controls. The rifle might be considered a carbine, but it can be rather hefty at 7.9 pounds.
While the M27 might be the primary rifle, we also need to mention the M38.
The M38 is the DMR variant of the weapon, and the only real difference is the optic equipped to the weapon.
Speaking of optics, the Marine Corps is in a transition period. They are currently fielding three optics with the various rifles in their infantry squads.
Trijicon 3.5×35 BAC with RMR
Trijicon 3.5×35 BAC
When the M27 hit the fleet, the first optic adopted was the Trijicon 3.35×35 with an RMR riding backup.
Marines have long used the ACOG series of optics on M4s and M16A4s, and it’s been a successful team-up. The new model, the SU-258/PVQ Squad Day Optic, dialed magnification back a hair.
The Marine Corps plans to replace the ACOG with the Trijicon VCOG. The VCGO presents the first mass-adopted LPVO for the United States military and will give Marines a very versatile and capable 1-8X level of magnification.
LPVOs are taking over the world of optics, and it’s interesting to see the Marines being early adopters.
Trijicon 1-8X VCOG
The VCOG allows Marines to have an optic that works equally well at close and long ranges. From the ground up, the optic is designed to address the needs of the military.
Trijicon designed the optic with a first focal plane configuration, so the reticle grows and shrinks as the magnification increases and decreases. The reticle’s design ensures it can be used effectively at nearly any range.
Inside sits a segmented circle that’s massive. Since it shrinks when the magnification is low, it works much like a red dot at lower magnifications.
Trijicon 1-8X VCOG
As the magnification increases, the BDC, wind calls, and illuminated crosshair becomes large and more in play for longer-range shots.
It’s a well-designed reticle that’s simple but versatile. Trijicon equipped the VCOG with 11 brightness settings, including two night vision settings.
Marines are amphibious by nature, and the VCOG can be submerged to 66 feet, so ship to shore won’t be an issue.
Designated marksmen will have their M38s equipped with the Leupold TS-30A2 MARK 4 MR/T optic.
Marines wielded this optic on the Mk 12 DMRs used by Marine Corps designated marksmen, so the Marines had them in inventory and had institutional knowledge of the platform.
Plus, Marines didn’t break it in the GWOT, so it’s tough. This optic uses a 2.5-8X magnification range with a 36mm objective lens.
Leupold TS-30A2 MARK 4 MR/T 2.5-8X
The turrets are fingertip adjustable, the reticle allows for range estimation, and the optic is rugged, well made, and water, shock, and fog proof.
Interestingly, with the adoption of the VCOG 1-8X being the new optic of choice, the older MARK 4 might give DMs an outdated optic. The MARK 4 is an SFP design and doesn’t have the same versatility as the 1-8X.
Marine Corps Gear
Harris 9-13 S-LM Bipod
Harris 9-13 S-LM Bipod
Marines love the Harris bipods. They’ve been in use in various precision rifles and DMRs for decades now. Automatic fire requires stability to control, and bipods lend stability.
As soon as the M27 replaced the SAW, the Marine Corps adopted a bipod to provide supportive fire.
From photos, the bipod doesn’t seem to be equipped for every M27 in the Marine Corps and seems to be reserved for Marines in the DMR and automatic rifleman role.
Harris 9-13 S-LM Bipod
The 9-13 numbers reference the 9-13 inches of adjustable height. The S-LM bipod uses notched legs that can be adjusted independently of each other.
With the S-LM series, the bipod legs deploy automatically with spring-loaded action. These legs make the bipods easier to adjust when prone and when dealing with uneven terrain.
Harris bipods are surprisingly affordable for their quality. They can take a serious beating and cost less than $100.
They are the premier polymer magazine. Every generation sees massive improvements that most shooters never notice.
When the M27 first rolled out, the Gen3 hadn’t seen the light of day, and the Gen2 magazines had issues with the M27.
This led the Marine Corps to ban the use of PMAGs, and my unit banned them while we were deployed, even though we had zero M27s at this time. Common sense isn’t always common.
PMAGs Gen 2 Vs Gen 3
Anyway, Magpul went back to the drawing board and made changes that allowed the Gen3 PMAGs to work flawlessly in the M27. The Gen3 Pmags use a stronger polymer, a more aggressive grip texture, and improved upon the famed design.
This made the most dependable PMAG ever created, and they are now the standard-issue magazine of the United States Marine Corps.
Before the advent of the Blue Force Gear VCAS sling, it was a dark time. As a Marine, you had only a few choices. You could use a 3-Point, but 3-points are a mess of straps and buckles that is a real pain in the ass.
You could use a 1-point which meant the rifle would be bouncing around and occasionally swinging into your crotch area and often made letting the weapon hang quite uncomfortable.
Then the VCAS or Vickers Combat Application Sling rescued us.
Blue Force Gear Vickers Sling
My unit got them fairly early, and it changed my life and how I carried my rifle. The tactical 2-point became the dominant option, and the VCAS remains the issued sling of the Marine Corps and the M27.
The VCAS is made from durable 1.25-inch webbing and features a ton of adjustment. You can adjust the sling for armored or nonarmored use. A quick-adjust pull tab makes it easy to adjust the sling rapidly.
Vickers Sling Pull Tab
When properly set up, a user can adjust the sling to have the rifle hanging loose and easy to maneuver, but it can be tight enough to go hands-off in the pull of a tab.
When tightened, it’s easy to climb, carry a wounded comrade, and more. In terms of durability, well, I still have mine, going on over a decade now, and it still functions perfectly.
Every Marine infantryman will also have his rifle equipped with a suppressor.
Yep, it’s one of the first wide-scale issuing of cans amongst a conventional military force. The USMC has been experimenting with suppressors in the infantry for years and only recently pulled the trigger.
The NT4 is an absolute workhorse and has been kicking around since the late 90s. It’s not the most modern suppressor but seems to offer exactly what the Marine Corps wants as a price point they can stomach.
It’s known to be quite rugged, and you want rugged when it comes to Marines.
The Marine Corps officially adopted the PEQ-16 to replace theolder PEQ-15. The PEQ 16 offered Marines a laser aiming unit with a built-in weapon light. The weapon light is pitiful, with a mere 125 lumens of white light.
PEQ-16
Although it’s rare to use white lights when NVGs and IR lasers typically dominate night fighting, in the face of lights from Cloud Defensive, Modlite, and even Surefire, designed in 2008, the 125 lumens of light is a penlight.
The device also has visible IR lasers, an IR flood setting, and more. It allows Marines to effectively and efficiently aim at night, mark targets, and more.
Final Thoughts
For as long as I can remember, the Marine Corps was the hand-me-down branch, but they seem to be leading the way in gear and rifles these days.
The Marine Corps modernization is equipping Marines with some pretty high-speed gear. The rifles will soon be outfitted with cans and LPVOs making them quite modern, albeit quite heavy.
Marines training with the M27 (Photo: Cpl. Michaela Gregory)
Is that a sweet modern setup? Or is a dang near 13-pound rifle just too much? Let me know in the comments below. For guns you can buy, check out our guide to Military Surplus Rifles & Shotguns.