How to rename GitHub repository

To rename a GitHub repository, follow these steps:

  1. Go to the repository on GitHub:

    • Log in to your GitHub account.
    • Navigate to the repository you want to rename.
  2. Access the repository settings:

    • Click on the “Settings” tab at the top of the repository page.
  3. Rename the repository:

    • In the “General” section, look for the “Repository name” field.
    • Edit the repository name to your desired new name.
  4. Confirm the change:

    • After entering the new name, scroll down and click the “Rename” button to apply the changes.

Additional Notes

  • GitHub will automatically redirect links to the old repository name to the new one, but it’s still a good idea to update any references (like in your local Git configurations or documentation).
  • In your local copy, you should update the remote URL using the command:
git remote set-url origin https://github.com/USERNAME/NEW_REPO_NAME.git

What is `protected $fillable` in a Laravel model?

In Laravel, the `protected $fillable` property is used to define an array of attributes that are mass assignable. This means these attributes can be assigned using mass-assignment techniques, such as when creating a new model instance or updating an existing one using the `create` or `update` methods.

Mass Assignment

Mass assignment is a way to assign multiple attributes to a model instance in a single step, typically using an array. For example, you might have a form where a user can submit several pieces of information at once. Instead of assigning each piece of information individually, you can pass the entire array to the `create` or `update` method.

Here’s an example of how you might use the `$fillable` property in a Laravel model:

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
    // Define the attributes that are mass assignable
    protected $fillable = [
        'title', 
        'content', 
        'author_id'
    ];
}

In this example, the `Post` model has three attributes (`title`, `content`, and `author_id`) that are mass assignable.

Using Mass Assignment

With the `$fillable` property defined, you can now safely use mass assignment:

// Creating a new post
$post = Post::create([
    'title' => 'My First Post',
    'content' => 'This is the content of my first post.',
    'author_id' => 1
]);

// Updating an existing post
$post->update([
    'title' => 'Updated Title',
    'content' => 'This is the updated content.'
]);

The primary purpose of the `$fillable` property is to prevent mass-assignment vulnerabilities. Without `$fillable` (or its counterpart `$guarded`), any attribute in the model can be mass assigned, which could potentially allow malicious users to update sensitive fields that they shouldn’t have access to.

Mass Assignment Vulnerability

So what is this mass assignment vulnerability? Consider a scenario where a user can submit their profile information. If the user model has an attribute like `is_admin`, and this attribute is not protected, a malicious user could submit a form with an `is_admin` field and set its value to `true`, giving themselves admin privileges.

By defining the `$fillable` property, you explicitly specify which attributes are safe to be mass assigned, thus mitigating this risk.

So, using the `$fillable` property is a best practice in Laravel to ensure that only the intended attributes can be mass assigned, enhancing the security of your application.

C64/SID/Chiptunes covers

This is a non programing related post. I am a big fan of chiptunes, especially C64/SID music. There are so many amazing and well known SID tunes that I though were original but it turned out they are not. Some of them really surprised me. This does not take away from them, some covers are even better than originals, but it is interesting to hear the original and how it compares to chiptune version.

I created a new page Retro Music & Gaming where I write about these. Some of the songs include Cobra, Zoids, Commando, Rob Hubbard’s “Delta” and “Monty on the Run”, Golden Axe,. Enjoy, and I will try to update the section as much as time permits.

Vite assets are still localhost on production server

If you are using vite.js (for example when using Laravel assets bundler) then running the npm run build command triggers the build process for your project. When you run this command, Vite.js will perform several tasks to prepare your application for production deployment.

If you use Git and upload/deploy your files to production server and you css is not working then check the source code.  If you see something like this on your production server :

<script type="module" src="http://127.0.0.1:4523/@vite/client"></script>
<script type="module" src="http://127.0.0.1:4523/resources/js/app.js"></script></code>

then check if the “hot” file was accidentally uploaded to your server (github) to your Laravel public folder. Delete it and it should work. This file is used when running the dev server but will break production.

To exclude this file being uploaded to github you add it to .gitignore file:

/public/hot

Is it better to make several commits and then push to github or push each commit immediately?

The decision of whether to make several commits and then push to GitHub or push each commit immediately depends on your workflow and the nature of the changes you are making. Both approaches have their merits, and the choice ultimately depends on your preferences and the collaboration model of your project.

1. Making Several Commits and Pushing at Once:

  • Advantages:
    • Cleaner History: Grouping related changes into separate commits can create a more organized and meaningful commit history, making it easier to understand the evolution of the project.
    • Atomic Changes: Each commit represents a discrete, self-contained change, making it easier to revert specific changes if needed.
    • Reduced Noise: Pushing frequently can clutter the commit history with minor or incomplete changes, which can be avoided with periodic pushes.
  • Considerations:
    • Avoid Pushing Broken Code: If you push only when your code is in a stable state, this approach can work well. Otherwise, you might introduce bugs to the shared repository.
    • Better for Collaboration: If multiple team members are working on the same branch, making several commits before pushing can reduce conflicts and simplify the review process.

2. Pushing Each Commit Immediately:

  • Advantages:
    • Real-Time Collaboration: Other team members can see and potentially build upon your latest changes immediately.
    • Continuous Integration: Pushing frequently can trigger automated tests or deployment pipelines, allowing you to catch issues early.
    • Incremental Sharing: If your commits are small and well-tested, pushing immediately can help you share your progress incrementally.
  • Considerations:
    • Messy History: Frequent, small commits can lead to a cluttered commit history, making it harder to follow the logical progression of changes.
    • Rollback Complications: If you realize you need to revert a specific feature or change, it might be more complicated to isolate and revert individual commits.

