Laravel Livewire Fullcalendar Integration Example

https://www.mywebtuts.com/upload/blog/livewire-fullcalendar-main.png

Hi Friend,

In this example, I will learn you how to use fullcalendar with livewire example. We will explain step-by-step laravel livewire fullcalendar integration. you can easily make livewire fullcalendar integration in laravel. we will describe laravel livewire fullcalendar integration.

Here, I will give you full example for simply livewire fullcalendar integration in laravel native as bellow.

Step 1 : Install Laravel App

In First step, We need to get fresh laravel version application using bellow command. So Let’s open terminal and run bellow command.

composer create-project --prefer-dist laravel/laravel blog

Step 2 : Setup Database Configuration

After successfully install laravel app thenafter configure databse setup. We will open “.env” file and change the database name, username and password in the env file.

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=Enter_Your_Database_Name
DB_USERNAME=Enter_Your_Database_Username
DB_PASSWORD=Enter_Your_Database_Password

Step 3 : Install Livewire

In this step, You will simply install livewire to our laravel application using bellow command:

composer require livewire/livewire

Step 4 : Create items Table and Model

In this step we have to create migration for items table using Laravel php artisan command, so first fire bellow command:

php artisan make:model Event -m

After this command you have to put bellow code in your migration file for create items table.

following path: /database/migrations/2021_04_10_102325_create_events_table.php

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateEventsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('events', function (Blueprint $table) {
            $table->id();
            $table->string('title');
            $table->string('start');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('events');
    }
}

Now we require to run migration be bellow command:

php artisan migrate

After you have to put bellow code in your model file for create items table.

following path:/app/Models/Event.php

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Event extends Model
{
    use HasFactory;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'title',
        'start',
    ];
}

Step:5 Create Route

In thi step,now, we need to add resource route for livewire fullcalendar integration in application. so open your “routes/web.php” file and add following route.

<?php

use Illuminate\Support\Facades\Route;
use App\Http\Livewire\Calendar;
use App\Models\Event;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::view('/', 'home');

Livewire::component('calendar', Calendar::class);

Step 6 : Create Component

Now, You can create livewire component using bellow command, So Let’s run bellow command to create calendar form component:

php artisan make:livewire calendar

Now they created fies on both path:

app/Http/Livewire/Calendar.php
resources/views/livewire/calendar.blade.php

Now first file we will update as bellow for Calendar.php file.

app/Http/Livewire/Calendar.php

<?php
namespace App\Http\Livewire;
use Livewire\Component;
use App\Models\Event;

class Calendar extends Component
{
    public $events = '';

    public function getevent()
    {       
        $events = Event::select('id','title','start')->get();

        return  json_encode($events);
    }

    /**
    * Write code on Method
    *
    * @return response()
    */ 
    public function addevent($event)
    {
        $input['title'] = $event['title'];
        $input['start'] = $event['start'];
        Event::create($input);
    }

    /**
    * Write code on Method
    *
    * @return response()
    */
    public function eventDrop($event, $oldEvent)
    {
      $eventdata = Event::find($event['id']);
      $eventdata->start = $event['start'];
      $eventdata->save();
    }

    /**
    * Write code on Method
    *
    * @return response()
    */
    public function render()
    {       
        $events = Event::select('id','title','start')->get();

        $this->events = json_encode($events);

        return view('livewire.calendar');
    }
}

Step 7: Create View

Here, we will create blade file for call fullcalendar route. in this file we will use @livewireStyles, @livewireScripts so let’s add it

resources/views/home.blade.php

<html>
<head>
    @livewireStyles
</head>
<body>
    <livewire:calendar />
    @livewireScripts
    @stack('scripts')
</body>
</html>

after,I will create calendar componet blade file.

resources/views/livewire/calendar.blade.php

<style>
    #calendar-container{
        width: 100%;
    }
    #calendar{
        padding: 10px;
        margin: 10px;
        width: 1340px;
        height: 610px;
        border:2px solid black;
    }
</style>

<div>
  <div id='calendar-container' wire:ignore>
    <div id='calendar'></div>
  </div>
</div>

