Exploring Python Tools for Generative AI

Generative AI has become a powerful tool for creating new and innovative content, from captivating poems to photorealistic images. But where do you begin when you start learning in this exciting area? Python, with its robust libraries and active community, stands as a perfect starting point. This article delves into some of the most popular Python tools for generative AI, equipping you with the knowledge and code examples to kickstart your creative journey.

1. Text Generation With Transformers

The Transformers library, built on top of PyTorch, offers a convenient way to interact with pre-trained language models like GPT-2. These models, trained on massive datasets of text and code, can generate realistic and coherent text continuations. Here's an example of using the transformers library to generate creative text:

Spring RestTemplate to WebClient Causes OutOfMemoryError

Spring Boot is a highly popular framework for Java enterprise applications. One common method of integration with internal or external applications is through HTTP REST connections. We were upgrading from RestTemplate to the Java NIO-based WebClient, which can significantly enhance application performance by allowing concurrency when calling REST service endpoints. The benefits of WebClients are as follows:

  1. Concurrency: WebClient enables handling multiple connections simultaneously without blocking threads, leading to better concurrency.
  2. Asynchronous: Asynchronous programming allows the application to perform other tasks while waiting for I/O operations to complete, improving overall efficiency.
  3. Performance: Non-blocking I/O can manage more connections with fewer threads, reducing the resources required for handling concurrent requests.

Although the performance improved, however with the same number of concurrent connections, the WebClient was crashing with OutOfMemoryError. We will be analyzing the WebClient crash issues along with how to troubleshoot and fix them.

Extractive Summarization With LLM Using BERT

In today's fast-paced world, we're bombarded with more information than we can handle. We’re increasingly getting used to receiving more information in less time, leading to frustration when having to read extensive documents or books. That's where extractive summarization steps in. To get to the heart of a text, the process pulls out key sentences from an article, piece, or page to give us a snapshot of its most important points. 

For anyone needing to understand big documents without reading every word, this is a game changer.

Maximizing Feedback for Developers With Continuous Testing

Developers need feedback on their work so that they know whether their code is helping the business. They should have “multiple feedback loops to ensure that high-quality software gets delivered to users”[1]. Development teams also need to review their feedback loops so that they can maximize useful feedback. 

Testing provides feedback and should be continuous so that it provides quick and continuous feedback to the developers. Testing must always be happening as part of the development process. There are many different types of testing.

Software Engineering Trends in the Industry

This article identifies some basic trends in the software industry. Specifically, we will explore how some well-known organizations implement and benefit from early and continuous testing, faster software delivery, reduced costs, and increased collaboration. While it is clear that activities like breaking down silos, shift-left testing, automation, and continuous delivery are interrelated, it is beneficial to take a look at how companies strive to achieve such goals in practice.

Companies try to break down the traditional silos that separate development, operations, and testing teams. This eliminates barriers and fosters collaboration, where all teams share responsibility for quality throughout the software development lifecycle. This collaborative approach leads to improved problem-solving, faster issue resolution, and ultimately, higher-quality software.

Evaluating LLMs: Beyond Traditional Software Testing

Large Language Models (LLMs) have revolutionized how we interact with computers, enabling text generation, translation, and more. However, evaluating these complex systems requires a fundamentally different approach than traditional software testing. Here's why:

LLM's Black Box Nature

Traditional software is based on deterministic logic with predictable outputs for given inputs. LLMs, on the other hand, are vast neural networks trained on massive text datasets. Their internal workings are incredibly complex, making it difficult to pinpoint the exact reasoning for any specific output. This "black box" nature poses significant challenges for traditional testing methods.

How to Add Google Search in a WordPress Site (The Easy Way)

Do you want to use Google search on your WordPress site?

By default, WordPress comes with a built-in search feature, but it is not very good. By adding Google Search in its place, you can display more accurate and relevant search results to visitors.

In this article, we will show you how to easily add Google Search to a WordPress site.

Add Google Search in a WordPress Site

Why Should You Use Google Search in WordPress?

The default WordPress search feature is not very useful and often fails to find relevant results to user queries. This forces many site owners to look for alternatives.