In practice, developers often strike a balance between the two approaches. They make smaller, meaningful commits locally while working on a feature or bug fix, ensuring their changes are logically grouped. Once the feature or fix is complete, they perform a final review of the commits and possibly squash or rebase them into more coherent, atomic commits before pushing to GitHub. This approach combines the benefits of both methods and creates a clean, organized commit history while still maintaining real-time collaboration with the team.

Ultimately, the key is to communicate and align with your team on the preferred approach and follow any established guidelines or best practices for your project.

 

Fatal error: Unparenthesized `a ? b : c ? d : e` is not supported in DatabaseInterface.php on line 615

You will get this error when you upgrade your PHP 7 to PHP 8 (or even 7.3 to 7.4 or something like that) but keep your old phpmyadmin version. This error can be in any code but in our case it is in phpMyAdmin\libraries\classes\DatabaseInterface.php file so we need to fix it for phpMyAdmin. We will not fix the code itself because in this case it is not needed.

The solution here is for Laragon. It is a little longer, but easy, Laragon oriented solution so you can better understand how it works. Scroll down to the end to do this manually (faster).

Laragon solution

It is possible that your Laragon came with older phpMyAdmin version. So we will tell Laragon to download the latest one.

Open your {INSTALLATION_PATH}\laragon\etc\apps\phpMyAdmin folder. Just in case, backup this phpMyAdmin folder first. Then delete all files in it so the folder is empty.

Right click the laragon tray icon, then Tools then Quick add and then Configuration…

laragon options configuration quick app

this will open packages. conf file in your text editor. Find this line :

# phpMyAdmin
phpmyadmin= *******

of course you will see a link to phpmyadmin download page. It will pobably be link to a specific version.

Change it to this (latest version of phpmyadmin) and save the file.

# phpMyAdmin
phpmyadmin=https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.zip

Note: if the second line starts with # you need to delete the # character.

Right click the laragon tray icon again, then Tools then Quick add and then phpmyadmin… and Laragon with automatixally downlaod the latest phpMyAdmin and install it.

laragon phpmyadmin

Restart Laragon, open yourproject.test/phpmyadmin/ in your browser (your project will be called different than yourproject.test) and phpmyadmin should work.

Manual solution

1. backup and then delete all files in {INSTALLATION_PATH}\laragon\etc\apps\phpMyAdmin folder
2. Download the latest version of phpMyAdmin from https://www.phpmyadmin.net/downloads/
3. Extract the content of downloaded ZIP file into a empty phpMyAdmin folder
4. Restart laragon and phpMyAdmin should work.

Disable Google Lens search in Chrome

this will be a short one but it is quite annoying one: Google Chrome keeps making Lens as default image search in Chrome after every few updates (not often). It is used when you right click an image on internet and select “Search image with Google”. Here is how to turn lens off:

Open a new tab and go to chrome://flags.

Search and locate the following flag: Enable Lens features in Chrome. From the drop-down, select Disabled

You need to relaunch Chrome and problem solved.

Google Drive is almost empty but shows several GB used

I guess you cant blame Google for trying to sell extra storage but this problem was really annoying me for a long time. Google kept telling me my account is full and it showed ~7GB in Google Drive. When I clicked on Drive icon there were just few files in it, totaling less than 1MB! No matter how much I kept clicking, files just weren’t there. Trash and everything else was empty. Of course on every page there was an offer for buying additional storage.

Well, finally I found what is clogging my drive: it was hidden app data, more specifically from chat app that drive was also backed up. I wish Google would tell me this, but of course it is in their interest to try to make us use pay for exra space.

How to see what is clogging up your drive (desktop):

1. Visit https://drive.google.com/ from your PC.

2. Click the gears icon and select Settings

Scroll down and you will see if an app is keeping hidden files in your drive. In my case it was chat app (I hid the name). If you see few GB of hiden app data then this is the answer to what is clogging up your Drive.

Important: I am not 100% sure what this data contains or if it is just a backup. If you are not sure what you are doing then do NOT delete the app data. I cant take any responsibly if those disappear. So I am not going to tell you how to gain back space, just that this is how I found out WHY my drive is full. This way you know what is the problem is so maybe deleting old photos and videos (or even clean or redo a backup) from your app on your phone will also delete it from drive.

Find the WiFi Password in Windows 10 Using CMD

Every time I search for this I get pages long articles with 99% of babbling when the solution is 2 lines. I think it can be used for Windows 7, 8, 10, 11,…

NOTE: you must have connected and stored password for that wifi in the past. This trick is to see password that is already stored on your computer (in case you forgot it), NOT to find out password on router for any wifi.

So here is how to do it:

Open CMD (some say in administrator mode but for me it worked OK without it too).

Type (can be small letters) NETSH WLAN SHOW PROFILE

You will get a list of all Wi-fi networks. Let say the name of network you want is MYWIFINET.

Type NETSH WLAN SHOW PROFILE MYWIFINET KEY=CLEAR

Scroll down to Security Settings and find Key Content (I hid my password with red color).

Next to it is the wifi password you are looking for.

Windows 11: Is my PC compatible? How to check TPM requirement

There was quite a buzz on internet after Microsoft announced new Windows 11 and apparently lots of PCs will be unable to upgrade due to “incompatible hardware” or not meeting the Windows 11 requirements. This will probably change due to backlash but one of those requirements is Trusted Platform Module (TPM) 2.0, (or some say 1.2).

To check what version of TPM you have simply click on the windows search icon (or press Win-R to open run console) and type tpm.msc and press enter.

New windows will open, called Trusted Platform (TPM) Module Management. Check if TPM is ready for use and what version of TPM do you have. If you have 2.0 then this requirement is met.

Trusted Platform Module (TPM) 2.0 Management
Trusted Platform Module (TPM) 2.0 Management

Microsoft had an PC Health Check app to tell you if your PC meets requirements but they puilled it to update it.