@push('scripts')
    <script src='https://cdn.jsdelivr.net/npm/fullcalendar@5.3.1/main.min.js'></script>
    
    <script>
        document.addEventListener('livewire:load', function() {
            var Calendar = FullCalendar.Calendar;
            var Draggable = FullCalendar.Draggable;
            var calendarEl = document.getElementById('calendar');
            var checkbox = document.getElementById('drop-remove');
            var data =   @this.events;
            var calendar = new Calendar(calendarEl, {
            events: JSON.parse(data),
            dateClick(info)  {
               var title = prompt('Enter Event Title');
               var date = new Date(info.dateStr + 'T00:00:00');
               if(title != null && title != ''){
                 calendar.addEvent({
                    title: title,
                    start: date,
                    allDay: true
                  });
                 var eventAdd = {title: title,start: date};
                 @this.addevent(eventAdd);
                 alert('Great. Now, update your database...');
               }else{
                alert('Event Title Is Required');
               }
            },
            editable: true,
            selectable: true,
            displayEventTime: false,
            droppable: true, // this allows things to be dropped onto the calendar
            drop: function(info) {
                // is the "remove after drop" checkbox checked?
                if (checkbox.checked) {
                // if so, remove the element from the "Draggable Events" list
                info.draggedEl.parentNode.removeChild(info.draggedEl);
                }
            },
            eventDrop: info => @this.eventDrop(info.event, info.oldEvent),
            loading: function(isLoading) {
                    if (!isLoading) {
                        // Reset custom events
                        this.getEvents().forEach(function(e){
                            if (e.source === null) {
                                e.remove();
                            }
                        });
                    }
                }
            });
            calendar.render();
            @this.on(`refreshCalendar`, () => {
                calendar.refetchEvents()
            });
        });
    </script>
    <link href='https://cdn.jsdelivr.net/npm/fullcalendar@5.3.1/main.min.css' rel='stylesheet' />
@endpush

Now we are ready to run our example so run bellow command for quick run:

php artisan serve

Now you can open bellow URL on your browser:

http://localhost:8000/
Preview

Event Fullcalendar
Add Event Fullcalendar
Drag And Drop Fullcalendar

It will help you..

Laravel News Links

How to Insert at the First Position of a List in Python

https://blog.finxter.com/wp-content/uploads/2021/05/insert_list_first_pos.jpg

Problem Formulation: How to insert at the first position of a list in Python?

How to Insert at the First Position of a List in Python

Solution:

Use the list.insert(0, x) element to insert the element x at the first position 0 in the list. All elements j>0 will be moved by one index position to the right.

>>> lst = [5, 1, 3, 8, 7, 9, 2]
>>> lst.insert(0, 42)
>>> lst
[42, 5, 1, 3, 8, 7, 9, 2]

You create the list [5, 1, 3, 8, 7, 9, 2] and store it in the variable lst. Now, you insert the new element 42 to the first position in the list with index 0. Note that Python uses zero-based indexing so the first position has index 0. The resulting list has 8 elements instead of only 7. The new element 42 is at the head of the list. All remaining elements are shifted by one position to the right.

To dive deeper into the very important list.insert() method, I’d recommend you watch my full explainer video here:

Note that some people recommend to insert an element at the first position of a list like so:

>>> lst = [1, 2, 3]
>>> lst = ['new'] + lst
>>> lst
['new', 1, 2, 3]

While the output looks the same, this doesn’t actually solve the problem because the list concatenation operator list_1 + list_2 creates a new list with the elements of two existing lists. The original lists remain unchanged. Only by assigning it to the variable lst, you overwrite it. However, if another variable would point to the old list, this option based on list concatenation wouldn’t work because the old list remains unchanged.

>>> lst_1 = [1, 2, 3]
>>> lst_2 = lst_1
>>> lst_2 = ['new'] + lst_2

In this example, you create two lists lst_1 and lst_2 both referring to the same list object in memory. You try to insert the new element at the beginning of the list using the problematic method. And you obtain a clash—both lists refer to different objects in memory!

>>> lst_2
['new', 1, 2, 3]
>>> lst_1
[1, 2, 3]

Thus, the list.insert(0, 'new') method is superior to list concatenation to insert an element at a given position in the list.

>>> lst_1 = [1, 2, 3]
>>> lst_2 = lst_1
>>> lst_2.insert(0, 'new')
>>> lst_1
['new', 1, 2, 3]
>>> lst_2
['new', 1, 2, 3]

Both variables now refer to the same, changed list object.

The post How to Insert at the First Position of a List in Python first appeared on Finxter.Finxter

MySQL Workbench 8.0.25 has been released

Dear MySQL users,

The MySQL developer tools team announces 8.0.25 as our General Availability
(GA) for MySQL Workbench 8.0.

For discussion, join the MySQL Workbench Forums:
http://forums.mysql.com/index.php?152

The release is now available in source and binary form for a number of
platforms from our download pages at:

http://dev.mysql.com/downloads/tools/workbench/

Enjoy!

Changes in MySQL Workbench 8.0.25 (Not yet released, General
Availability)

   This release contains no functional changes and is published
   to align the version number with the MySQL Server 8.0.25
   release.

On Behalf of MySQL Engineering Team,
Prashant Tekriwal

