<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Vasantha Kumar on Medium]]></title>
        <description><![CDATA[Stories by Vasantha Kumar on Medium]]></description>
        <link>https://medium.com/@kvasanth373?source=rss-ca6af442e68d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*0myL7KRlm5F6jejFBIxiHA.jpeg</url>
            <title>Stories by Vasantha Kumar on Medium</title>
            <link>https://medium.com/@kvasanth373?source=rss-ca6af442e68d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 14:50:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kvasanth373/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Supercharge Your Browsing with JumpTo: The Ultimate Shortlink Extension]]></title>
            <link>https://medium.com/@kvasanth373/supercharge-your-browsing-with-jumpto-the-ultimate-shortlink-extension-34d26584c799?source=rss-ca6af442e68d------2</link>
            <guid isPermaLink="false">https://medium.com/p/34d26584c799</guid>
            <category><![CDATA[web-development-tools]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[browser-extension]]></category>
            <category><![CDATA[chrome-extension]]></category>
            <dc:creator><![CDATA[Vasantha Kumar]]></dc:creator>
            <pubDate>Sat, 28 Dec 2024 19:13:35 GMT</pubDate>
            <atom:updated>2024-12-28T19:13:35.139Z</atom:updated>
            <content:encoded><![CDATA[<p>We’ve all been there. You’re juggling multiple projects, each with its own set of links — GitHub repos, design files, documentation, project management boards. Remembering and quickly accessing these resources can be a real pain. That’s where <strong>JumpTo</strong> comes in.</p><p>JumpTo is a powerful browser extension I created (available on the <a href="https://chromewebstore.google.com/detail/jumpto/phcgdchicomdkpiohonofdhhafdmanhi?authuser=0&amp;hl=en">Chrome Web Store</a>) that revolutionizes how you navigate the web using custom shortlinks. Think of it as your personal, browser-integrated URL shortener, but with superpowers. In this post, we’ll dive into what makes JumpTo special, how it works, and why you should consider adding it to your browsing arsenal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*Ni3iT9sQvPWdaozbYanlKQ.gif" /><figcaption>demo</figcaption></figure><h3>Two Ways to Jump, One Destination</h3><p>JumpTo caters to different browsing styles. Whether you’re a Chrome/Brave user or prefer the sleek interface of Arc (or any other browser), JumpTo has you covered:</p><p><strong>1. The Chrome/Brave Way (Omnibox Integration):</strong></p><ul><li>Type go in your address bar.</li><li>Hit Tab or Space.</li><li>Enter your shortcut (e.g., gh for GitHub).</li><li>Boom! You’re there.</li></ul><p>This leverages Chrome’s Omnibox API for a seamless, integrated experience.</p><p><strong>2. The Universal Way ( go/shortcut ):</strong></p><ul><li>Simply type go/ followed by your shortcut (e.g., go/gh).</li><li>Works in any browser that supports extensions!</li></ul><p>This method relies on intercepting navigation requests, making it universally compatible.</p><h3>Core Features That Will Make You Jump for Joy</h3><p>JumpTo isn’t just a basic URL shortener. It’s packed with features designed to enhance your productivity:</p><ul><li><strong>Custom Shortlinks:</strong> Assign short, memorable keywords to any URL. go/mydoc could instantly take you to that shared Google Doc you always need.</li><li><strong>Dark Mode Support:</strong> Easy on the eyes, especially during those late-night coding sessions.</li><li><strong>Usage Statistics:</strong> Track your most-used shortcuts and see how JumpTo is saving you time.</li><li><strong>Import/Export:</strong> Backup your shortcuts or migrate them between browsers effortlessly.</li><li><strong>Recent Shortcuts History:</strong> Quickly access the shortcuts you’ve used recently.</li><li><strong>Keyboard Shortcuts:</strong> For the ultimate power user, control JumpTo without ever leaving your keyboard. Ctrl/Cmd + Shift + K to open the popup, Ctrl/Cmd + K to focus the search, and Ctrl/Cmd + N to add a new shortcut — it’s all there.</li></ul><h3>Installation: Get Jumping in Minutes</h3><p>You can install JumpTo directly from the <a href="https://www.google.com/url?sa=E&amp;q=https%3A%2F%2Fchromewebstore.google.com%2Fdetail%2Fjumpto%2Fphcgdchicomdkpiohonofdhhafdmanhi%3Fauthuser%3D0%26hl%3Den">Chrome Web Store</a> with a single click.</p><p>For developers or those who prefer a more hands-on approach, you can build and install it locally:</p><pre># Clone the repository<br>git clone https://github.com/orcawhisperer/jump-to.git<br><br># Navigate to the directory<br>cd jump-to<br><br># Install dependencies<br>npm install<br><br># Build for development<br>npm run dev<br><br># Or, build for production<br>npm run build</pre><p>Then, in Chrome, enable “Developer mode” in chrome://extensions/, click “Load unpacked,” and select the dist folder.</p><h3>Under the Hood: A Peek at the Tech Stack</h3><p>JumpTo is built with a modern web development stack:</p><ul><li><strong>React:</strong> For a dynamic and responsive user interface.</li><li><strong>TypeScript:</strong> Ensuring type safety and catching errors early.</li><li><strong>Tailwind CSS:</strong> Rapidly styling components with utility-first CSS.</li><li><strong>shadcn/ui:</strong> Beautifully designed components built on top of Radix UI and Tailwind CSS.</li><li><strong>Chrome Extensions API:</strong> Harnessing the power of browser extensions.</li></ul><p><strong>Project Structure:</strong></p><p>The project is organized for clarity and maintainability:</p><pre>jumpto/<br>├── src/<br>│   ├── assets/        # Icons and images<br>│   ├── components/    # Reusable UI components<br>│   ├── hooks/         # Custom React hooks<br>│   ├── services/      # Logic for storage, analytics, URLs<br>│   ├── pages/         # Popup and options page<br>│   ├── background/    # Background service worker<br>│   └── content/       # Content script<br>├── webpack/         # Webpack configuration<br>├── dist/            # Build output<br>└── package.json     # Dependencies and scripts</pre><h3>The Power of the Chrome Extensions API</h3><p>JumpTo leverages several key parts of the Chrome Extensions API:</p><ul><li><strong>chrome.storage:</strong> To store shortcuts, settings, and usage statistics locally.</li><li><strong>chrome.webNavigation:</strong> To intercept navigation requests and redirect go/ URLs.</li><li><strong>chrome.omnibox:</strong> To integrate with Chrome’s address bar for suggestions and shortcut triggering.</li><li><strong>chrome.commands:</strong> To enable global keyboard shortcuts.</li><li><strong>chrome.action:</strong> To manage the browser action (the popup).</li><li><strong>chrome.tabs:</strong> To create or update tabs with shortcut URLs.</li></ul><h3>Inside the Code: Key Highlights</h3><p>Let’s highlight a few interesting parts of the codebase:</p><p><strong>1. background/index.ts:</strong> This is the heart of the extension. It listens for navigation events, omnibox interactions, and command triggers.</p><ul><li><strong>URL Interception:</strong> The chrome.webNavigation.onBeforeNavigate listener checks if the URL starts with go/, extracts the shortcut, and redirects to the corresponding URL if found.</li><li><strong>Omnibox Handling:</strong> chrome.omnibox.onInputChanged provides suggestions based on the user’s input, while chrome.omnibox.onInputEntered handles the final shortcut selection.</li></ul><p><strong>2. services/storage.ts:</strong> This service abstracts away the interaction with chrome.storage.local, providing methods to get, set, and manage shortcuts, settings, and other data.</p><p><strong>3. services/url.ts:</strong> This service handles URL validation, sanitization, and shortcut suggestion. It includes important security checks, like validateSafety, to help protect users from potentially malicious URLs.</p><p><strong>4. hooks/useShortcuts.ts:</strong> This custom hook encapsulates the logic for managing shortcuts, including adding, deleting, updating, tracking usage, and importing/exporting.</p><p><strong>5. hooks/useKeyboardShortcut.ts:</strong> This hook provides a declarative way to bind keyboard shortcuts to actions within the extension.</p><p><strong>6. components/: </strong>This folder contains reusable UI components built with shadcn/ui and Tailwind, providing a consistent and visually appealing interface.</p><p><strong>7. pages/:</strong> This folder contains the UI for the popup (what you see when you click the extension icon) and the options page.</p><h3>Security and Privacy Considerations</h3><p>JumpTo takes user privacy and security seriously.</p><ul><li><strong>Minimal Permissions:</strong> The extension only requests the necessary permissions to function.</li><li><strong>Local Storage:</strong> All data is stored locally in the user’s browser.</li><li><strong>Optional Analytics:</strong> Usage analytics are collected only if the user explicitly enables them in the settings. The AnalyticsService ensures that events are only tracked if analytics are enabled and provides a mechanism for periodic syncing (although the actual syncing to a remote server is left as a placeholder in this version).</li><li><strong>URL Safety Checks:</strong> The UrlService.validateSafety method provides basic URL validation to help prevent navigation to suspicious domains. This could be further enhanced by integrating with services like Google Safe Browsing API in the future.</li></ul><h3>Future Enhancements</h3><p>JumpTo is already a powerful tool, but there’s always room for improvement. Here are some potential future enhancements:</p><ul><li><strong>Cloud Syncing:</strong> Allow users to sync their shortcuts across multiple devices using a cloud storage provider.</li><li><strong>Smart URL Suggestions:</strong> JumpTo intelligently suggests shortcuts based on the domain of the URL, saving you precious seconds.</li><li><strong>Advanced Search:</strong> Implement fuzzy searching or filtering by category/tags within the popup.</li><li><strong>Regex Support:</strong> Enable power users to define shortcuts using regular expressions for more complex URL patterns.</li><li><strong>Customizable Themes:</strong> Allow users to personalize the look and feel of the extension.</li><li><strong>Integration with Other Services:</strong> Connect with other productivity tools or APIs.</li></ul><h3>Contribute and Jump In!</h3><p>JumpTo is an open-source project, and contributions are welcome! Check out the <a href="https://github.com/orcawhisperer/jump-to">GitHub repository</a>, fork it, and start building your amazing features. Let’s make JumpTo even better together!</p><h3>Conclusion</h3><p>JumpTo is more than just a URL shortener; it’s a productivity booster that streamlines your browsing experience. By combining custom shortlinks, smart suggestions, and a touch of browser magic, JumpTo empowers you to navigate the web with unparalleled speed and efficiency. Install it today and experience the joy of jumping directly to where you need to be!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=34d26584c799" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building My Portfolio Website with Rust and Leptos: A Journey into WebAssembly]]></title>
            <link>https://medium.com/google-cloud/building-my-portfolio-website-with-rust-and-leptos-a-journey-into-webassembly-12709ee4ab10?source=rss-ca6af442e68d------2</link>
            <guid isPermaLink="false">https://medium.com/p/12709ee4ab10</guid>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[gcp-app-dev]]></category>
            <category><![CDATA[webassembly]]></category>
            <category><![CDATA[lepto]]></category>
            <category><![CDATA[rust]]></category>
            <dc:creator><![CDATA[Vasantha Kumar]]></dc:creator>
            <pubDate>Tue, 05 Mar 2024 10:58:47 GMT</pubDate>
            <atom:updated>2025-10-26T07:23:18.019Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Oy1NXSkkoi5Jic0vyZJjrQ.jpeg" /><figcaption>Rust + Wasm + Leptos</figcaption></figure><p>As a software engineer, having a strong portfolio website is crucial for showcasing your skills and attracting potential employers. While there are many tools and frameworks available, I wanted to take a different approach and build my portfolio using Rust and the Leptos web framework. This decision was driven by several factors:</p><ul><li><strong>Learning Rust:</strong> I’ve been fascinated by <a href="https://www.rust-lang.org/">Rust’s</a> potential for web development and wanted to gain practical experience with the language.</li><li><strong>Exploring WebAssembly:</strong> <a href="https://leptos.dev/">Leptos</a> leverages <a href="https://webassembly.org/">WebAssembly (WASM)</a>, which allows for near-native performance in web applications. I was eager to explore this technology and its benefits.</li><li><strong>Tailwind CSS:</strong> I appreciate <a href="https://tailwindcss.com/">Tailwind’s</a> utility-first approach to styling, which makes it easy to create a clean and responsive website.</li><li><strong>GCP: </strong>Google Cloud Platform provides a broad range of modular services including compute, storage, data analytics, machine learning, and many more. I’ll be deploying this application in the App Engine.</li></ul><h3>The Development Process</h3><p>The project involved several key steps:</p><ol><li><strong>Defining Components:</strong> I broke down the website into reusable components like About, Experience, and Skills. This modular approach made development and maintenance easier.</li><li><strong>Data Modeling:</strong> I created data structures in Rust to represent the information displayed on the website, such as my bio, skills, and experience details. This data is loaded from a JSON file, allowing for easy updates.</li><li><strong>Server-Side Rendering (SSR) and Hydration:</strong> Leptos provides excellent support for SSR, which improves SEO and initial page load times. It also allows for client-side hydration, ensuring a smooth and interactive user experience.</li><li><strong>Styling with Tailwind CSS:</strong> Tailwind’s utility classes made it easy to style the website and achieve a clean and responsive design.</li><li><strong>Deployment on GCP:</strong> I chose Google Cloud Platform to host the website, leveraging its scalability and reliability.</li></ol><h3>Challenges and Learnings</h3><p>While the project was a rewarding experience, it also presented some challenges:</p><ul><li><strong>Learning Curve:</strong> Rust and Leptos are relatively new technologies, and the learning curve was steeper compared to more established web development tools. However, the supportive community and excellent documentation helped me overcome these hurdles.</li><li><strong>Debugging WASM:</strong> Debugging WASM code can be tricky, but Leptos provides helpful tools and techniques to identify and resolve issues.</li></ul><p>Despite the challenges, I learned a great deal about Rust, WebAssembly, and modern web development practices. I’m thrilled with the final result, a performant and visually appealing portfolio website that showcases my skills and interests.</p><h3>Code Snippets: A Glimpse into the Project</h3><p>To give you a better understanding of the development process, let’s look at some critical code snippets:</p><p><strong>1. Defining a Component:</strong></p><p>Here’s how I defined the Hero component, which displays my name and title:</p><pre>#[component]<br>pub fn Hero(name: ReadSignal&lt;String&gt;, title: ReadSignal&lt;String&gt;) -&gt; impl IntoView {<br>    ...<br>    view! {<br>        &lt;section id=&quot;hero&quot; class=&quot;...&quot;&gt;<br>            &lt;div class=&quot;container mx-auto&quot;&gt;<br>                &lt;h2 class=&quot;text-4xl ...&quot;&gt;{name}&lt;/h2&gt;<br>                &lt;h3 class=&quot;text-xl ...&quot;&gt;{title}&lt;/h3&gt;<br>            &lt;/div&gt;<br>        &lt;/section&gt;<br>    }<br>}</pre><p>This code uses Lepto’s view! macro to define the HTML structure of the component. It also demonstrates how to use reactive signals (name and title) to dynamically update the content.</p><p><strong>2. Data Loading and Reactivity:</strong></p><p>The following snippet shows how I loaded user data from a JSON file and ensured reactivity:</p><pre>#[server(name = LoadData, prefix = &quot;/api&quot;,<br>    endpoint = &quot;load-data&quot;, input = GetUrl,<br>    output = Json)]<br>pub async fn load_data() -&gt; Result&lt;User, ServerFnError&gt; {<br>    let file = File::open(&quot;./data/data.json&quot;)?;<br>    let data: User = serde_json::from_reader(file)?;<br>    Ok(data)<br>}</pre><p>This function utilizes Rust’s file I/O capabilities and the serde_json crate to parse the JSON data into a User struct.</p><pre>let (data_loaded, set_data_loaded) = create_signal(false);<br>let (data, set_data) = create_signal(User::new());<br><br>create_local_resource(<br>    || (),<br>    move |_| async move {<br>        let data_result = load_data().await;<br>        if let Ok(data) = data_result {<br>            set_data.update(|user_data: &amp;mut User| *user_data = data);<br>            set_data_loaded.update(|_| true);<br>        }<br>        ...<br>    },<br>);</pre><p>This code uses Lepto’s create_local_resource and create_signal functions to manage data loading and reactivity, ensuring the UI updates automatically when data changes.</p><h3>Deployment on Google Cloud Platform (GCP)</h3><p>For hosting my portfolio website, I chose Google Cloud Platform (GCP) due to its scalability, reliability, and ease of use. Here’s a brief overview of the deployment process:</p><p><strong>Dockerizing the Application:</strong> I created a Dockerfile to containerize the Rust application and its dependencies. This ensures consistent deployment across different environments.</p><pre>FROM rustlang/rust:nightly-bullseye as builder<br><br># Install dependencies and build the application<br><br>FROM rustlang/rust:nightly-bullseye as runner<br><br># Copy the built application and static assets<br><br>WORKDIR /app<br><br># Set environment variables and expose port<br><br>CMD [&quot;/app/portfolio&quot;]</pre><p><strong>Building and Pushing the Docker Image:</strong> Using Cloud Build, I automated the process of building the Docker image and pushing it to the Google Container Registry (GCR). This allows for easy versioning and rollbacks.</p><pre>steps:<br>  - name: &quot;gcr.io/cloud-builders/docker&quot;<br>    args: [&quot;build&quot;, &quot;-t&quot;, &quot;gcr.io/$PROJECT_ID/portfolio:$TAG_NAME&quot;, &quot;.&quot;]<br>  - name: &quot;gcr.io/cloud-builders/docker&quot;<br>    args: [&quot;push&quot;, &quot;gcr.io/$PROJECT_ID/portfolio:$TAG_NAME&quot;]</pre><p><strong>Deploying to Google App Engine:</strong> Finally, I deployed the Docker image to Google App Engine, which provides a fully managed platform for hosting web applications. App Engine automatically scales the application based on traffic, ensuring optimal performance and cost efficiency.</p><pre>gcloud app deploy --image-url=gcr.io/$PROJECT_ID/portfolio:$TAG_NAME</pre><p>This deployment setup allows me to easily update and manage my portfolio website while ensuring high availability and performance for visitors.</p><h3>Conclusion</h3><p>Building my portfolio website with Rust and Leptos was a valuable learning experience. It allowed me to explore exciting new technologies and create a website that stands out from the crowd. If you’re a developer looking to challenge yourself and learn something new, I highly recommend giving Rust and Leptos a try.</p><p><strong>Check out the website:</strong> <a href="https://www.vasanthakumar.dev/">https://www.vasanthakumar.dev/</a></p><p><strong>Leave a star on the GitHub repository: </strong><a href="https://github.com/iamvasanth07/portfolio-leptos">https://github.com/orcawhisper/portfolio-leptos</a></p><p>I hope this blog post inspires you to explore new technologies and build something awesome!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=12709ee4ab10" width="1" height="1" alt=""><hr><p><a href="https://medium.com/google-cloud/building-my-portfolio-website-with-rust-and-leptos-a-journey-into-webassembly-12709ee4ab10">Building My Portfolio Website with Rust and Leptos: A Journey into WebAssembly</a> was originally published in <a href="https://medium.com/google-cloud">Google Cloud - Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Pixels to Characters: Transforming Videos into Captivating ASCII Art in Rust]]></title>
            <link>https://medium.com/@kvasanth373/from-pixels-to-characters-transforming-videos-into-captivating-ascii-art-in-rust-a976041dbf56?source=rss-ca6af442e68d------2</link>
            <guid isPermaLink="false">https://medium.com/p/a976041dbf56</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[ascii]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[rust]]></category>
            <category><![CDATA[opencv]]></category>
            <dc:creator><![CDATA[Vasantha Kumar]]></dc:creator>
            <pubDate>Sun, 31 Dec 2023 17:02:16 GMT</pubDate>
            <atom:updated>2023-12-31T17:05:32.964Z</atom:updated>
            <content:encoded><![CDATA[<p>The mesmerizing allure of videos goes beyond vibrant colors and fluid motion. Imagine capturing their essence, not with pixels, but with the raw power of text. This is the magic of ASCII art, and in this blog, we’ll delve into its world, turning videos into captivating character tapestries using the potent Rust language.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FGPY4g1mLTM4%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DGPY4g1mLTM4&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FGPY4g1mLTM4%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/7ac53ca505258bbb1f827c18b63d7da8/href">https://medium.com/media/7ac53ca505258bbb1f827c18b63d7da8/href</a></iframe><h4>From Script to Screen:</h4><p>Our journey begins with OpenCV, a robust library for computer vision in Rust. With it, we’ll load the video you choose, opening a gateway to its frames. Each frame, a snapshot of frozen motion, will be our canvas for artistic transformation.</p><h4>Step 1: Load the Video</h4><p>Our journey begins with opening the door to the video itself. To do this, we leverage the power of OpenCV’s VideoCapture, a dedicated tool for interacting with video sources. Think of it as a magic key that unlocks the video&#39;s hidden frames, granting us access to its visual tapestry.</p><pre>use videoio::VideoCapture;<br><br>// ...<br><br>let mut cap = VideoCapture::from_file(video_path, 0).unwrap();</pre><h4><strong>Step 2: Grayscale Alchemy</strong></h4><p>Color, while beautiful, adds complexity to our artistic endeavor. Therefore, we’ll invoke the transformative power of imgproc, OpenCV&#39;s image processing module. With a flick of its grayscale spell, each frame sheds its colorful coat, revealing a simpler world of light and shadow.</p><pre>let mut gray = core::Mat::default();<br>imgproc::cvt_color(&amp;frame, &amp;mut gray, imgproc::COLOR_BGR2GRAY, 0).unwrap();</pre><p>This line calls OpenCV’s cvt_color function to transform the colorful frame into a grayscale image, stored in the gray variable. This simplifies the subsequent processing and aligns with the monochromatic nature of ASCII art.</p><h4>Step 3: Scaling the Canvas</h4><p>Imagine a vast, detailed painting crammed onto a tiny canvas. The intricacies would blur. Likewise, a high-resolution video might overwhelm our ASCII representation. So, using OpenCV’s resizing magic, we’ll adjust the frame dimensions to a size optimal for text-based rendering.</p><pre>let mut resized_frame = core::Mat::default();<br>imgproc::resize(<br>            &amp;gray,<br>            &amp;mut resized_frame,<br>            core::Size::new(width, height),<br>            0.0,<br>            0.0,<br>            imgproc::INTER_LINEAR,<br>        )<br>        .unwrap();</pre><h4>Step 4: The Dance of Pixels and Characters</h4><p>Here’s where the true artistry takes flight. Each pixel in the resized frame holds a value representing its brightness. Our task is to map these values to a carefully chosen set of ASCII characters. Think of it as a dance between light and symbol, where darkness whispers “@” and bright areas shimmer like “.”.</p><p>In our code, we define a string of characters, each representing a different level of brightness. Then, we use a simple formula to map each pixel’s value to its corresponding character. This mapping breathes life into the frame, transforming numeric values into evocative symbols.</p><pre>fn pixel_to_ascii(pixel: u8) -&gt; String {<br>    let ascii_chars = &quot; .,:;i1tfLCG08@&quot;;<br>    let ascii_chars_len = ascii_chars.len();<br>    let pixel_index = pixel as usize * ascii_chars_len / 256;<br>    ascii_chars.chars().nth(pixel_index).unwrap().to_string()<br>}</pre><p>This function is the heart of the pixel-to-character mapping. It takes a pixel’s brightness value (pixel) and uses a string of ASCII characters (ascii_chars) to represent different levels of brightness. The formula calculates an index within the character string, and the corresponding character is returned, creating the ASCII representation of the pixel.</p><h4>Step 5: Weaving the Frames into Video Tapestry</h4><p>With each frame a tapestry of characters, we now need to weave them together to create the animated magic of video. To achieve this, we’ll loop through each processed frame, replacing the original frame data with its ASCII counterpart. Imagine it as a silent movie, where flickering lines of text narrate the visual story.</p><pre>loop {<br>    // ... (frame loading and processing)<br><br>    // Map pixels to ASCII characters<br>    let mut ascii_frame = String::new();<br>    for y in 0..height {<br>        for x in 0..width {<br>            ascii_frame += &amp;pixel_to_ascii(*resized_frame.at_2d::&lt;u8&gt;(y, x).unwrap());<br>        }<br>        ascii_frame += &quot;\n&quot;;<br>    }<br><br>    // Clear screen and display ASCII frame<br>    clearscreen::clear().unwrap();<br>    println!(&quot;{}&quot;, ascii_frame);<br><br>    // Pause for frame duration<br>    std::thread::sleep(std::time::Duration::from_millis(frame_duration.try_into().unwrap()));<br>}</pre><h4>Step 6: Bringing the Art to Life</h4><p>Finally, it’s time to unveil our creation. We’ll clear the console screen, ensuring each frame gets its moment in the spotlight. Then, with a triumphant println, we&#39;ll display the ASCII frame, letting the characters dance across the screen, recreating the video&#39;s essence in a new, textual medium.</p><h4>But the Journey Doesn’t End Here:</h4><p>Think of this code as a springboard for your creative exploration. Experiment with different character sets, mapping schemes, and frame sizes to discover unique artistic expressions. You could even explore advanced techniques like dithering or dynamic character selection to achieve even greater levels of detail and nuance.</p><p>So, grab your video file, embrace the power of Rust, and embark on your own journey into the fascinating world of ASCII art video conversions. Let your imagination guide you, and let the characters dance! <a href="https://github.com/iamvasanth07/video-to-ascii-rust">Here’s the project link</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a976041dbf56" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Pic to Prose: Whipping Up ASCII Art with Rust and OpenCV]]></title>
            <link>https://medium.com/@kvasanth373/from-pic-to-prose-whipping-up-ascii-art-with-rust-and-opencv-005ffcade94c?source=rss-ca6af442e68d------2</link>
            <guid isPermaLink="false">https://medium.com/p/005ffcade94c</guid>
            <category><![CDATA[ascii-art]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[opencv]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[rust]]></category>
            <dc:creator><![CDATA[Vasantha Kumar]]></dc:creator>
            <pubDate>Fri, 29 Dec 2023 15:54:12 GMT</pubDate>
            <atom:updated>2023-12-29T15:54:12.840Z</atom:updated>
            <content:encoded><![CDATA[<p>Forget filters and fancy edits, let’s cook up some real magic with our computers! Today’s menu: turning any old picture into a sizzling hot plate of ASCII art, using the dynamic duo of Rust and OpenCV. Think words dancing like pixels, capturing the essence of an image in pure text-based awesomeness.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OGiS4h2lkxI-irl9YjMvSw.jpeg" /></figure><p>Grab your digital spatulas:</p><ul><li>Rust: Our trusty oven, blazing fast and super safe for all your coding adventures. Install it from <a href="https://www.rust-lang.org/tools/install">https://www.rust-lang.org/tools/install</a>.</li><li>OpenCV: The secret spice, a library that lets us play with images like a pro. Grab it from <a href="https://opencv.org/releases/">https://opencv.org/releases/</a>.</li><li>Any cool pic: From your cat’s sassy stare to that breathtaking sunset, any image can be the star of this show.</li></ul><h4>Step 1: Kneading the Dough (Reading and Grayscaling):</h4><pre>use opencv::core;<br>use opencv::imgcodecs;<br>// ... other imports<br><br>fn main() {<br>    // ... other code<br><br>    let image = imgcodecs::imread(args[1].as_str(), imgcodecs::IMREAD_COLOR).unwrap();<br>    let mut gray_image = Mat::default();<br>    imgproc::cvt_color(&amp;image, &amp;mut gray_image, imgproc::COLOR_BGR2GRAY, 0).unwrap();<br><br>    // ... rest of the code<br>}</pre><p>This code snippet is like tossing the pizza dough into the oven. It reads the image using OpenCV and transforms it into a grayscale masterpiece, setting the stage for our ASCII art creation.</p><h4>Step 2: Shaping the Loaf (Scaling and Resizing):</h4><pre>// ... other code<br><br>let desired_width = 150;<br>let desired_height = 150;<br><br>// Calculate scaling factor while maintaining aspect ratio<br>// ... (code for scaling and resizing)<br><br>let mut resized = Mat::default();<br>imgproc::resize(&amp;gray_image, &amp;mut resized, core::Size::new(new_width, new_height), 0.0, 0.0, imgproc::INTER_LINEAR).unwrap();</pre><p>Here, we’re ensuring our ASCII art isn’t too squished or stretched, just like shaping pizza dough to fit the pan. The code calculates the optimal scaling factor and resizes the image accordingly.</p><h4>Step 3: The Fiery Transformation (ASCII Conversion):</h4><pre>// ... other code<br><br>let ascii_chars = &quot;@%#*+=-:. &quot;;<br>let mut ascii_art = String::new();<br><br>for i in 0..resized.rows() {<br>    for j in 0..resized.cols() {<br>        // ... (code for mapping pixels to ASCII characters)<br>        ascii_art.push(ascii_chars.chars().nth(ascii_index).unwrap());<br>    }<br>    ascii_art.push(&#39;\n&#39;);<br>}</pre><p>This is where the magic happens! We define a palette of ASCII characters and map each pixel’s intensity to a character, creating the text-based masterpiece. Imagine picking toppings for your pizza, but with text instead of pepperoni!</p><h4>Step 4: Serving the Sizzle (Output and Appreciation):</h4><pre>// ... other code<br><br>let mut file = File::create(format!(&quot;{}.txt&quot;, args[1].split(&#39;.&#39;).collect::&lt;Vec&lt;&amp;str&gt;&gt;()[0])).unwrap();<br>file.write_all(ascii_art.as_bytes()).unwrap();<br><br>println!(&quot;{}&quot;, ascii_art);</pre><p>Finally, we present our ASCII art creation, both by saving it to a text file for sharing and printing it directly to the console for instant gratification. It’s like serving up a piping hot pizza, ready to be devoured by eager eyes! <a href="https://github.com/iamvasanth07/img-to-ascii-rust">Here’s the project link</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=005ffcade94c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simplifying SAML Authentication in Looker: A Step-by-Step Guide]]></title>
            <link>https://medium.com/google-cloud/simplifying-saml-authentication-in-looker-a-step-by-step-guide-7bde04d0ebae?source=rss-ca6af442e68d------2</link>
            <guid isPermaLink="false">https://medium.com/p/7bde04d0ebae</guid>
            <category><![CDATA[okta]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[sso]]></category>
            <category><![CDATA[gcp-security-operations]]></category>
            <category><![CDATA[looker]]></category>
            <dc:creator><![CDATA[Vasantha Kumar]]></dc:creator>
            <pubDate>Fri, 23 Jun 2023 00:31:24 GMT</pubDate>
            <atom:updated>2023-06-23T00:31:24.098Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p><a href="https://cloud.google.com/looker/docs">Looker</a> is a modern, user-friendly platform for data analytics and business intelligence. It allows organizations to explore, analyze, and share real-time business analytics with ease. On the other hand, <a href="https://okta.com/">Okta</a> is a popular identity and access management service that provides secure identity management and Single Sign-On (SSO) capabilities.</p><p>Security Assertion Markup Language (SAML) is a standard for exchanging authentication and authorization data between parties. By integrating SAML into Looker via Okta, you can provide SSO access to your users, enhancing security and user experience. In this guide, we’ll walk you through configuring SAML 2.0 for Looker.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nAZkNANiGxGjRDNE3vAG_g.png" /></figure><h3>Prerequisites</h3><p>Before we begin, you’ll need to have administrative access to both Looker and Okta.</p><h3>Step 1: Configuring Okta</h3><p>First, log into Okta as Administrator and add the <a href="https://www.okta.com/integrations/looker/">Looker integration App</a> from which you can get SAML setup instructions and metadata that will be used for configuring Looker.</p><figure><img alt="Okta Admin Looker Integration App" src="https://cdn-images-1.medium.com/max/1024/1*BEUFMZqg_YpDNj7IrN-s0w.png" /><figcaption>Okta Admin Looker Integration App</figcaption></figure><h3>Step 2: Configuring SAML in Looker</h3><p>Log into Looker as an Administrator. Navigate to the Admin section and select ‘SAML Authentication’. Once there, you’ll need to enable SAML authentication.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/1*oVYWSRrerZ2vklSK4Rtinw.png" /></figure><h3>Step 3: Setting Up SAML Auth Settings</h3><p>In the SAML Auth Settings section, you’ll need to enter information that will be provided by Okta. This includes the IdP URL, IdP Issuer, and IdP Certificate files. You can obtain these details from the Okta Admin dashboard.</p><figure><img alt="Looker Admin SAML Settings" src="https://cdn-images-1.medium.com/max/1024/1*t3-ovxlHh9e3jNV8fe_l8w.png" /><figcaption>Looker Admin SAML Settings</figcaption></figure><h3>Step 4: Configuring User Attributes</h3><p>Next, in the User Attribute Settings section, you’ll need to set three key attributes:</p><ul><li>Email Attr: Enter ‘Email’.</li><li>FName Attr: Enter ‘FirstName’.</li><li>LName Attr: Enter ‘LastName’.</li></ul><p>These attributes map to the corresponding user details in Okta.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6b3iz0MMBW42iCw8Rh7Sdw.png" /></figure><h3>Step 5: Setting Up Roles</h3><p>If you’re not planning to set roles from groups, simply select ‘Default New User Roles’ from the dropdown list in the Role Settings section.</p><p>However, if you want to assign roles based on groups, enable the ‘Mirror SAML Groups’ switch. Then:</p><ul><li>In the Groups Attribute field, enter ‘Groups’.</li><li>Enable the ‘Auth Requires Role’ switch.</li><li>In the Group To Role Pairings section, enter a group name that will be sent and then select a corresponding role in Looker.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q5KOGJm5ivYs7R9X6xDzlg.png" /><figcaption>Looker Admin Dashboard — SAML Groups</figcaption></figure><h3>Step 6: Testing and Saving</h3><p>Before you finalize your settings, test the SAML authentication. A successful test will validate the server response.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k5n1AZrDa1aAQH7_cu6qCw.png" /></figure><p>Finally, select the appropriate migration options and update the settings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1UbrPRUKDMYVZKD_NlmNCA.png" /></figure><p>Congratulations, you have now configured SAML 2.0 for Looker!</p><h3>Conclusion</h3><p>Setting up SAML 2.0 in Looker using Okta is straightforward and offers numerous benefits, including enhanced security and streamlined user access. Remember to always test your settings before deploying to ensure a smooth transition for your users.</p><h3>Useful Links</h3><ol><li><a href="https://cloud.google.com/looker/docs">Looker </a>— Google Cloud’s Official documentation.</li><li><a href="https://cloud.google.com/looker/docs/admin-panel-authentication-saml">Setting up SAML authentication for Looker</a> — This page on Google Cloud’s documentation provides instructions on setting up SAML authentication for Looker​.</li><li><a href="https://saml-doc.okta.com/SAML_Docs/How-to-Configure-SAML-2.0-for-Looker.html">How to Configure SAML 2.0 for Looker</a> — This guide by Okta provides detailed instructions on configuring SAML 2.0 for Looker​.</li><li><a href="https://www.okta.com/integrations/looker/">Okta + Looker Integration</a> — This page details the Okta SAML 2.0 App and its features.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7bde04d0ebae" width="1" height="1" alt=""><hr><p><a href="https://medium.com/google-cloud/simplifying-saml-authentication-in-looker-a-step-by-step-guide-7bde04d0ebae">Simplifying SAML Authentication in Looker: A Step-by-Step Guide</a> was originally published in <a href="https://medium.com/google-cloud">Google Cloud - Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Architecting a Scalable and Secure Cloud-Based Database Solution: A Deep Dive into Integrating …]]></title>
            <link>https://medium.com/google-cloud/architecting-a-scalable-and-secure-cloud-based-database-solution-a-deep-dive-into-integrating-a22a5771aeaa?source=rss-ca6af442e68d------2</link>
            <guid isPermaLink="false">https://medium.com/p/a22a5771aeaa</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[pgbouncer]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <dc:creator><![CDATA[Vasantha Kumar]]></dc:creator>
            <pubDate>Tue, 20 Jun 2023 16:37:42 GMT</pubDate>
            <atom:updated>2023-06-20T16:37:42.261Z</atom:updated>
            <content:encoded><![CDATA[<h3>Architecting a Scalable and Secure Cloud-Based Database Solution: A Deep Dive into Integrating Cloud SQL, PgBouncer, CloudSQL Proxy, and HammerDB for Optimal Performance</h3><h3>Introduction</h3><p>PgBouncer is a lightweight connection pooler for PostgreSQL, whereas Cloud SQL Proxy is a tool to establish secure connections to Cloud SQL Second Generation instances. On the other hand, HammerDB is an open-source database load testing and benchmarking tool. Combining these three technologies enables users to efficiently manage their Cloud SQL database instances while ensuring security and optimal performance.</p><p>This article will demonstrate how to automate the deployment of a setup containing PgBouncer, Cloud SQL Proxy, and HammerDB using Terraform, which is an Infrastructure as Code (IaC) tool for provisioning and managing cloud resources.</p><h3>Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9dCxGAoQHcwtyJWmt-cwFw.png" /><figcaption>An Integrated Architecture: Unveiling the Symbiotic Relationship Between Cloud SQL, PgBouncer, CloudSQL Proxy, and HammerDB for Robust Database Management in the Cloud</figcaption></figure><h4>PgBouncer</h4><p>PgBouncer is a lightweight connection pooler for PostgreSQL. It reduces the connection overhead by pooling connections to the PostgreSQL servers. Databases can only handle a limited number of connections and establishing a connection is resource-intensive. PgBouncer helps to increase the number of transactions per second and the number of clients that can be served with the same hardware by maintaining a pool of established connections that can be reused by new clients.</p><h4>Cloud SQL Proxy</h4><p>Cloud SQL Proxy is a tool provided by Google Cloud that allows a user to connect to a Cloud SQL instance without having to deal with IP whitelisting or SSL certificates. The proxy provides secure access to your Cloud SQL Second Generation instances without having to whitelist IP addresses or configure SSL. The Cloud SQL Proxy works by having a local client running in the local environment. This client is used to proxy a secure connection to the Cloud SQL instance.</p><h4>Cloud SQL</h4><p>Cloud SQL is a fully-managed database service that makes it easy to set up, maintain, manage, and administer your relational databases on Google Cloud Platform. It provides support for PostgreSQL, MySQL, and SQL Server. It manages all the administrative tasks like backups, patch management, and failover, which helps in focusing on the database schema design, optimization, and application development.</p><h4>HammerDB</h4><p>HammerDB is an open-source database load testing and benchmarking tool for Oracle, SQL Server, DB2, TimesTen, MySQL, MariaDB, PostgreSQL, Greenplum, Redis, Amazon Aurora, and Redshift, and more. It is used to test how the database performs under different loads and is widely used for capacity planning and performance tuning of database systems.</p><h3>Prerequisites</h3><p>Before proceeding, ensure that you have the following installed and set up:</p><ul><li>Terraform</li><li>Google Cloud SDK</li><li>A Google Cloud Platform (GCP) account</li><li>Basic knowledge of Terraform, Google Cloud, and PostgreSQL</li></ul><h3>Deployment Overview</h3><p>The deployment consists of creating:</p><ol><li>A Virtual Private Cloud (VPC) network</li><li>A Compute Engine instance running PgBouncer, Cloud SQL Proxy, and HammerDB</li><li>A PostgreSQL HA instance on Cloud SQL</li><li>Firewall rules allowing traffic to the Compute Engine instance</li></ol><h3>Setup and Configuration</h3><h3>Project Structure</h3><pre>pgbouncer/<br>│<br>├── main.tf<br>├── variables.tf<br>├── outputs.tf<br>├── templates/<br>│   ├── pgbouncer.ini.tmpl<br>│   ├── cloud-init.yaml.tmpl<br>│   └── userlist.txt.tmpl<br>│<br>├── scripts/<br>│   ├── start_all_services.sh.tmpl<br>│   ├── stop_all_services.sh.tmpl<br>│   ├── configure_hammerdb.sh.tmpl<br>│   ├── configure_hammerdb.tcl.tmpl<br>│   ├── run_workload.sh.tmpl<br>│   └── run_workload.tcl.tmpl<br>├── ...    </pre><h3>main.tf</h3><p>The main.tf file is the primary configuration file for Terraform. It contains the actual resource definitions and modules used in the project. This file will include the configurations for setting up the Cloud SQL instance, Compute Engine instance, Network, and Firewall rules. You can think of this file as the main entry point for the Terraform script.</p><pre>...<br><br>locals {<br>  users    = [for u in var.users : ({ name = u.name, password = u.password })]<br>  admins   = [for u in var.users : u.name if lookup(u, &quot;admin&quot;, false) == true]<br>  userlist = templatefile(&quot;${path.module}/templates/userlist.txt.tmpl&quot;, { users = local.users })<br>  cloud_config = templatefile(<br>    &quot;${path.module}/templates/pgbouncer.ini.tmpl&quot;,<br>    {<br>      db_host            = var.cloud_sql_proxy_host<br>      db_port            = var.cloud_sql_proxy_port<br>      listen_port        = var.listen_port<br>      auth_user          = var.auth_user<br>      auth_query         = var.auth_query<br>      default_pool_size  = var.default_pool_size<br>      max_db_connections = var.max_db_connections<br>      max_client_conn    = var.max_client_conn<br>      pool_mode          = var.pool_mode<br>      admin_users        = join(&quot;,&quot;, local.admins)<br>      custom_config      = var.custom_config<br>    }<br>  )<br><br>  configure_hammerdb = templatefile(&quot;${path.module}/scripts/configure_hammerdb.sh.tmpl&quot;, {})<br>  configure_hammerdb_tcl = templatefile(&quot;${path.module}/scripts/configure_hammerdb.tcl.tmpl&quot;, {<br>    pgbouncer_host = var.pgbouncer_host<br>    pgbouncer_port = var.listen_port<br>    db_user        = var.db_user<br>    db_password    = var.db_password<br>    hammerdb_user  = var.db_user<br>    hammerdb_pass  = var.db_password<br>  })<br>  run_workload     = templatefile(&quot;${path.module}/scripts/run_workload.sh.tmpl&quot;, {})<br>  run_workload_tcl = templatefile(&quot;${path.module}/scripts/run_workload.tcl.tmpl&quot;, {})<br><br>  start_all_services = templatefile(&quot;${path.module}/scripts/start_all_services.sh.tmpl&quot;, {<br>    cloud_sql_proxy_port    = var.cloud_sql_proxy_port<br>    listen_port             = var.listen_port<br>    cloud_sql_instance_name = module.db.instance_connection_name<br>    cloud_sql_replica_name  = module.db.replicas_instance_connection_names[0]<br>    cloud_sql_proxy_image   = var.cloud_sql_proxy_image<br>    image                   = &quot;edoburu/pgbouncer:${var.pgbouncer_image_tag}&quot;<br>  })<br><br>  stop_all_services = templatefile(&quot;${path.module}/scripts/stop_all_services.sh.tmpl&quot;, {})<br>  ...<br>}<br><br>data &quot;template_file&quot; &quot;cloud_config&quot; {<br>  template = file(&quot;${path.module}/templates/cloud-init.yaml.tmpl&quot;)<br>  vars = {<br>    image                        = &quot;edoburu/pgbouncer:${var.pgbouncer_image_tag}&quot;<br>    listen_port                  = var.listen_port<br>    config                       = base64encode(local.cloud_config)<br>    userlist                     = base64encode(local.userlist)<br>    project_id                   = var.project_id<br>    cloud_sql_proxy_image        = var.cloud_sql_proxy_image<br>    cloud_sql_instance_name      = module.db.instance_connection_name<br>    cloud_sql_replica_name       = module.db.replicas_instance_connection_names[0]<br>    cloud_sql_proxy_port         = var.cloud_sql_proxy_port<br>    configure_hammerdb           = base64encode(local.configure_hammerdb)<br>    configure_hammerdb_tcl       = base64encode(local.configure_hammerdb_tcl)<br>    run_workload                 = base64encode(local.run_workload)<br>    run_workload_tcl             = base64encode(local.run_workload_tcl)<br>    start_all_services           = base64encode(local.start_all_services)<br>    stop_all_services            = base64encode(local.stop_all_services)<br>    terminate_active_connections = base64encode(local.terminate_active_connections)<br>    clean_up                     = base64encode(local.clean_up)<br>  }<br>  depends_on = [<br>    module.db,<br>  ]<br>}<br><br>data &quot;template_cloudinit_config&quot; &quot;cloud_config&quot; {<br>  gzip          = false<br>  base64_encode = false<br>  part {<br>    filename     = &quot;cloud-init.yaml&quot;<br>    content_type = &quot;text/cloud-config&quot;<br>    content      = data.template_file.cloud_config.rendered<br>  }<br>}<br><br>...<br><br># Compute instance to run pgbouncer and cloud_sql_proxy<br>resource &quot;google_compute_instance&quot; &quot;pgbouncer_instance&quot; {<br>  name         = &quot;pgbouncer-instance-${random_id.suffix.hex}&quot;<br>  machine_type = &quot;n1-standard-1&quot;<br>  zone         = &quot;us-central1-a&quot;<br><br>  metadata = {<br>    user-data = data.template_cloudinit_config.cloud_config.rendered<br>  }<br><br>  ...<br><br>  tags = [&quot;pgbouncer&quot;]<br><br>  depends_on = [<br>    module.db<br>  ]<br><br>}<br><br>...<br><br># Postgres HA Cloud SQL instance<br>module &quot;db&quot; {<br>  source  = &quot;GoogleCloudPlatform/sql-db/google//modules/postgresql&quot;<br>  version = &quot;~&gt;5.0.0&quot;<br><br>  project_id           = var.project_id<br>  name                 = &quot;db-pgbouncer&quot;<br>  random_instance_name = true<br><br>  database_version = &quot;POSTGRES_14&quot;<br>  region           = var.region<br>  zone             = var.zone<br>  tier             = &quot;db-f1-micro&quot;<br><br>  ...<br><br>}<br></pre><h3>variables.tf</h3><p>The variables.tf file is used to define the input variables that the Terraform script requires. By using variables, you can customize the Terraform configurations without modifying the main configuration code. For example, you might define variables for the GCP project ID, region, network settings, and instance sizes.</p><h3>outputs.tf</h3><p>The outputs.tf file is used to define outputs from your Terraform script. These outputs are usually critical information about the resources that are created, such as the public IP address of the Compute Engine instance. Outputs help you to easily retrieve important data from your Terraform-managed infrastructure.</p><h3>templates/</h3><p>The templates directory contains template files that are used to generate configuration files for various components such as PgBouncer and Cloud SQL Proxy. These templates can include placeholders for values that will be filled in by Terraform when it runs.</p><ul><li>pgbouncer.ini.tmpl is a template for the PgBouncer configuration file. This file contains settings for how PgBouncer should behave and connect to your database.</li></ul><pre>[databases]<br>* = host=${db_host} port=${db_port}<br><br>[pgbouncer]<br>listen_addr = 0.0.0.0<br>listen_port = ${listen_port}<br>unix_socket_dir =<br>user = postgres<br>auth_file = /etc/pgbouncer/userlist.txt<br>auth_type = scram-sha-256<br><br>%{ if custom_config == &quot;&quot; ~}<br>%{ if auth_query != null &amp;&amp; auth_user != null ~}<br>auth_query = ${auth_query}<br>auth_user = ${auth_user}<br>%{ endif ~}<br>max_db_connections = ${max_db_connections}<br>max_client_conn = ${max_client_conn}<br>pool_mode = ${pool_mode}<br>default_pool_size = ${default_pool_size}<br>admin_users = ${admin_users}<br>stats_users = ${admin_users}<br>ignore_startup_parameters = extra_float_digits, options<br>application_name_add_host = 1<br><br>%{~ else ~}<br># Custom Config -------------------------------------------------------------- #<br><br>${custom_config}<br>%{~ endif ~}</pre><ul><li>userlist.txt.tmpl is a template for userlist.txt file. This file contains user login info for the PgBouncer.</li></ul><pre>%{ for user in users ~}<br>&quot;${user.name}&quot; &quot;${user.password}&quot;<br>%{ endfor ~}</pre><ul><li>cloud-init.yaml.tmpl is a template for cloud-init configuration. Cloud-init is a tool for automating the initial setup of a cloud instance. This file can contain scripts and configurations to install and configure software, such as PgBouncer and Cloud SQL Proxy.</li></ul><pre>#cloud-config<br><br>write_files:<br>  - path: /run/user/start_all_services.sh<br>    permissions: &quot;0755&quot;<br>    encoding: b64<br>    content: ${start_all_services}<br>  - path: /run/user/stop_all_services.sh<br>    permissions: &quot;0755&quot;<br>    encoding: b64<br>    content: ${stop_all_services}<br>  ...<br>  - path: /run/user/userlist.txt<br>    permissions: &quot;0644&quot;<br>    encoding: b64<br>    content: ${userlist}<br>  - path: /etc/systemd/system/demo.service<br>    permissions: &quot;0644&quot;<br>    owner: root<br>    content: |<br>      [Unit]<br>      Description=Demo<br>      After=docker.service<br>      Requires=docker.service<br>      [Service]<br>      Type=simple<br>      ExecStart=/run/user/start_all_services.sh<br>      ExecStop=/run/user/stop_all_services.sh<br>      RemainAfterExit=yes<br>      [Install]<br>      WantedBy=multi-user.target<br>runcmd:<br>  - systemctl daemon-reload<br>  - systemctl enable demo.service<br>  - systemctl start demo.service<br><br></pre><h3>scripts/</h3><p>The scripts directory contains shell script templates or actual shell scripts that are used in the automation process. These scripts are usually responsible for installing and starting services on the instances created.</p><ul><li>start_all_services.sh.tmpl is an example script that could be used to start the PgBouncer and Cloud SQL Proxy services once the Compute Engine instance is running. This script would likely include commands to start both services and ensure they are running as expected.</li><li>stop_all_services.sh.tmpl is an example script that could be used to stop the PgBouncer and Cloud SQL Proxy services once the Compute Engine instance is running. This script would likely include commands to stop both services.</li></ul><h4>Running Terraform</h4><p>Once you have configured your Terraform scripts, run the following commands to initialize Terraform, plan your deployment, and apply the changes:</p><pre>terraform init<br>terraform plan<br>terraform apply</pre><h3>Connecting to PgBouncer Instance</h3><p>After applying the Terraform script, you can SSH into the Compute Engine instance. Once logged in, you can use systemctl to start or stop the services.</p><pre>systemctl start demo # Starts all the Docker containers<br>systemctl stop demo  # Stops and removes all the containers</pre><h3>Conclusion</h3><p>This article demonstrated how to automate the deployment of a Cloud SQL environment, complete with PgBouncer, Cloud SQL Proxy, and HammerDB using Terraform. This setup ensures optimised performance, security, and efficient management of Cloud SQL database instances. You can find the complete code <a href="https://github.com/iamvasanth07/pgbouncer">here</a></p><p>Now you have a powerful toolset at your disposal for managing connections, securing communication.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a22a5771aeaa" width="1" height="1" alt=""><hr><p><a href="https://medium.com/google-cloud/architecting-a-scalable-and-secure-cloud-based-database-solution-a-deep-dive-into-integrating-a22a5771aeaa">Architecting a Scalable and Secure Cloud-Based Database Solution: A Deep Dive into Integrating …</a> was originally published in <a href="https://medium.com/google-cloud">Google Cloud - Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>