Skip to main content

Posts

Validating Native Query and Entity Graph

 Validating Native Query and Entity Graph Using native queries in Spring JPA/Hibernate can be less enjoyable, but they are occasionally indispensable, especially for enhancing performance. Similarly, EntryGraphs become necessary in specific situations to mitigate N+1 scenarios or define data boundaries retrieved from the database. Since it's challenging to validate these scenarios without executing each query, inadequate testing can lead to significant issues. The same holds true when refactoring numerous database tables and columns, potentially missing updates in native queries, which may slip through testing and manifest in production. You may encounter such scenarios as well. Therefore, we've invested effort into developing a solution to validate native queries against a schema. You might be interested in such thing or suggest some improvement over it. Here's what we've accomplished: Developed a component that conducts validation by executing each native query agains...

Shell Scripts

Shell scripts $? variable: In a shell script, we can check the return status immediately after running any command to determine if command is successful or not. like echo $? if return status is 0, it indicates success,  and if the return status is non-zero, typically 1, means failure. /dev/null /dev/null is a special device file in Unix-like operating systems (including Linux) that discards all data written to it. It essentially acts as a black hole for data. When data is written to /dev/null, it simply disappears and does not consume any storage space. Here are some common use cases for /dev/null: Discarding Output: As mentioned earlier, redirecting output to /dev/null is a common way to discard unwanted output, such as diagnostic messages or verbose output, especially when running scripts or commands in the background where you don't need to see the output. command >/dev/null  # Redirects stdout to /dev/null command 2>/dev/null # Redirects stderr to /dev/null command ...

HTML to PDF

Converting HTML to PDF with code offers more control and flexibility compared to online tools. Here are some ways to achieve this: 1. Using Python Libraries: Python provides several libraries for HTML to PDF conversion. Here are two popular options: WeasyPrint (using wkhtmltopdf): This library utilizes the powerful wkhtmltopdf tool for rendering HTML and generating PDFs. It offers fine-grained control over the conversion process. Here's an example using WeasyPrint: Python from weasyprint import HTML html_file = "my_report.html" # Replace with your HTML file path pdf_file = "report.pdf" HTML(filename=html_file).write_pdf(pdf_file) print("Converted HTML to PDF successfully!") Use code with caution. PDFKit (using wkhtmltopdf): Similar to WeasyPrint, PDFKit leverages wkhtmltopdf. It offers a simpler API for basic conversions. Here's an example using PDFKit: Python import pdfkit url = "https://www.example.com" # Replace with a...

Recover lost files on Windows, free and effective

 Windows File Recovery If necessary, download and launch the app from Microsoft Store. Press the Windows key, enter Windows File Recovery in the search box, and then select Windows File Recovery. When you are prompted to allow the app to make changes to your device, select Yes. In the Command Prompt window, enter the command in the following format:  winfr source-drive: destination-drive: [/mode] [/switches] There are 2 basic modes you can use to recover files: Regular and Extensive.  Regular mode examples Recover your Documents folder from your C: drive to the recovery folder on an E: drive. Don’t forget the backslash (\) at the end of the folder.   winfr C: E: /regular /n \Users\<username>\Documents\  Recover PDF and Word files from your C: drive to the recovery folder on an E: drive.  winfr C: E: /regular /n *.pdf /n *.docx  Extensive mode examples   winfr E: C: /extensive /n *invoice*  Recover jpeg and png photos from your...

Archiving all messages on LinkedIn

Open https://www.linkedin.com/ in a web browser, got to developer option and then paste the script in Console window and clink enter. timer = setInterval(() => { // select all messages items = document.querySelectorAll('div.msg-selectable-entity__checkbox-container > input'); for (let i = 0; i < items.length; i++) { items[i].click(); } setTimeout(() => { // click archive button buttons = document.querySelectorAll('div.display-flex.mvA > button[title="Archive"]'); if (buttons.length == 1) { buttons[0].click(); } }, 1000); }, 5000) Credit to Gaidar Magdanurov

Git: create a patch of the last two commits

 To merge two patch files into a single patch file or create a patch of the last two commits, you can use the `git diff` and `git apply` commands. Here are the steps for each scenario: ### Merge Two Patch Files into a Single Patch File: 1. Suppose you have two patch files named `patch1.patch` and `patch2.patch`. 2. To merge them into a single patch file, you can use the `cat` command:    ```bash    cat patch1.patch patch2.patch > combined.patch    ```    This command concatenates the contents of both patch files into a new file named `combined.patch`. ### Create a Patch of the Last Two Commits: 1. Generate a patch file for the last two commits using the `git diff` command:    ```bash    git diff HEAD~2..HEAD > last_two_commits.patch    ```    This command creates a patch file (`last_two_commits.patch`) that represents the changes introduced in the last two commits. 2. Apply the generated patch fil...

Find files that contain the word 'xxx' but do not contain the word 'yyy' in the same file

  Find files that contain the word 'xxx' but do not contain the word 'yyy' in the same file ```bash grep -rl 'xxx' /path/to/search/* | xargs grep -L 'yyy' ``` This command first searches for files containing 'xxx' using the `-r` (recursive) and `-l` (only file names) options. Then, it pipes the results to `xargs` to search for files that do not contain 'yyy' using the `-L` option. Make sure to replace `/path/to/search/*` with the actual path or file pattern you want to search.