The MySQL Workbench Developer Central Site

6 Mobile Apps to Help Dementia Patients and Their Caregivers

https://static1.makeuseofimages.com/wordpress/wp-content/uploads/2021/05/My_House_Of_Memories.jpg

While it’s no secret that mobile apps have ability to help us in different areas of our lives, you may be surprised to learn that there are a growing number of apps specifically designed to assist people with dementia. These vary from memory games to help slow down the progression of dementia, to reminder apps that can help dementia patients remain more independent.

In addition, there are apps aimed at supporting family members and caregivers too. Let’s take a look at some of the best apps for those with dementia, as well as their loved ones.

1. MemoClock

Image Gallery (3 Images)

Memo clock receiver
Expand
Memoclock app home screenshot
Expand
Memoclock app send message screenshot
Expand

MemoClock was created by Dan Mogenson after his father was diagnosed with Alzheimer’s disease. The app connects a caregiver with their friend or relative who has dementia and allows them to send reminders directly to the other person’s phone. For daily tasks, you can set repeat reminders that create an alert at the same time each day. The app can also receive pictures and voice messages.

Aside from assisting individuals with daily tasks and reminding them of appointments, the app also helps to tackle loneliness by providing a simple and direct line of communication. For MemoClock to work, both the sender and the receiver need a compatible smartphone; thankfully, most devices are supported.

Download: MemoClock for Android | iOS (Free, subscription available)

2. Train Your Brain

Image Gallery (3 Images)

Train your brain memory game options
Expand
Train your brain memory game how to
Expand
Train your brain memory game pairs
Expand

While brain games provide great mental stimulation for people of all ages, they’re particularly beneficial for older adults who are at high risk of, or are already living with, dementia.

Unlike other memory apps, Train Your Brain was specifically designed with seniors in mind. It has a very simple, yet stimulating, interface and a variety of different memory games to choose from. These include matching pairs of cards and memorizing short shopping lists.

There are plenty of free ad-supported games to choose from. Alternatively, you can pay a small fee to unlock more games and remove the ads.

Download: Train Your Brain for Android | iOS (Free, premium version available)

3. My House Of Memories


My House Of Memories was created by National Museums Liverpool, designed for individuals living with dementia or Alzheimer’s. However, it can also be enjoyed by anyone with an interest in history. The purpose of the app is to spark meaningful conversations and bring up positive memories.

While using the app, individuals and their families or caregivers can reminisce together about simple historic objects. They will also hear familiar sounds that encourage positive memories and promote wellbeing. If you like a particular object or find that it sparks a good memory, then you can store it for later and add it to a memory display.

Read more: How iPods and Old Songs Can Treat the Symptoms of Dementia

To help people with dementia remember their family, friends, and personal memories, there’s even the option to upload your own photos to a new or existing memory album.

Download: My House Of Memories for Android | iOS (Free)

4. Dementia Guide Expert

Image Gallery (3 Images)

Dementia Guide Home
Expand
Dementia Guide Article Example
Expand
Dementia Guide Medication Article
Expand

A dementia diagnosis can be extremely scary, but the more you know about the stages of dementia, the easier it is to plan for the future. National dementia experts designed this guide app to help support individuals with dementia, as well as their friends and families.

The app offers helpful tips to help you manage and understand dementia as a condition, while also providing access to a library of further information and linked resources. Although the interface may look outdated, the app contains a wealth of relevant information and is easy to navigate and explore.

Download: Dementia Guide Expert for Android | iOS (Free)

5. Medisafe

Image Gallery (3 Images)

Medisafe Medication Example
Expand
Medisafe schedule example
Expand
Medisafe manage appointments screen
Expand

Remembering to take your medication can be tricky at the best of times, let alone when you’re struggling with your memory. Medisafe is a free, award-winning pill reminder and medication tracking app. It’s designed to make it easier to stay on top of your medication and take it regularly each day.

Read more: The Best Medicine Reminder Apps

The app’s Medifriend functionality also allows family, friends, or caregivers to see what medication the user has taken each day. It can even give a report for you to share with your doctor. Whether you’re managing one prescription or several, the app helps you keep track of what to take and when to take it.

Download: Medisafe for Android | iOS (Free, subscription available)

6. Mojo

Image Gallery (3 Images)

Mojo Home page
Expand
Mojo notes page
Expand
Mojo Forum Page
Expand

Learning that someone you love has Alzheimer’s or any form of dementia can put stress on your relationship. The Mojo app is designed to help and support family members or friends as they learn how to become good caregivers for their loved ones. The app has a free advice center and a forum with articles designed to help you find moments of joy in a difficult time.

