Firdaus Archive

Blog pribadi untuk curhat, share tentang script, software, kuliah, project IT dan seputar IT.

Cara Crawl / Index Site ke Google

Kunjungi alamat https://search.google.com/search-console

Klik Menu dibawah ini lalu pilih add properties 

Lalu isikan alamatnya


Lalu verifikasi melalui DNS management add TXT record seperti dibawah ini


Jika sudah klik verify jika berhasil lanjut ke step selanjutnya

Isikan alamatnya seperti gambar di bawah ini



jika sudah tunggu proses maka muncul page di bawah ini



setelah itu Klik Request Indexing

MySQL Pelajari Penting

 - Limit ... Offset...

- Group_Concat

- Self Join (https://www.educba.com/mysql-self-join/)

MySQL LAST_INSERT_ID() how it works at multi-users environment

 Untuk mengambil data id yang terakhir di insertkan bisa memakai fungsi berikut

LAST_INSERT_ID()

LAST_INSERT_ID() gives you the last autogenerated id on the connection you execute it on, it does not return the last insert id globally produced by the MySQL server.


sauce : https://stackoverflow.com/questions/5835677/last-insert-id-how-it-works-at-multi-users-environment

MySQL Stored Procedure : Create a procedure to insert and update table header and details in mysql

Stack Overflow answer powered by AI 
To create a stored procedure in MySQL that can be used to insert and update table header and details, you can follow this example:

DELIMITER //

CREATE PROCEDURE insert_update_table (IN p_header_value VARCHAR(50), IN p_detail_value VARCHAR(50))
BEGIN
    -- Check if the header already exists in the table
    IF EXISTS (SELECT * FROM your_table WHERE header_column = p_header_value) THEN
        -- Update the existing record
        UPDATE your_table SET detail_column = p_detail_value WHERE header_column = p_header_value;
    ELSE
        -- Insert a new record
        INSERT INTO your_table (header_column, detail_column) VALUES (p_header_value, p_detail_value);
    END IF;
END //

DELIMITER ;


In this example, replace your_table with the actual name of your table, header_column with the name of the column where you want to store the header value, and detail_column with the name of the column where you want to store the detail value. To use the procedure, you can call it like this: 

CALL insert_update_table('Header Value', 'Detail Value'); 

 This will either update the existing record with the provided header value and detail value if the header value already exists, or insert a new record with the provided values if the header value doesn't exist in the table.

Displaying URL parameter values as text in an element on webpage

 source https://stackoverflow.com/questions/71727647/displaying-url-parameter-values-as-text-in-an-element-on-webpage-question-from


<!-- example url https://exampleurl.com/?birthdate=22091977&pdflink=yourlink123.pdf-->


<html>

    <body>

        <span id="birthdate"></span>

</br>

<span id="pdflink"></span>

    </body>

</html>


<script>

    const queryString = window.location.search;

    const urlParams = new URLSearchParams(queryString);

    const birthdate = urlParams.get('birthdate');

    const pdflink = urlParams.get('pdflink');

    document.getElementById("birthdate").innerHTML = birthdate;

document.getElementById("pdflink").innerHTML = pdflink;

</script>

MySQL Stored Procedure : Insert Data in Header and Detail within 1 Transaction

This is Generated by ChatGPT 2023-11-01

To insert data into a single-row header table and multiple-row detail table using a stored procedure in MySQL, you can follow these steps. In this example, we'll create two tables: header and detail, with a one-to-many relationship, and then create a stored procedure to insert data into both tables.

Assuming you have the following tables:

CREATE TABLE header (

    header_id INT AUTO_INCREMENT PRIMARY KEY,

    header_data VARCHAR(255)

);


CREATE TABLE detail (

    detail_id INT AUTO_INCREMENT PRIMARY KEY,

    header_id INT,

    detail_data VARCHAR(255),

    FOREIGN KEY (header_id) REFERENCES header(header_id)

);

Here's a stored procedure to insert data into both tables:

DELIMITER $$


CREATE PROCEDURE InsertHeaderAndDetails(

    IN headerData VARCHAR(255),

    IN detailDataArray JSON

)

BEGIN

    DECLARE done INT DEFAULT FALSE;

    DECLARE detailValue VARCHAR(255);

    DECLARE cur CURSOR FOR SELECT value FROM JSON_TABLE(detailDataArray, '$[*]' COLUMNS(value VARCHAR(255) PATH '$'));

    

    -- Insert data into the header table

    INSERT INTO header (header_data) VALUES (headerData);

    SET @lastHeaderID = LAST_INSERT_ID(); -- Get the last inserted header ID


    -- Insert data into the detail table

    OPEN cur;

    read_loop: LOOP

        FETCH cur INTO detailValue;

        IF done THEN

            LEAVE read_loop;

        END IF;

        INSERT INTO detail (header_id, detail_data) VALUES (@lastHeaderID, detailValue);

    END LOOP;

    CLOSE cur;

END $$


DELIMITER ;

 

This stored procedure takes two parameters:


headerData: The data to be inserted into the header table.

detailDataArray: A JSON array containing the data to be inserted into the detail table.

You can call the stored procedure like this:

CALL InsertHeaderAndDetails('Header Data', '["Detail 1", "Detail 2", "Detail 3"]');

This will insert a new row into the header table and multiple rows into the detail table with the corresponding header_id.

Please adjust the data types, table structures, and stored procedure parameters as needed to match your specific requirements. Additionally, ensure that you have proper error handling and validation in your production code for real-world scenarios.



 

 

 

Radmin VPN Alternative

ZeroTier

Freelan

Hamachi

sc https://www.saashub.com/zerotier-one-alternatives https://www.saashub.com/radmin-vpn-alternatives

Log USB insert / Eject Using USBLogView by nirsoft

USBLogView is a small utility that runs in the background and records the details of any USB device that is plugged or unplugged into your system. For every log line created by USBLogView, the following information is displayed: Event Type (Plug/Unplug), Event Time, Device Name, Description, Device Type, Drive Letter (For storage devices), Serial Number (Only for some types of devices), Vendor ID, Product ID, Vendor Name, Product Name, and more...

You can easily select one or more log records and then export them into csv/tab-delimited/xml/html file.


To Download Click This link

http://www.nirsoft.net/utils/usb_log_view.html

or This Direct Link

http://www.nirsoft.net/utils/usblogview.zip

Visual Studio Code - Removing Lines Containing criteria

This method dont need any Extension

1. Ctrl+F to open find.

2. Paste your string.

3. Alt+Enter to select all of the instances of the string on the page.

4. Ctrl+L to broaden the selection to the entire line of each instance on the page.

5. Delete/Backspace to remove those lines.


This method u need this extension https://marketplace.visualstudio.com/items?itemName=qcz.text-power-tools


Even its slow but its just an alternative in case u were too lazy to do the 1st method

[Fix Error] Kode Error 0x0000011b Windows 10 Sharing Printer

Kode error 0x0000011b muncul saat ingin melakukan sharing printer pada windows 10. Error tersebut disebabkan oleh update terbaru windows 10 2021-09 Cumulative Update for Windows 10 Version 21H1 for x64-based Systems (KB5005565).

Cara mengatasi problem tersebut yaitu :


Buka Windows Registry Editor (regedit)

Kemudian arahkan ke HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print

Kemudian buat DWORD-32 baru dengan nama RpcAuthnLevelPrivacyEnabled set Value Data : 0

Selanjutnya Restart PC / Laptop

Error 0x0000011b akan hilang dan sharing printer bisa digunakan kembali.


source : https://pdsi.unisayogya.ac.id/fix-error-kode-error-0x0000011b-windows-10-sharing-printer/

PowerShell merubah nama file extensi tertentu dengan tambahan tanggal dalam 1 folder

 

Powershell
Contoh diatas adalah file awal saat sebelum di rename, anda bisa menggunakan script dibawah ini untuk menambahkan prefix/suffix pada filenya

Get-ChildItem |Foreach-Object { Rename-Item $_ -NewName ("{0}-{1}{2}" -f $_.LastWriteTime.ToString('yyyyMMdd'),$_.BaseName,$_.Extension)  }


 jika ingin nama file tetap di depan anda bisa menggunakan script dibawah ini

Get-ChildItem |Foreach-Object { Rename-Item $_ -NewName ("{0}-{1}{2}" -f $_.BaseName,$_.LastWriteTime.ToString('yyyyMMdd'),$_.Extension)  }


Menghapus File Ukuran Besar pada Git History

 

Git filter branch

Fungsi git filter-branch 

Cara menggunakannya adalah sebagai berikut

 git filter-branch --force --index-filter \

  'git rm --cached --ignore-unmatch lokasi/ke/file.exe' \

  --prune-empty --tag-name-filter cat -- --all


Jika sudah dijalankan maka akan muncul gambar seperti di atas

file.exe adalah file yang ingin di hapus dari semua history github repo yang telah disimpan, cara ini dapat menghemat banyak sekali space pada local repo sehingga ukuran repo tidak membengkak.

setelah proses selesai maka eksekusi command di bawah ini

git push origin --force --all
Git Push Force

jika git menemukan file lain yang ukurannya besar maka akan diberikan peringatan tetang file tersebut
Git Bash Info

lanjutkan dengan script dibawah ini untuk melakukan garbage collector
git gc --aggressive --prune
Git gc agressive prune

Jika sudah selesai maka silahkan cek kembali ukuran local repository anda.

Anda juga bisa menambahkan file di .gitignore agar file tersebut tidak masuk ke dalam repo. 

Merubah Partisi dari MBR ke GPT atau sebaliknya

hard disk MBR
Biasanya saat kita akan melakukan Downgrade dari Windows 8,8.1 atau 10 ke Windows 7 kita akan mengalami beberapa masalah seperti Disk yang di install harus menggunakan GPT (GUID Partition Table) sedangkan setelah kita menginstall windows 8 keatas kita sudah menggunakan MBR(Master Boot Record)

Biasanya kebanyakan orang akan memindahkan filenya ke hard disk lain dan memformat hard disknya terlebih dahulu, lalu menhapus semua partisi dan format ulang semuanya. Cara ini terlalu lama dan tidak efisien. Lebih baik kita konversi langsung hard disk tersebut tanpa harus memformatnya, caranya adalah sebagai berikut:
Sebelumnya download dulu
1. Download EaseUS Partition Master Professional dan install seperti biasa, anda hanya perlu mencobanya trial saja, tidak perlu membeli softwarenya kecuali jika anda gunakan untuk seterusnya.
2. Buka programnya lalu pilih disk MBR yang ingin di konversi menjadi GPT