You can use a popular WordPress search plugin. However, the problem is that you still have to manage that plugin, and it will have an impact on your server resources.

On the other hand, you can use Google’s reliable and powerful search feature instead. It is free, allows you to limit the search to your sites only, and can be run from your WordPress site.

Plus, the Google search is fast, users already trust the brand, and you will not have to maintain or update it. You can even allow users to search external websites on Google if needed.

Having said that, let’s see how you can easily add a Google site search to your WordPress site.

How to Add Google Search to a WordPress Site

You can easily add Google Search to your WordPress site by visiting the Google Programmable Search Engine website.

From here, click the ‘Get Started’ button.

Click the get started button on the Programmable Search Engine page

This will direct you to the ‘Create a new search engine’ page, where you must add a name for the search form you are about to create.

Next, select the ‘Search specific sites or pages’ option in the ‘What to search?’ section and add your WordPress site’s URL.

Now, the Googe Site Search will only index the content available on your website. However, if you want Google to show search results from other websites as well, then you can choose the ‘Search the entire web’ option.

Add website URL to create Google Site search

Next, scroll down and toggle on the ‘Image Search’ option to allow your Google Search form to index images on your website. We recommend this option if you sell photos online, have a photography website, or run a travel blog.

After that, you can also toggle on the ‘Safe Search’ switch so that users won’t be shown inappropriate results for their queries.

Once you are done, click the ‘Create’ button.

Click create to generate a google search engine ID

Google will now generate your search engine ID code for you.

From here, simply copy the code and paste it into a notepad app or plain text editor.

Copy the Google Search Engine ID from the website

Now, you must visit your WordPress dashboard and edit your theme files to add the search to your site’s <body>. However, this can be risky, and the smallest error can break your website.

That is why we recommend using WPCode instead. It is the best WordPress code snippets plugin on the market that makes it safe and easy to add custom code.

First, you need to install and activate the WPCode plugin. For detailed instructions, see our beginner’s guide on how to install a WordPress plugin.

Note: WPCode has a free plan that you can use for this tutorial. However, upgrading to the pro version will give you access to more features like smart conditional logic, a cloud library of code snippets, and more.

Upon activation, visit the Code Snippets » + Add Snippet page from the WordPress admin sidebar. Here, click the ‘Use Snippet’ button under the ‘Add Your Custom Code (New Snippet)’ option.

Add new snippet

This will take you to the ‘Create Custom Snippet’ page, where you can type any name you like for the snippet. Then, select ‘Universal Snippet’ as the code type from the dropdown menu on the right.

Once you do that, simply paste the Google Search Engine ID into the ‘Code Preview’ box.

Paste the Google Search Engine ID into WPCode preview box

Then, scroll down to the ‘Insertion’ section and select the ‘Auto Insert’ mode. The Google Search form will be automatically added to your site upon activation.

After that, you can expand the ‘Location’ dropdown menu to choose where you want to display your search box.

For example, if you want to display the search form at the top of all your pages and posts, then you can select the ‘Insert Before Post’ option.

Choose location and insertion for the search engine ID

Next, scroll back to the top and toggle the ‘Inactive’ switch to ‘Active’.

Finally, click the ‘Save Snippet’ button to store your settings.

Save Google Search Engine ID snippet

You have successfully added a Google Site search form manually.

You can now visit your WordPress blog to see it in action.

Google Search preview

Alternative: Use SearchWP to Create an Amazing Search Form

If you find it difficult to add Google Site Search to your website or you are looking for an alternative, then you can use SearchWP for internal search.

It is the best WordPress search plugin on the market that automatically replaces the default search form and allows users to find anything they need on your site.

The SearchWP homepage

SearchWP is used by over 30,000 websites and lets you create a custom relevance scale to adjust the search algorithm.

You can also make any part of your site searchable including PDFs, custom post types, media, comments, custom fields, WooCommerce products, and more.

If you have a multilingual site, then you can also create a multilingual search with the plugin.

Configure SearchWP engine settings

However, you must keep in mind that, unlike Google Search, the plugin can only index and show results for content available on your website.

For more details, you can see our tutorial on how to improve WordPress search with SearchWP.