The app also has a wealth of resources designed to help you manage troublesome dementia behaviors, plus space to share experiences with other app users. You can also upload images of friends and family, track care reports, and make your own care notes and checklists from the homepage of the app.

When you sign up for the first time, you’re automatically given a 30-day free trial. After this, you need to upgrade to access additional premium features. At the time of writing, Mojo’s iOS app appeared to be unavailable.

Download: Mojo for Android (Free trial, subscription required)

Utilizing Phone Apps for Dementia Patients

There is a wide range of phone apps that people living with dementia can use to help improve their memory and manage their daily lives. There are also lots of apps whose aim is to provide support to caregivers and families. Using these apps may not cure dementia, but they can make living with the disease a little more bearable.

These are just a few of the available dementia care apps currently on the Play Store and App Store, but there are many others to consider. As more people begin using technology to help manage their dementia diagnosis, more of these apps should start to appear.

MUO – Feed

Elon Musk Finally Explains the Reason for His Bizarre Tweets

http://img.youtube.com/vi/FuaDWyCnJxs/0.jpg

Elon Musk, the CEO of Tesla, SpaceX, and other startups, provided an explanation for his bizarre tweets that have gotten him into trouble with regulators, customers and competitors.

Elon Musk’s Reason for Bad Tweets

During Musk’s controversial Saturday Night Live appearance, the CEO of Tesla and SpaceX admitted to posting strange things online, saying it’s how his brain is hardwired.

Look, I know I sometimes say or post strange things, but that’s just how my brain works. To anyone I’ve offended, I just want to say I reinvented electric cars, and I’m sending people to Mars in a rocket ship. Did you think I was also going to be a chill, normal dude?

Musk probably isn’t lying by blaming his bizarre or downright insulting tweets on his eccentricity. After all, we’re talking about the same guy who changed his job title to the "Technoking of Tesla" in a US Securities and Exchange Commission filing.

Now, one would be right to argue that PayPal’s former co-founder should know better than that. Indeed, there are plenty of examples of Musk’s aggressive and offensive tweeting.

The Most Bizarre Musk Tweets

In April 2020 during the height of the coronavirus pandemic when the US was reporting more than 20,000 new daily cases, the Tesla chief demanded that the government reopen the economy and "FREE AMERICA NOW."

Musk also caused quite a turmoil with a thinly-veiled threat in another tweet in which he announced that workers who unionized would lose their company-paid stock options. The National Labor Relations Board was unsympathetic, ordering Musk to delete that one.

Related: Must-Have Smartphone Apps for Electric Car Owners

Offending British cave explorer Vernon Unsworth by calling him a "pedo guy" in front of his millions of Twitter followers definitely isn’t one of Musk’s finer moments either.

"Funding Secured"

But the most famous Musk tweet has got to be a 2018 post in which he announced taking Tesla private at $420/share. Shares of Tesla tumbled following the "funding secured."

It was this tweet in particular that prompted the US Securities and Exchange Commission to sue Musk in federal court, charging the technology entrepreneur with committing securities fraud by manipulating stock prices with tweets. All in all, the "funding secured" tweet cost Musk a $20 million fine and a position as Tesla’s chairman of the board.

MUO – Feed

Memes that made me laugh 57

https://1.bp.blogspot.com/-Rfx69VysSJE/YJilu3iCTjI/AAAAAAAAsT8/ilwCN_04Wr87zC_wb5TW_tgdzKAEumMoQCPcBGAsYHg/w400-h225/Meme%2B-%2BCommunism.png

 

Gathered over the past week from around the Internet.


More next week.

Peter

Bayou Renaissance Man

How to Exercise All Those Little Muscles in Your Feet That You Forgot (and Why You Should)

https://i.kinja-img.com/gawker-media/image/upload/c_fill,f_auto,fl_progressive,g_center,h_675,pg_1,q_80,w_1200/3a244b6516ee43cce8e9e4f81501c850.jpg

Photo: New Africa (Shutterstock)

It’s easy to exercise the muscles you can see—your biceps, your quads—but there are more muscles in your body than just the big ones. We’ve talked before about the muscles in your hands and forearms, which help to give you a strong grip, and today I’d like to bring your attention to your feet.

Your feet contain more little muscles than you probably realize, including four separate layers of them on the bottom of your feet. These “intrinsic” muscles help support your arch, move your toes, and more.

If you engage in a variety of exercises, the muscles of your feet and lower legs will probably get plenty of work. But it doesn’t hurt to take a few minutes to give them some special attention—and if you’re a runner, or if you need extra support for your feet in exercises like yoga, you might find that some foot exercises help you with your other activities.

Try some foot yoga

