Skip to main content

Posts

Showing posts from April, 2024

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...