We hope this article helped you learn how to easily add Google Search to a WordPress site. You may also want to see our beginner’s guide on how to get my WordPress site listed on Google and our tips for using Google Search Console to grow website traffic.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

The post How to Add Google Search in a WordPress Site (The Easy Way) first appeared on WPBeginner.

Elevate Your Terminal Game: Hacks for a Productive Workspace

In the realm of productivity, every efficiency gained counts. For many, the terminal serves as the central hub for navigating the digital landscape. Whether you're a seasoned developer, a system administrator, or simply someone who spends a lot of time working in the command line, customizing your terminal can transform it from a basic tool into a personalized powerhouse. In this guide, we'll explore various ways you can hack your terminal to enhance your workflow, boost productivity, and create a workspace tailored to your needs. Most of the stuff will revolve around modifying your bashrc/zshrc config.

Enhance the Look With Powerlevel10k

The aesthetic appeal of your terminal plays a significant role in your overall experience. Powerlevel10k is one of the coolest themes you can install in your zsh terminal. It transforms your terminal from a basic interface into a sleek, informative, and visually captivating display, providing a significant upgrade in both aesthetics and functionality.

Making Cloud Simpler: How Tangoe’s AI and Patents Streamline FinOps

As cloud usage continues its meteoric rise, spurred further by advances like generative AI, the complexity and costs of cloud management are skyrocketing. Infrastructure and architecture leaders need better ways to optimize cloud spending that don't require manual analysis of endless line items across disconnected consoles. 

Tangoe aims to solve this problem through exclusive patented capabilities that apply AI and automation to streamline the entire FinOps process. With 70 patents and counting, they are continuous innovators in using technology to simplify technology management.

The Art and Science of Software Testing

In the realm of software development, where innovation and progress unfold at an unprecedented pace, the significance of software testing cannot be overstated. It stands as the bastion against defects, bugs, and glitches that could potentially compromise the integrity, functionality, and security of digital products. Software testing is not merely a procedural step in the development lifecycle; it is a meticulous craft that demands equal parts of skill, strategy, and foresight.

The Imperative of Quality Assurance

In today's hyperconnected world, software pervades every facet of our lives. From the applications we use daily to the critical systems running behind the scenes in industries such as healthcare, finance, and transportation, the reliability and performance of software are paramount. Quality assurance, therefore, emerges as a non-negotiable imperative, driving the need for robust testing methodologies.

AI Advancement for API and Microservices

Recent AI advancements in API technology involve enhancing natural language processing capabilities, improving algorithmic decision-making through reinforcement learning, and expanding AI integration across diverse sectors like healthcare, finance, and e-commerce to create more intelligent, adaptable, and tailored API solutions.

Key Trends and Advancements

AutoML for APIs

AutoML (Automated Machine Learning) tools are increasingly being used to automate the development of machine learning models that can be exposed through APIs. This streamlines the process of building AI-powered APIs by reducing the need for manual intervention in model training and deployment.

10 Tips To Improve Python Coding Skills in 2024

Python is a popular, versatile, and easy-to-learn programming language that offers excellent career options to individuals such as Python developers, full-stack developers, software engineers, cyber security experts, data analysts, etc. It is an excellent language to begin your career in IT. The Python programming language helps individuals develop the frontend and backend and work with the database. Good Python coding skills allow professionals to execute all Python-related works efficiently and conveniently. If you also want to excel with Python, you must give special attention to your coding skills. 

In this blog, we'll share the 10 best tips to help you improve your Python coding skills.

Modern CSS Tooltips And Speech Bubbles (Part 1)

In a previous article, we explored ribbon shapes and different ways to approach them using clever combinations of CSS gradients and clip-path(). This time, I’d like to explore another shape, one that you’ve likely had to tackle at least once in your front-end life: tooltips. You know what we’re talking about, those little things that look like speech bubbles from comic books. They’re everywhere in the wild, from a hover effect for buttons to the text messaging app on your phone.

The shapes may look easy to make in CSS at first glance, but it always ends with a lot of struggles. For example, how do you adjust the position of the tail to indicate whether the tooltip is coming from a left, right, or center position? There are plenty of considerations to take into account when making tooltips — including overflowage, collision detection, and semantics — but it’s the shape and direction of the tail that I want to focus on because I often see inflexible fixed units used to position them.