Yoga can provide a mindful focus on the way our body works, strengthening and stretching muscles in ways we don’t normally think about. Fortunately, Adriene (of Yoga With Adriene) has a yoga flow for the feet, so you can follow along and get to know all those little foot muscles.

G/O Media may get a commission

Do a strength routine for your feet

If yoga isn’t your style, you can do foot exercises in sets and reps. This video from PodiumRunner will show you a few. One that might blow your mind if you never thought about your arch as a muscle: stand with your feet flat on the ground, then pull your arch upwards, making your footprint shorter and your instep taller. You have a muscle that does this! You can contract it on purpose! Amazing.

Scrunch a towel

One exercise not mentioned above is the towel scrunch. Set a dish towel on the ground, place your toes on it, then (sitting or standing) scrunch your toes to bunch the towel up. Repeat until the whole towel is in a heap under your feet.

This is a fun one because you can actually load it. Put a small weight, like a water bottle, on the opposite end of a towel, to make it harder to pull toward you.

Run on uneven ground

The real function of our feet is to support us as we do other things in life, so don’t think you’re limited to just doing focused foot exercises on their own. Going out for a trail run, or even jogging on sand or grass, will constantly challenge your feet to support you at a variety of angles and positions. If you have a place you can safely run barefoot, give that a try as well.

 

Lifehacker

Elon Musk Defies Haters, Absolutely Crushed His Opening Monologue on SNL

https://www.louderwithcrowder.com/media-library/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpbWFnZSI6Imh0dHBzOi8vYXNzZXRzLnJibC5tcy8yNjE1MzUzMi9vcmlnaW4uanBnIiwiZXhwaXJlc19hdCI6MTY0MzM0NTk3MH0.r1eisjVsTE2nsAINp6VmnFd0eDRQHFAopoeLCA81aV0/image.jpg?width=980

Elon Musk hosted SNL last night, after a few weeks of controversy over his appearance. Musk is notorious for being two things progressive douchelords hate: a billionaire and someone who has different opinions than they do. The people who write and/or perform for SNL are progressive douchelords. It was no surprise they were allegedly told they didn’t have to come to work if they didn’t want to. Not sure if anyone boycotted. But Musk showed up. And he absolutely crushed his opening monologue.


Elon Musk Monologue – SNL

youtu.be

I’m actually making history tonight as the first person with Asperger’s to host SNL. Or, at least the first to admit it.

Actually, this "misleading claim" is currently being fact-checked by Twitter. Dan Aykroyd "was the first person with Asperger’s syndrome to host the show." Though they may have him confused with being an asssburger. Just saying, Dan Aykroyd is both the least talented Blues Brother, Ghostbuster and groundskeeper at the Bushwood Country Club.

To anyone I’ve offended [on Twitter], I just want to say, I reinvented electric cars, and I’m sending people to Mars on a rocket ship. Did you think I was also going to be a chill, normal dude?

All I hear all the time is, ‘Elon Musk, all he ever does is smoke weed on podcasts.’ Like I go from podcast to podcast lighting up joints. It happened once. It’s like reducing O.J. Simpson to "Murderer." It happened one time. Fun fact. O.J. Also hosted this show in ’79. And again in ’96. Killed both times."

I ask for so little in life. Please, to the god or gods of content, have OJ Simpson respond to Musk on Twitter.

The controversy was much ado about nothing. Elon Musk was funny. A Chinese rocket didn’t crash anywhere in our country. SNL, once known for brilliant political satire, once again ignored the wealth of material provided them by Joe Biden this week. Overall, another bland Saturday at 30 Rock.

But Elon was still really funny.

Looking for a fashionable way to support Louder with Crowder? Get your swag at Crowdershop today!


Would Caitlyn Jenner Actually Improve California? | Louder With Crowder

youtu.be

Louder With Crowder

How to Find Duplicate Data in a Linux Text File With uniq

https://static1.makeuseofimages.com/wordpress/wp-content/uploads/2021/05/remove-duplicate-liens.png

Have you ever come across text files with repeated lines and duplicate words? Maybe you regularly work with command output and want to filter those for distinct strings. When it comes to text files and the removal of redundant data in Linux, the uniq command is your best bet.

In this article, we will discuss the uniq command in-depth, along with a detailed guide on how to use the command to remove duplicate lines from a text file.

What Is the uniq Command?

The uniq command in Linux is used to display identical lines in a text file. This command can be helpful if you want to remove duplicate words or strings from a text file. Since the uniq command matches adjacent lines for finding redundant copies, it only works with sorted text files.

Luckily, you can pipe the sort command with uniq to organize the text file in a way that is compatible with the command. Apart from displaying repeated lines, the uniq command can also count the occurrence of duplicate lines in a text file.

How to Use the uniq Command

There are various options and flags that you can use with uniq. Some of them are basic and perform simple operations such as printing repeated lines, while others are for advanced users who frequently work with text files on Linux.

Basic Syntax

The basic syntax of the uniq command is:

uniq option input output

…where option is the flag used to invoke specific methods of the command, input is the text file for processing, and output is the path of the file that will store the output.

The output argument is optional and can be skipped. If a user doesn’t specify the input file, uniq takes data from the standard output as the input. This allows a user to pipe uniq with other Linux commands.

Example Text File

We’ll be using the text file duplicate.txt as the input for the command.

127.0.0.1 TCP
127.0.0.1 UDP
Do catch this
DO CATCH THIS
Don't match this
Don't catch this
This is a text file.
This is a text file.
THIS IS A TEXT FILE.
Unique lines are really rare.

Note that we have already sorted this text file using the sort command. If you are working with some other text file, you can sort it using the following command:

sort filename.txt > sorted.txt

Remove Duplicate Lines

The most basic use of uniq is to remove repeated strings from the input and print unique output.

uniq duplicate.txt

Output:


Notice that the system doesn’t display the second occurrence of the line This is a text file. Also, the aforementioned command only prints the unique lines in the file and doesn’t affect the content of the original text file.

Count Repeated Lines

To output the number of repeated lines in a text file, use the -c flag with the default command.

uniq -c duplicate.txt

Output:


The system displays the count of each line that exists in the text file. You can see that the line This is a text file occurs two times in the file. By default, the uniq command is case-sensitive.

Print Only Repeated Lines

To only print duplicate lines from the text file, use the -D flag. The -D stands for Duplicate.

uniq -D duplicate.txt

The system will display output as follows.

This is a text file.
This is a text file.

Skip Fields While Checking for Duplicates

If you want to skip a certain number of fields while matching the strings, you can use the -f flag with the command. The -f stands for Field.

Consider the following text file fields.txt.

192.168.0.1 TCP
127.0.0.1 TCP
354.231.1.1 TCP
Linux FS
Windows FS
macOS FS

To skip the first field:

uniq -f 1 fields.txt

Output:

192.168.0.1 TCP
Linux FS

The aforementioned command skipped the first field (the IP addresses and OS names) and matched the second word (TCP and FS). Then, it displayed the first occurrence of each match as the output.

Ignore Characters When Comparing

Like skipping fields, you can skip characters as well. The -s flag allows you to specify the number of characters to skip while matching duplicate lines. This feature helps when the data you are working with is in the form of a list as follows:

1. First
2. Second
3. Second
4. Second
5. Third
6. Third
7. Fourth
8. Fifth

To ignore the first two characters (the list numberings) in the file list.txt:

uniq -s 2 list.txt

Output:


In the output above, the first two characters were ignored and the rest of them were matched for unique lines.

Check First N Number of Characters for Duplicates

The -w flag allows you to check only a fixed number of characters for duplicates. For example:

uniq -w 2 duplicate.txt

The aforementioned command will only match the first two characters and will print unique lines if any.

Output:


Remove Case Sensitivity

As mentioned above, uniq is case-sensitive while matching lines in a file. To ignore the character case, use the -i option with the command.

uniq -i duplicate.txt

You will see the following output.


Notice in the output above, uniq did not display the lines DO CATCH THIS and THIS IS A TEXT FILE.

Send Output to a File

To send the output of the uniq command to a file, you can use the Output Redirection (>) character as follows:

uniq -i duplicate.txt > otherfile.txt

While sending an output to a text file, the system doesn’t display the output of the command. You can check the content of the new file using the cat command.

cat otherfile.txt

You can also use other ways to send command line output to a file in Linux.

Analyzing Duplicate Data With uniq

Most of the time while managing Linux servers, you will be either working on the terminal or editing text files. Therefore, knowing how to remove redundant copies of lines in a text file can be a great asset to your Linux skill set.

Working with text files can be frustrating if you don’t know how to filter and sort text in a file. To make your work easier, Linux has several text editing commands such as sed and awk that allow you to work efficiently with text files and command-line outputs.

MUO – Feed

Luger Pistol: The Most Famous German 9mm

https://www.pewpewtactical.com/wp-content/uploads/2021/05/7.65mm-Borchardt-and-7.63mm-Mauser.jpeg

When you think about the Gestapo, the Nazis, or World War II in general, one of the first things that likely comes to mind is the Luger.

Easily one of the most iconic and famous pistols of all time, the Luger was an absolute game-changer.

Luger Model 1900
Luger Model 1900

No other pistol of its era seems to boast the impact on modern-day firearms as the Luger.

It led to rapid advancements in the development of semi-auto pistols, changed the world of ammunition, and even led to the development of sub-machine guns.