Forget what you already know about tooltips because in this article, we will start from zero, and you will learn how to build a tooltip with minimal markup powered by modern CSS that provides flexibility to configure the component by adjusting CSS variables. We are not going to build one or two shapes, but… 100 different shapes!

That may sound like we’re getting into a super-long article, but actually, we can easily get there by adjusting a few values. In the end, you will have a back pocket full of CSS tricks that can be combined to create any shape you want.

And guess what? I’ve already created an online collection of 100 different tooltip shapes where you can easily copy and paste the code for your own use, but stay with me. You’re going to want to know the secret to unlocking hundreds of possibilities with the least possible code.

We’ll start with the shapes themselves, discussing how we can cut out the bubble and tail by combining CSS gradients and clipping. Then, we’ll pick things back up in a second article dedicated to improving another common approach to tooltips using borders and custom shapes.

The HTML

We’re only working with a single element:

<div class="tooltip">Your text content goes here</div>

That’s the challenge: Create hundreds of tooltip variations in CSS with only a single element to hook into in the HTML.

A Simple Tooltip Tail

I’m going to skip right over the basic rectangular shape; you know how to set a width and height (or aspect-ratio) on elements. Let’s start with the simplest shape for the tooltip’s tail, one that can be accomplished with only two CSS properties:

.tooltip {
  /* tail dimension */
  --b: 2em; /* base */
  --h: 1em; /* height*/

  border-image: fill 0 // var(--h)
    conic-gradient(#CC333F 0 0); /* the color  */
  clip-path: 
    polygon(0 100%, 0 0, 100% 0, 100% 100%,
      calc(50% + var(--b) / 2) 100%,
      50% calc(100% + var(--h)),
      calc(50% - var(--b) / 2) 100%);
}

The border-image property creates an “overflowing color” while clip-path defines the shape of the tooltip with polygon() coordinates. (Speaking of border-image, I wrote a deep-dive on it and explain how it might be the only CSS property that supports double slashes in the syntax!)

The tooltip’s tail is placed at the bottom center, and we have two variables to control its dimensions:

We can do the exact same thing in more intuitive ways, like defining a background and then border (or padding) to create space for the tail:

background: #CC333F;
border-bottom: var(--h) solid #0000;

…or using box-shadow (or outline) for the outside color:

background: #CC333F;
box-shadow: 0 0 0 var(--h) #CC333F;

While these approaches are indeed easier, they require an extra declaration compared to the single border-image declaration we used. Plus, we’ll see later that border-image is really useful for accomplishing more complex shapes.

Here is a demo with the different directions so you can see how easy it is to adjust the above code to change the tail’s position.

We can fix this by setting limits to some values so the tail never falls outside the container. Two points of the polygon are concerned with the fix.

This:

calc(var(--p) + var(--b) / 2) 100%

…and this:

calc(var(--p) - var(--b) / 2) 100%

The first calc() needs to be clamped to 100% to avoid the overflow from the right side, and the second one needs to be clamped to 0% to avoid the overflow from the left side. We can use the min() and max() functions to establish the range limits:

clip-path: 
  polygon(0 100%, 0 0, 100% 0, 100% 100%,
    min(100%, var(--p) + var(--b) / 2) 100%,
    var(--p) calc(100% + var(--h)),
    max(0%, var(--p) - var(--b) / 2) 100%);

Adjusting The Tail Shape

Let’s integrate another variable, --x, into the clip-path() and use it to adjust the shape of the tail:

.tooltip {
  /* tail dimension */
  --b: 2em; /* base */
  --h: 1em; /* height*/

  --p: 50%;  /* tail position */
  --x: -2em; /* tail shape */

  border-image: fill 0 // 9999px
    conic-gradient(#CC333F 0 0); /* the color  */
  clip-path: 
    polygon(0 100%, 0 0, 100% 0, 100% 100%,
      min(100%, var(--p) + var(--b) / 2) 100%,
      calc(var(--p) + var(--x)) calc(100% + var(--h)),
      max(0%, var(--p) - var(--b) / 2) 100%);
}

The --x variable can be either positive or negative (using whatever unit you want, including percentages). What we’re doing is adding the variable that establishes the tail’s shape, --x, to the tail’s position, --p. In other words, we’ve updated this:

var(--p) calc(100% + var(--h))

…to this:

calc(var(--p) + var(--x)) calc(100% + var(--h))

And here is the outcome:

The tooltip’s tail points in either the right or left direction, depending on whether --x is a positive or negative value. Go ahead and use the range sliders in the following demo to see how the tooltip’s tail is re-positioned (--p) and re-shaped (--x) when adjusting two variables.

Note that I have updated the border-image outset to an impractically large value (9999px) instead of using the --h variable. The shape of the tail can be any type of triangle and can take a bigger area. Since there’s no way for us to know the exact value of the outset, we use that big value to make sure we have enough room to fill the tail in with color, no matter its shape.

Does the outset concept look strange to you? I know that working with border-image isn’t something many of us do all that often, so if this approach is tough to wrap your head around, definitely go check out my border-image article for a thorough demonstration of how it works.

Working With Gradients

Most of the trouble starts when we want to color the tooltip with a gradient instead of a flat color. Applying one color is simple — even with older techniques — but when it comes to gradients, it’s not easy to make the tail color flow smoothly into the container’s color.

But guess what? That’s no problem for us because we are already using a gradient in our border-image declaration!

border-image: fill 0 // var(--h)
  conic-gradient(#CC333F 0 0);

border-image only accepts gradients or images, so to produce a solid color, I had to use a gradient consisting of just one color. But if you change it into a “real” gradient that transitions between two or more colors, then you get your tooltip gradient. That’s all!

We start by declaring a background and border-radius on the .tooltip. Nothing fancy. Then, we move to the border-image property so that we can add a bar (highlighted in red in the last figure) that slightly overflows the container from the bottom. This part is a bit tricky, and here I invite you to read my previous article about border-image to understand this bit of CSS magic. From there, we add the clip-path and get our final shape.

.tooltip {
  /* triangle dimension */
  --b: 2em; /* base */
  --h: 1em; /* height */

  --p: 50%; /* position  */
  --r: 1.2em; /* the radius */
  --c: #4ECDC4;

  border-radius: var(--r);
  clip-path: polygon(0 100%, 0 0, 100% 0, 100% 100%,
    min(100%, var(--p) + var(--b) / 2) 100%,
    var(--p) calc(100% + var(--h)),
    max(0%, var(--p) - var(--b) / 2) 100%);
  background: var(--c);
  border-image: conic-gradient(var(--c) 0 0) fill 0/
    var(--r) calc(100% - var(--p) - var(--b) / 2) 0 calc(var(--p) - var(--b) / 2)/
    0 0 var(--h) 0;
}

This visual glitch happens when the border-image overlaps with the rounded corners. To fix this, we need to adjust the border-radius value based on the tail’s position (--p).

We are not going to update all the radii, only the bottom ones and, more precisely, the horizontal values. I want to remind you that border-radius accepts up to eight values — each corner takes two values that set the horizontal and vertical directions — and in our case, we will update the horizontal value of the bottom-left and bottom-right corners:

border-radius:
  /* horizontal values */
  var(--r) 
  var(--r) 
  min(var(--r),100% - var(--p) - var(--b)/2) /* horizontal bottom-right */
  min(var(--r),var(--p) - var(--b)/2) /* horizontal bottom-left */
  /
  /* vertical values */
  var(--r)
  var(--r)
  var(--r)
  var(--r)

All the corner values are equal to --r, except for the bottom-left and bottom-right corners. Notice the forward slash (/), as it is part of the syntax that separates the horizontal and vertical radii values.

Now, let’s dig in and understand what is happening here. For the bottom-left corner, when the position of the tail is on the right, the position (--p) variable value will be big in order to keep the radius equal to the radius (--r), which serves as the minimum value. But when the position gets closer to the left, the value of --p decreases and, at some point, becomes smaller than the value of --r. The result is the value of the radius slowly decreasing until it reaches 0. It adjusts as the position updates!

I know that’s a lot to process, and a visual aid usually helps. Try slowly updating the tail’s position in the following demo to get a clearer picture of what’s happening.

This time, the border image creates a horizontal bar along the bottom that is positioned directly under the element and extends outside of its boundary so that we have enough color for the tail when it’s closer to the edge.

.tooltip {
  /* tail dimension */
  --b: 2em; /* base */
  --h: 1.5em; /* height */

  --p: 50%; /* position */
  --x: 1.8em; /* tail position */
  --r: 1.2em; /* the radius */
  --c: #4ECDC4;

  border-radius: var(--r) var(--r) min(var(--r), 100% - var(--p) - var(--b) / 2) min(var(--r), var(--p) - var(--b) / 2) / var(--r);
  clip-path: polygon(0 100%, 0 0, 100% 0, 100% 100%,
    min(100%, var(--p) + var(--b) / 2) 100%,
    calc(var(--p) + var(--x)) calc(100% + var(--h)),
    max(0%, var(--p) - var(--b) / 2) 100%);
  background: var(--c);
  border-image: conic-gradient(var(--c) 0 0) 0 0 1 0 / 0 0 var(--h) 0 / 0 999px var(--h) 999px;
}

That’s why I do not use this approach when working with a simple isosceles triangle. This said, the method is perfectly fine, and in most cases, you may not see any visual glitches.

Putting Everything Together

We’ve looked at tooltips with tails that have equal sides, ones with tails that change shape, ones where the tail changes position and direction, ones with rounded corners, and ones that are filled in with gradients. What would it look like if we combined all of these examples into one mega-demo?

We can do it, but not by combining the approaches we’ve covered. We need another method, this time using a pseudo-element. No border-image for this one, I promise!

.tooltip {
  /* triangle dimension */
  --b: 2em; /* base */
  --h: 1em; /* height */

  --p: 50%; /* position */
  --r: 1.2em; /* the radius */

  border-radius: var(--r) var(--r) min(var(--r), 100% - var(--p) - var(--b) / 2) min(var(--r), var(--p) - var(--b) / 2) / var(--r);
  background: 0 0 / 100% calc(100% + var(--h)) 
    linear-gradient(60deg, #CC333F, #4ECDC4); /* the gradient */
  position: relative;
  z-index: 0;
}
.tooltip:before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0 0 calc(-1*var(--h));
  background-image: inherit;
  clip-path: 
    polygon(50% 50%,
      min(100%, var(--p) + var(--b) / 2) calc(100% - var(--h)),
      var(--p) 100%,
      max(0%, var(--p) - var(--b) / 2) calc(100% - var(--h)));
}

The pseudo-element is used to create the tail at the bottom and notice how it inherits the gradient from the main element to simulate a continuous gradient that covers the entire shape.

Another important thing to note is the background-size declared in the .tooltip. The pseudo-element is covering a bigger area due to the negative bottom value, so we have to increase the height of the gradient so it covers the same area.

Can you figure it out? The code for all of them is included in my tooltip collection if you need a reference, but do try to make them yourself — it’s good exercise! Maybe you will find a different (or perhaps better) approach than mine.

Scriptless Approach in Performance Testing: NeoLoad

In the evolving landscape of the software testing world, the need for rapid and efficient performance testing has become more crucial than ever. Conventional code-based testing tools have long been the standard, requiring specialized skills and considerable time and investments. Nevertheless, the arrival of low code/no code performance testing tools has marked a paradigm shift, offering a more accessible and efficient alternative. Below, we will explore the reasons why low code/no code performance testing tools like Tricentis NeoLoad are going to change performance test automation and how they will outshine their traditional counterparts.

What Is a Low Code/No Code Approach?

Low code/no code platforms have emerged as powerful tools, enabling users with limited coding expertise to develop applications and automate processes effortlessly. These platforms boast intuitive drag-and-drop interfaces, visual workflows, and a wealth of pre-built components, facilitating the rapid creation of robust applications. In the domain of performance testing, low code/no code tools offer an efficient approach, allowing testers to design, execute, and analyze performance tests without the need for extensive scripting or coding knowledge.