Today, we’ll explore the lead up to its creation, what made it unique, and why it gained notoriety.

So, let’s take a look at a pistol that deserves every bit of notoriety that it holds, the German Luger.

Table of Contents

Loading…

The Man Behind the Curtain

In 1849, a child was born right on the edge of the Austrian Empire.

His name was Georg Luger.

georg luger
Georg Luger

The son of a surgeon, it might not be too much of a stretch to say that a thorough understanding of complex mechanisms and an innate ability to work with one’s hands was something of an inherited trait.

In 1867, at the age of 18, Georg Luger went on to volunteer for military service. He quickly caught the attention of command and set aside for his expert marksmanship.

The military shipped him to the Austro-Hungarian Military Firearms School at Fort Bruckneudorf, where he first gained interest in firearm design – particularly automatic loading systems.

Imitation is the Sincerest Form of Flattery

It wasn’t long after his stint in the military that Luger met two men who would change his life forever – Hugo Borchardt and Ferdinand Ritter von Mannlicher.

Hugo Borchadt
Hugo Borchadt

Had it not been for the creation of these two friends, the Luger pistol would likely never see the light of day.

Hugo Borchardt was a firearms designer who created a rather strange-looking pistol known as the C-93.

A novel and complex “toggle” action system chambered a round within the gun.

With this action came an even more interesting round — the 7.65mm x 25mm. The cartridge was specifically designed by Borchardt for use with his C-93.

Borchardt Semi Automatic Pistol C93
Borchardt C-93

At this point, Luger had worked in armament development for years with Mannlicher, specifically on rifle magazine designs.

The creation of firearms was no mystery to him.

After studying the C-93, he began to realize several changes could be made to produce a truly spectacular firearm.

The result…the Luger.

Luger Patent Drawing
Cutaway drawing of the Luger design from Georg Luger’s 1904 patent. (Photo: Rock Island Auction Co)

The Creation of the Luger

One of the chief changes Luger made to the C-93 was simplifying the toggle action.

He realized there were too many moving parts within it, and that simpler proves better with virtually any system.

Additionally, he found the vertical alignment of the C-93 handle a bit awkward to grip. So, he angled the Luger so that it would naturally align with the target.

Cased C-93 Pistol
Note the vertical grip on this C-93. (Photo: Hmaag)

The Luger also possessed a fixed barrel — a trait that led to improved accuracy compared to other pistols at that time.

The end result was a pistol that could intuitively line up with a target and then put a round through with ease even from a distance.

Georg Luger kept the 8-round magazine that fed into the handle from the C-93.

Though his creation is a primitive semi-auto design by today’s standards, the Luger had an incredibly impressive rate of fire for weapons of its time.

And it was thus, in 1898, the Luger was created.

It’s Alive

Manufacturing of the Luger truly began two years later in 1900 when a Deutsche Waffen-und-Munitionsfabriken began production.

Because of this, the initials DWM are often found engraved on the Luger.

One would think that such an iconic German weapon would be pumped out by the truckload for German soldiers, right?

However, that’s not what happened.

Ironically, Switzerland first picked up the Luger — referred to as the Model 1900 — for military use.

Checks out.

To Prepare for Peace…

As the Model 1900 rose in popularity, the German military took notice.

The German Navy adopted the Model 1900 as its standard sidearm in 1904.

However, before its German adoption, the military demanded the fix of one problem — caliber size.

One of the few characteristics Luger retained from the C-93 was the 7.65x25mm round. This turned out to be a slight issue.

7.65mm Borchardt and 7.63mm Mauser
7.65mm Borchardt and 7.63mm Mauser (Photo: Drake00)

The German military wanted a round with more stopping power and better performance.

In response, Georg Luger removed the bottleneck shape of the 7.65x25mm round to create the infamous 9mm.

This new 9mm cartridge quickly gathered a number of names, including 9mm Luger and 9mm Parabellum.

PPTG19eight
9mm goodness

Parabellum comes from an old Latin phrase, si vis pacum, para bellum, meaning, “If you want peace, prepare for war.”

Because of this moniker, the newly created Luger — Pistole 1908 – became known as the Parabellum Pistol.

Luger P08
Luger P08

That name later came to be shortened to simply the P08.

The Luger Comes to the States…Almost

While synonymous with Nazi Germany, the Luger almost became the sidearm of choice for the U.S. military.

On April 16, 1901, the U.S. Army ordered 1,000 Lugers to test for troop use.

However, after significant testing spanning several years, the military opted for the M1911 over the Luger 45 (a .45 ACP Luger variant) in 1907.

45 ACP Luger
Luger in .45 ACP, an exact functional replica of a 1907 US Army Trials Luger. (Photo: Eugene Golubtsov)

The rest, as they say, is history.

However, this brief stint stateside forever impacted the pistole. A salesman named Hans Tauscher represented the Pistole 1908 in the U.S.

His marketing efforts eventually saw the P08 adopting a new name – the Luger.

Hans Tauscher
We have this dude to thanks for the Luger moniker.

The World Wars

While German soldiers were outfitted with the Luger throughout World War I, its impact on the future development of submachine guns is where the Luger left its mark.

Trench warfare made smaller carbine-sized weapons with a high rate of fire incredibly useful for cleaning out enemy troops in trench combat.

With a few slight tweaks, the Luger adapted to this gory task.

Luger P08 Submachine Gun
Luger P08 Submachine Gun

Many Lugers during this time were modded to accept stocks for submachine gunfire.

With the addition of a 32-round drum magazine, the Luger became a truly potent weapon of trench warfare.

Though the Luger would later be replaced by advancements in submachine guns, it certainly paved the way.

Lead-Up to WWII

After World War 1, the Treaty of Versailles greatly limited what Germany was allowed to do militarily.

The German military wasn’t permitted to contain more than 100,000 troops, and restrictions existed on what types of weapons could be produced.

Treaty of Versailles WWI
Treaty of Versailles

One of these restrictions stated pistol calibers measure less than 8mm and pistol barrel length less than 3 5/16-inches.

In response, the Germans shortened the barrel of the Luger to 3-inches, exporting the great majority of these pistols, under the Model 1923 name, to other nations.

While the Germans exported Lugers complying with the Treaty of Versailles’ restrictions, they secretly mass-produced 9mm Lugers with 4-inch barrels for their own use.

The Luger saw action throughout World War II. It impressed with its functionality and became a prize amongst Allied soldiers.

Winter Training Luger P08
Waffen SS privates from the 5th SS Panzer Division firing several Luger P08 during winter training.

Quickly discovering the Allies would take on big risks to take home a Luger, they booby-trapped these pistols – wiring them to mines and grenades.

Post-World War 2

After V-Day, perspectives towards the Luger gradually changed.

Its association with the Nazis was unmistakable. Due to that and improvements in pistol design, the Swiss stopped issuing the Luger to its troops.

However, with the Berlin Wall upon Germany and a division into an Eastern and a Western bloc, the Luger continued to see widespread use amongst the Eastern half.

Berlin Wall
The Berlin Wall (Photo: Noir)

Stasi agents and the Volkspolizei used the Luger extensively throughout communist-run East Germany, the German Democratic Republic.

As further technological improvements entered the firearms market, the Luger gradually fell out of favor.

Soon, it took its place on the shelves of historical weapons.

Kinks in the Armor

The flaws with the Luger became more noticeable as time went on.

The Germans have a reputation for over-designing machinery, and the Luger was no exception to this. (Ever used a Bosch dishwasher…I rest my case.)

German Engineering

Due to very tight tolerances within the inside mechanics of the weapon, it didn’t take much dirt before the Luger would become clogged and unusable.

Soldiers spend the great majority of their time outside in the elements, so this was a problem.

Unlike a Nerf battle, opponents aren’t likely to listen when you call for a “timeout” during an actual war.

Nerf Battle

The Luger also proved incredibly sensitive to pressure changes. It requires high-pressure rounds to fire properly, and using anything less will result in jams.

So, while the Luger was an incredibly accurate weapon with a high rate of fire, it was very susceptible to the environment around it.

These factors combined with the complex design schematics led to difficulties in mass production during wartime.

It’s easy to see why the Luger saw a limited lifespan as a military weapon.

Official production of the Luger lasted until 1942. Though the Walther P-38 replaced the Luger well before that time in 1938.

Walther P38
Walther P-38 (Photo: Wiki Commons)

Conclusion

The Luger truly changed the world of sidearms, making a lasting impact on the world.

Brazil, Bulgaria, Finland, Iran, Norway, Switzerland, and even Turkey used the Luger at some point within their armed forces.

Luger GunsAmerica
Luger (Photo: GunsAmerica)

It led to the widespread proliferation of 9mm pistols and 9mm submachine guns throughout the world after World War I.

So, it’s safe to say that had it not been for the Luger, you may be carrying a very different type of firearm on your person today.

Do you have thoughts on the Luger? Have you ever had the opportunity to shoot one? If so, let us know in the comments below! Ready to dive into more World War weaponry? Check out the Famous Guns of WWI and the Coolest Guns From WWII.

The post Luger Pistol: The Most Famous German 9mm appeared first on Pew Pew Tactical.

Pew Pew Tactical