<?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 Pablo Caballero on Medium]]></title>
        <description><![CDATA[Stories by Pablo Caballero on Medium]]></description>
        <link>https://medium.com/@pablo.caballero?source=rss-a48e2d312a34------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*rxEkjvZvuWHMSEL6DxqFwg.jpeg</url>
            <title>Stories by Pablo Caballero on Medium</title>
            <link>https://medium.com/@pablo.caballero?source=rss-a48e2d312a34------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 08:41:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pablo.caballero/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[Why Your Photos Have Today’s Date]]></title>
            <link>https://medium.com/@pablo.caballero/why-your-photos-have-todays-date-48e00d365ab4?source=rss-a48e2d312a34------2</link>
            <guid isPermaLink="false">https://medium.com/p/48e00d365ab4</guid>
            <category><![CDATA[powershell]]></category>
            <category><![CDATA[exif]]></category>
            <category><![CDATA[timestamp]]></category>
            <category><![CDATA[organization]]></category>
            <category><![CDATA[photos]]></category>
            <dc:creator><![CDATA[Pablo Caballero]]></dc:creator>
            <pubDate>Wed, 20 May 2026 05:01:01 GMT</pubDate>
            <atom:updated>2026-05-20T05:01:01.830Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-nd/4.0/</cc:license>
            <content:encoded><![CDATA[<h3><strong>Why Your Photos Have Today’s Date (and How to Fix It)</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MGXqGTlSu6GmCDOL" /><figcaption>Photo by <a href="https://unsplash.com/@hxzrshk?utm_source=medium&amp;utm_medium=referral">Harsh Kumar</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>You moved your photos to a new cloud account and now they’re all dated today. Your memories are out of order and searching for the right ones is a mess. Here’s the 30-second fix — no programming knowledge needed.</p><h3><strong>Why Does This Happen?</strong></h3><p>When you download photos from the cloud and re-upload them somewhere else, the file’s timestamps get reset to the current date. The original “date taken” information is still there — it’s just stored in a different place than the timestamp your operating system uses to sort files.</p><p>Every file actually has two separate timestamps: a <a href="https://learn.microsoft.com/en-us/dotnet/api/system.io.filesysteminfo.creationtime?view=netframework-4.8.1&amp;viewFallbackFrom=net-11.0"><strong><em>CreationTime</em></strong></a><em> </em>and a <a href="https://learn.microsoft.com/en-us/dotnet/api/system.io.filesysteminfo.lastwritetime?view=netframework-4.8.1&amp;viewFallbackFrom=net-11.0"><strong><em>LastWriteTime</em></strong></a>. Cloud services often reset both when you download. The fix is to overwrite those timestamps with the real date, which is either hidden inside the filename or stored in the file’s metadata.</p><h3><strong>Before You Start</strong></h3><p>You’ll run these scripts in <strong>PowerShell</strong>, a tool built into Windows. It can also be <a href="https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell">installed on macOS and Linux</a> in a few minutes — no programming experience required.</p><h4><strong>1. Open PowerShell</strong></h4><ul><li><strong>Windows:</strong> Press Win + R, type powershell, and hit Enter.</li><li><strong>macOS/Linux:</strong> Open a terminal and type pwsh.</li></ul><h4><strong>2. Allow scripts to run </strong>(Windows only, one-time setup)</h4><p>Paste this line and press Enter:</p><pre>Set-ExecutionPolicy RemoteSigned -Scope CurrentUser</pre><p>Type Y when prompted.</p><h4>3. Download the scripts</h4><p>Get both scripts from GitHub:</p><ul><li>PatchTimeName.ps1: <a href="https://gist.github.com/p-caballero/1778c0aebb39dac6fe06a6289010d993">https://gist.github.com/p-caballero/1778c0aebb39dac6fe06a6289010d993</a></li><li>PatchTimeExif.ps1: <a href="https://gist.github.com/p-caballero/488b356395f6dca48aaf188f04c1d8b3">https://gist.github.com/p-caballero/488b356395f6dca48aaf188f04c1d8b3</a></li></ul><h3>Which Script Do I Need?</h3><p>Check your filenames:</p><ul><li>They look like 20211127_155433000_iOS.MOV → use PatchTimeName.ps1 (iPhone / Android files)</li><li>They look like IMG_4823.JPG or DSC_0042.NEF → use PatchTimeExif.ps1 (camera/EXIF files)</li></ul><p>Not sure? If your files came from an iPhone or Android device and the filename starts with a date, use PatchTimeName.ps1. For everything else, try PatchTimeExif.ps1.</p><h3>Manual Way</h3><p>You always can change the dates manually, specially with videos that don’t contain a quick and simple way to extract the metadata. Navigate to your file’s folder and change the dates:</p><pre>Get-Item &quot;MVI_0452.AVI&quot; | ForEach-Object { $_.CreationTime = $_.LastWriteTime = Get-Date &quot;2011-05-08 14:46:00&quot; }</pre><h3>PatchTimeName — iPhone and Android Files</h3><p>iPhone and Android devices name their files with the date and time baked right into the filename — for example, 20211127_155433000_iOS.MOV means <em>November 27, 2021 at 15:54</em>. This applies to JPG, PNG, MP4, and MOV files.</p><p>PatchTimeName.ps1 reads the date directly from the filename and uses it to overwrite the file&#39;s timestamps.</p><h4>How to run it:</h4><p>Navigate to the folder where you saved the script, then point it at your photos folder:</p><pre>.\PatchTimeName.ps1 .\2021\01\</pre><p>You’ll see output confirming each file as it’s updated:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*qNNvFUlOk6qaPaWJ7CaRYQ.png" /><figcaption><em>Screenshot of PowerShell showing files being updated</em> after using PatchTimeName.ps1.</figcaption></figure><h3>PatchTimeExif — Cameras and Other Devices</h3><p>Digital cameras, phones, and tablets silently embed extra information inside every photo file when you take a picture. This hidden data — called EXIF metadata — includes things like camera model, GPS location, and crucially, the exact date and time the photo was taken. A photo named IMG_4823.JPG from a Canon or Samsung device still carries its original date in this metadata even if the filename gives nothing away.</p><p>PatchTimeExif.ps1 reads that embedded date and applies it to the file&#39;s timestamps.</p><p>How to run it:</p><pre>.\PatchTimeExif.ps1 .\2021\01\</pre><p>You’ll see output confirming each file as it’s updated:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/981/1*YgQJ28npHVuKrzuYrGVwJg.png" /><figcaption><em>Screenshot of PowerShell showing files being updated</em> after using PatchTimeExif.ps1.</figcaption></figure><h3>Recap</h3><p>There are two scenarios covered here:</p><ul><li>Filename starts with a date (e.g. 20211127_155433000_iOS.MOV) → run PatchTimeName.ps1</li><li>Standard camera or phone filename (e.g. IMG_4823.JPG) → run PatchTimeExif.ps1</li></ul><p>Run the right script once on your folder and your photos will snap back into the correct order. Your memories deserve to be in the right place.</p><p><em>Always keep a backup of your files before running any automated script. These scripts are provided as-is, without warranty of any kind.</em></p><h3>How to cite this story</h3><p>Caballero, P. (2026, May). <strong>Why Your Photos Have Today’s Date (and How to Fix It)</strong>. Medium. Retrieved from <a href="https://medium.com/p/48e00d365ab4">https://medium.com/p/48e00d365ab4</a></p><h3>Disclaimer of Warranties and Liability</h3><p><em>This material, originally authored by </em><a href="https://www.linkedin.com/in/pcaballero/"><em>Pablo Caballero</em></a><em> and published on Medium, is provided for informational purposes only. Whilst all information has been provided in good faith, the author makes no representation, warranty, or guarantee of any kind, whether express or implied, concerning the accuracy, adequacy, validity, reliability, availability, or completeness of the information contained herein. The reader assumes all risk associated with the use of this material and agrees that neither the author nor any other party shall be liable for any direct, indirect, incidental, consequential, or special damages arising from reliance upon this information.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=48e00d365ab4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sharing Private GitHub Repositories for Free]]></title>
            <link>https://medium.com/@pablo.caballero/sharing-private-github-repositories-for-free-15af911b09ec?source=rss-a48e2d312a34------2</link>
            <guid isPermaLink="false">https://medium.com/p/15af911b09ec</guid>
            <category><![CDATA[github]]></category>
            <category><![CDATA[personal-access-tokens]]></category>
            <category><![CDATA[private-repository]]></category>
            <category><![CDATA[codesharing]]></category>
            <dc:creator><![CDATA[Pablo Caballero]]></dc:creator>
            <pubDate>Tue, 05 May 2026 21:13:04 GMT</pubDate>
            <atom:updated>2026-05-05T21:13:04.373Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2M0zTSzr1LUoTvwr_JoPLg.png" /></figure><p>Individuals who have attempted to share a <strong>private GitHub repository</strong> often observe that the process is less straightforward than expected. There is no single method that is optimal for every context, and each approach contains practical and security trade-offs.</p><p>Why should one share a private repository rather than publishing it openly? The principal reason is controlled access. In many cases, the repository should be visible only to a professor, a recruiter, or another authorised reviewer, and only for a limited period.</p><p>For students, the best scenario is commonly an institutional GitHub organisation managed by the university. In less favourable situations, students may resort to transmitting compressed archives by e-mail or to using generic file-transfer platforms.</p><p>For professionals, the requirements can be more strict: temporary review windows, confidentiality constraints, and the wish to avoid conflict with a current employer by not exposing portfolio code publicly.</p><h3>Paid Alternatives</h3><p>A number of third-party platforms, such as GitFront and GitShare, offer mechanisms for temporary access to private repositories. These services can be useful in practice, but they also introduce additional considerations:</p><ul><li>recurring subscription costs,</li><li>dependency on an external provider,</li><li>and a separate trust model beyond GitHub itself.</li></ul><p>Accordingly, paid alternatives may be suitable in certain workflows, but they are not universally necessary.</p><h3>Official GitHub Method</h3><p>GitHub already provides a <strong>native free mechanism</strong> for private sharing by adding collaborators on a per-repository basis.</p><p>Path: Repository Settings → Collaborators and teams</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gP0Fcos8u-cw0zOD59tkoA.png" /><figcaption>Screenshot of the Collaborators and Teams settings panel for a repository.</figcaption></figure><p>When the reviewer can use a GitHub account, this remains the most direct identity-based approach.</p><pre>git clone https://github.com/my-user/my-private-repository.git</pre><h3>A Practical Workaround: Fine-Grained Personal Access Tokens</h3><p>When the reviewer does not have a GitHub account, or when account onboarding is not practical for a short review, a fine-grained <strong>Personal Access Token</strong> (PAT) may be employed as a temporary workaround.</p><p>It is important to frame this method carefully. A fine-grained PAT is not inherently insecure; however, it is a bearer credential. Any person who possesses the token may use it until it expires or is revoked.</p><p>Token creation path: User profile → Settings → Developer settings → Personal access tokens → Fine-grained tokens → Generate new token</p><p>Direct link: <a href="https://github.com/settings/personal-access-tokens/new">https://github.com/settings/personal-access-tokens/new</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/1*m3r29OzoG4CXpCwqf6uCNQ.png" /><figcaption>Screenshot of the Personal Access Token creation form.</figcaption></figure><h4>Recommended configuration</h4><ul><li><strong>Token name</strong>: concise and descriptive.</li><li><strong>Expiration time</strong>: shortest feasible duration.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/271/1*osdl4xaxhz9iI_pepLP_Fg.png" /><figcaption>Detail of the expiration date field.</figcaption></figure><ul><li><strong>Repository access</strong>: only the target repository.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/666/1*wVM2Hfup1jYCGdtxFCXkVQ.png" /><figcaption>Detail of the repository access selection panel.</figcaption></figure><ul><li><strong>Permissions</strong>: Contents set to Read-only.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*G9HmZ5k8KbGe-R36useCFg.png" /><figcaption>Detail of the permissions configuration panel.</figcaption></figure><p>Clone pattern:</p><pre>git clone https://&lt;YOUR_TOKEN&gt;@github.com/my-user/my-private-repository.git</pre><h3>Balanced Security Considerations</h3><p>A fine-grained, read-only, short-lived PAT can be sufficiently secure for low-risk and temporary sharing, provided that it is configured and handled with discipline.</p><p>At the same time, its risk profile is different from collaborator-based access and may also differ from third-party share links.</p><p>Fine-grained PAT advantages:</p><ul><li>No direct monetary cost.</li><li>No requirement for a third-party sharing platform.</li><li>Granular scope control (single repository, read-only permissions, short expiry).</li></ul><p>Fine-grained PAT limitations:</p><ul><li>It remains a bearer secret associated with your account context,</li><li>Operational leakage can occur (history, logs, screenshots, forwarding),</li><li>Attribution to a specific recipient identity is weaker than named collaborator access.</li></ul><p>Third-party service potential advantages:</p><ul><li>Simplified reviewer experience.</li><li>Potentially easier share-link lifecycle controls.</li></ul><p>Third-party service potential limitations:</p><ul><li>Subscription expenditure.</li><li>External platform dependency.</li><li>Additional trust assumptions and possible discoverability concerns depending on provider design.</li></ul><p>Therefore, the decision is not binary; it is a context-dependent trade-off.</p><p>Fine-Grained PAT Safety Checklist:</p><ul><li>Use fine-grained PATs only (avoid broad classic tokens).</li><li>Restrict access to one repository.</li><li>Grant Contents permission as Read-only.</li><li>Set the shortest practical expiry.</li><li>Share only via secure channels.</li><li>Revoke immediately after the review is finished.</li><li>Prefer sanitised sample repositories when external review is expected.</li></ul><h3>Conclusions</h3><p>For recipients who can use GitHub, collaborator access is generally the clearest and most auditable option. For recipients without GitHub accounts, a tightly scoped fine-grained PAT can be a valid free temporary approach.</p><p>The key determinant is not the token itself, but the rigour of scoping, transmission, monitoring, and revocation.</p><h3>How to cite this story</h3><p>Caballero, P. (2026, May). Sharing Private GitHub Repositories for Free. Medium. Retrieved from <a href="https://medium.com/p/15af911b09ec">https://medium.com/p/15af911b09ec</a></p><h3><strong>Disclaimer of Warranties and Liability</strong></h3><p><em>This material, originally authored by </em><a href="https://www.linkedin.com/in/pcaballero/"><em>Pablo Caballero</em></a><em> and published on Medium, is provided for informational purposes only. Whilst all information has been provided in good faith, the author makes no representation, warranty, or guarantee of any kind, whether express or implied, concerning the accuracy, adequacy, validity, reliability, availability, or completeness of the information contained herein. The reader assumes all risk associated with the use of this material and agrees that neither the author nor any other party shall be liable for any direct, indirect, incidental, consequential, or special damages arising from reliance upon this information.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=15af911b09ec" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Amazon Kindle and Programmed Obsolescence]]></title>
            <link>https://medium.com/@pablo.caballero/amazon-kindle-and-programmed-obsolescence-6d6b175551a4?source=rss-a48e2d312a34------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d6b175551a4</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[obsolescence]]></category>
            <category><![CDATA[amazon]]></category>
            <category><![CDATA[customer-service]]></category>
            <category><![CDATA[kindle]]></category>
            <dc:creator><![CDATA[Pablo Caballero]]></dc:creator>
            <pubDate>Fri, 25 Jul 2025 13:24:48 GMT</pubDate>
            <atom:updated>2025-07-28T06:42:34.187Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7c9D6py2obfs2P58" /><figcaption>Photo by <a href="https://unsplash.com/@felipepelaquim?utm_source=medium&amp;utm_medium=referral">@felipepelaquim</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>A few days ago, I found myself in a surprisingly long conversation — over an hour — with Amazon support. The reason? My beloved Kindle, still in perfect condition, had mysteriously disconnected from Amazon’s cloud. All my personal documents and legally purchased e-books were suddenly inaccessible.</p><p>Let me give you some context.</p><p>Years ago, I bought a Kindle for my mother and me. It was a revolution in how we read. As an adult who takes care of his devices, I’ve kept it in pristine condition. But like many books, it eventually gathered dust on a shelf. Recently, I decided to bring it back to life.</p><p>I charged my 5th-generation Kindle, excited to dive back into my digital library. But to my surprise, the device was no longer connected to Amazon’s systems.</p><p>For a non-technical person, this would be a nightmare. For me, a software engineer, it was a challenge — and eventually, a headache. My mother took one look and said, “It’s broken.” But I knew better.</p><h3>👣 1st step: log in to Amazon</h3><p>First problem: what was my password? Thankfully, I use a password manager. (Though I’m seriously considering going old-school with a physical notebook.)</p><p>Once logged in, Amazon sent me a verification code. That’s when I paused — had I enabled two-step authentication? (For the non-techies: it’s a way to protect your account with more than just a password.) I hadn’t. Odd, but I moved on.</p><p>You can check your settings in:</p><p><em>Your account &gt; Login &amp; Security &gt; 2-step verification</em></p><p>After scouring Reddit threads, Amazon forums, and obscure Amazon blog posts, I did something I’d never done before: I called Amazon support.</p><p>They asked for my Kindle’s serial number.</p><p><em>Menu → Settings → Menu → Device Info</em></p><p>Then came the chilling response: “Oh, that’s a very old model. Why don’t you buy a new one? We can offer you a discount.”</p><p>But I didn’t want a new one. My Kindle wasn’t broken. It worked fine — until something on Amazon’s side broke it. I paid for it. I cared for it. I wanted it back.</p><p>After some back-and-forth, the support agent — patient and kind — escalated the issue. Eventually, they guided me through a manual update.</p><h3>🔔 2nd step: Updating the Kindle software</h3><p>She sent me an email with the URL, you can find it under:</p><p><em>Digital Services and Device Support &gt; Kindle E-Reader Help &gt; Learn More on Kindle E-Reader &gt; Kindle E-Reader Software Updates</em></p><figure><img alt="Screenshot of Kindle E-Reader Software Updates" src="https://cdn-images-1.medium.com/max/776/1*xugHlNurBxxBHXYxhAYDNA.png" /><figcaption>Screenshot of Kindle E-Reader Software Updates</figcaption></figure><p>I had to fire up my computer, download a file named update_kindle_5.6.1.1.bin, connect my Kindle via USB, and carefully drop the file into the root directory of the device — like performing digital surgery on a forgotten relic that Amazon had quietly left behind.</p><p>But if you happen to own a 4th-generation Kindle… well, things get a little crazier.</p><p>The update process took about 15 minutes. During that time, we made several attempts to log in — none of them successful. What did happen, though, was a series of Kindle restarts that felt more like a ritual than a solution.</p><h3>🔐 3rd step: Change your password</h3><p>The support agent gently said, “There’s a warning on your account. Could you please change your password?”<br>I sighed, clearly annoyed, and muttered my frustration — but I did it anyway. Sometimes, compliance is the fastest way out of the maze.</p><p>And then, it stopped sending me text messages altogether. I was forced to authenticate using only the Amazon app on my phone. But the result was the same — either the verification step froze, or the code was rejected as invalid…</p><p>After one hour and three minutes, the customer service agent finally gave up. No more discount offers — just a quiet, defeated “I’m sorry, but it’s not working. Have a nice day.”</p><p>I offered a tired, bittersweet “Thank you for your time,” knowing we had both reached the end of a long, frustrating road.</p><h3>🍺 4th step: Drink a beer</h3><p>I needed a moment to process everything that had just happened. Then it hit me — two-factor authentication. I vaguely recalled a Reddit post describing Amazon’s bizarre workaround: disable it, and if it was already disabled, enable it just so you could disable it again. It felt less like a security feature and more like trying to unlock a door by knocking in a secret rhythm only Reddit seemed to know.</p><figure><img alt="Two factor authentication flow" src="https://cdn-images-1.medium.com/max/881/1*8DYPOhFXZ7hn28X_BPJBGg.png" /><figcaption>Two factor authentication flow</figcaption></figure><p>No luck — disabling two-factor authentication didn’t solve the problem either. Another dead end in a maze of digital frustration.</p><p>So I thought — what if I try enabling two-factor authentication using an app like Microsoft Authenticator, Google Authenticator, or something similar?</p><figure><img alt="Screenshot of Two-Step Verification of Amazon" src="https://cdn-images-1.medium.com/max/922/1*aMmgE5D5bkOJH3XEP7291A.png" /><figcaption>Screenshot of Two-Step Verification of Amazon</figcaption></figure><p>Interestingly, during the final step of the process, a message popped up: older devices like the Kindle may not be fully compatible with modern 2FA methods. But apparently, Amazon had quietly built a workaround for this exact scenario.</p><p>Finally — light at the end of the tunnel.</p><h3>💡 5th step: Log in with two-factor authentication</h3><p>The login formula was simple: my email as the username, my usual password, and then — right at the end — the six-digit code from the authentication app.</p><p>And yes, this time… it worked!</p><h3>🧐 Conclusions</h3><p>Poor engineering decisions can lock users out of services they rightfully own. And when a workaround exists — even a clumsy or unofficial one — customer support should be fully informed. Otherwise, users are left in the dark, and support teams are left apologizing for problems they didn’t create.</p><p>Clear communication between engineering and customer service isn’t just a nice-to-have — it’s essential for a smooth and respectful user experience.</p><p>And finally, let’s be honest: Devices don’t become obsolete on their own. Obsolescence is a business decision.</p><p>In fact, the EU Directive 2024/825 now explicitly addresses this issue, prohibiting practices that promote early obsolescence or mislead consumers about a product’s durability or software compatibility. It’s a step toward holding companies accountable — and a reminder that consumers deserve transparency, not silent shutdowns.</p><h3>How to cite this story</h3><p>Caballero, P. (2025, July). Amazon Kindle and Programmed Obsolescence. Medium. Retrieved from <a href="https://medium.com/p/6d6b175551a4">https://medium.com/p/6d6b175551a4</a></p><p><em>This story, provided by </em><a href="https://www.linkedin.com/in/pcaballero/"><em>Pablo Caballero</em></a><em> on Medium, is intended for general information purposes only. All information has been provided in good faith; however, I make no representation or warranty of any kind, express or implied, regarding the accuracy, adequacy, validity, reliability, availability, or completeness of any information in this story.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d6b175551a4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Boost Your Productivity: AI Assisted Professional Diary]]></title>
            <link>https://medium.com/bestsecret-tech/boost-your-productivity-ai-assisted-professional-diary-b1ce830a9e8f?source=rss-a48e2d312a34------2</link>
            <guid isPermaLink="false">https://medium.com/p/b1ce830a9e8f</guid>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[visual-studio-code]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[co-pilot]]></category>
            <category><![CDATA[ai-assistant]]></category>
            <dc:creator><![CDATA[Pablo Caballero]]></dc:creator>
            <pubDate>Tue, 04 Feb 2025 12:20:00 GMT</pubDate>
            <atom:updated>2025-02-04T12:20:00.793Z</atom:updated>
            <content:encoded><![CDATA[<h3>Boost Your Productivity: AI Assisted Professional Diary Using Visual Studio Code + Copilot</h3><figure><img alt="Professional Diary" src="https://cdn-images-1.medium.com/max/1024/0*AvdQumCR3bEgrgXp" /><figcaption>Photo by <a href="https://unsplash.com/@priscilladupreez?utm_source=medium&amp;utm_medium=referral">Priscilla Du Preez 🇨🇦</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>In today’s fast-paced professional world, staying organized and productive is more important than ever. As someone who has tried various methods to keep track of tasks and notes, I found that integrating AI tools like Microsoft Copilot with Visual Studio Code has been a game-changer. This story will guide you through setting up an AI-assisted professional diary, helping you streamline your workflow and enhance productivity.</p><p>When I first started as an intern many years ago, I always carried a small notebook with me. Over time, I experimented with different methods, from stacks of papers for meeting notes to a phase where everything was covered in post-it notes. Eventually, I began losing my notes, or my notebook turned into what we humorously called in my hometown, “The Big Book of Petete” [<a href="https://medium.com/p/b1ce830a9e8f#e979">1</a>].</p><figure><img alt="El libro GORDO de Petete" src="https://cdn-images-1.medium.com/max/1024/1*jaEA2Tfrz40cuS6qoBjeQg.jpeg" /><figcaption>Ilustration from “The Big Book of Petete”.</figcaption></figure><p>And then the <strong>revolution of artificial intelligence</strong> arrived, and I began to search if any engineer had thought of creating a notebook that a <em>Large Language Model</em> (LLM) AI could help me to recall. However, the solutions were expensive or paying an extra subscription. So, I decided to try something with the tools that I had for coding.</p><p>Let’s get to work!</p><h3>The Tools</h3><figure><img alt="Visual Studio Code in a laptop" src="https://cdn-images-1.medium.com/max/1024/0*jmPxwbHFlvVO3-fN" /><figcaption>Photo by <a href="https://unsplash.com/@safarslife?utm_source=medium&amp;utm_medium=referral">Safar Safarov</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Visual Studio Code</h4><p>Visual Studio Code [<a href="https://medium.com/p/b1ce830a9e8f#eee0">2</a>] (VS Code), a <strong>free </strong>and open-source code editor developed by Microsoft, is designed to be both lightweight and powerful. It offers a range of features that make it suitable for various programming tasks. Among its key features are:</p><ul><li>Multi-platform: Available on Linux, macOS, Windows, and Raspberry Pi.</li><li>Code Editing: Syntax highlighting, intelligent code completion, and code refactoring.</li><li>Extensions: A vast library to customize and enhance functionality.</li><li>Integrated Terminal: Run commands directly within the editor.</li><li>Debugging: Robust capabilities including breakpoints and an interactive console.</li><li>Source Control: Integration with Git and other version control systems.</li></ul><p>VS Code combines the speed and simplicity of a text editor with the powerful features of an integrated development environment (IDE).</p><h4>Microsoft Copilot Pro</h4><p>Microsoft’s Copilot is an advanced AI assistant designed to enhance productivity and streamline tasks across various platforms. It integrates seamlessly with tools like Windows, Office apps, and Bing, providing users with a conversational interface to search for information, generate text, create images, and even write code. By leveraging the power of generative AI, Copilot helps users automate everyday tasks, making workflows more efficient and intuitive.</p><p>It is based on technology developed by OpenAI, the creators of ChatGPT, Copilot uses LLMs to generate human-like text and assist with various tasks.</p><p>If you choose not to subscribe to Copilot Pro, unfortunately, you won’t be able to link Copilot with Visual Studio Code at this time. This limitation marks the end of the story for now. If, on the other hand, you have an account, I will tell you how to set up our diary. The price of the subscription [<a href="https://medium.com/p/b1ce830a9e8f#7af9">4</a>] is around €22 per month, and it will change your life.</p><h3>Setting Up Your Environment</h3><p>1 Install Visual Studio Code. Follow the detailed installation instructions available on Visual Studio Code website: <a href="https://code.visualstudio.com/">https://code.visualstudio.com/</a></p><p>2 Add Copilot extension. Open Visual Studio Code and click on the extensions button from the left tool bar and install “<strong>GitHub Copilot</strong>” and “<strong>GitHub Copilot Chat</strong>”.</p><figure><img alt="GitHub Copilot Chat" src="https://cdn-images-1.medium.com/max/1024/1*c1xx8XZRfYooqpunWVPsJA.png" /><figcaption>Required Visual Studio Code extensions.</figcaption></figure><p>3 Sign in with GitHub. As I mentioned previously, you need your account for Copilot Pro, and it is linked to your GitHub account.</p><figure><img alt="GitHub Copilot Chat — Login section" src="https://cdn-images-1.medium.com/max/696/1*jwAFSBCjJV3ha4AQWwlVCg.png" /><figcaption>Details of the login in GitHub</figcaption></figure><p>The instructions on how to register or create an account will be skipped, as they fall outside the scope of this story.</p><p>As a result, it should look like the image after the login.</p><figure><img alt="GitHub Copilot Chat — Logged" src="https://cdn-images-1.medium.com/max/980/1*XXedjNp-V8FcXgVLNPg0Zw.png" /><figcaption>Details of the login in GitHub after the “Sign in”.</figcaption></figure><p>4 Add Markdown extension (optional). Markdown is a simple, versatile markup language for formatting text. It’s ideal for creating headings, lists, links, and more without the complexity of HTML. Using Markdown can help structure your diary semantically. While VS Code supports basic Markdown by default, the free “Markdown All in One” extension enhances formatting capabilities. Find and install it from the extensions marketplace [<a href="https://medium.com/p/b1ce830a9e8f#8d90">3</a>].</p><figure><img alt="Markdown All in One" src="https://cdn-images-1.medium.com/max/1024/1*E7BvW3xtHKmwJeB7NzpHjw.png" /><figcaption>Extension “Markdown All in One”.</figcaption></figure><p>5Saving in the cloud (optional). Consider using a <strong>PRIVATE</strong> and <strong>NON-Corporate </strong>Git repository (it should be only for our eyes) and uploading changes daily. Detailed instructions on using Git are beyond the scope of this story.</p><h3>Creating Your Professional Diary</h3><p>1 Create a folder “diary” wherever you want to save your notes. And then create inside two more folders, “notes” and “knowledge-base”.</p><figure><img alt="Proposed folder structure" src="https://cdn-images-1.medium.com/max/587/1*jO-DfeFILaXFChGUAtOHsw.png" /><figcaption>Proposed folder structure.</figcaption></figure><p>In “notes” folder you can write all our notes per day. You could have one file per day or one file per month, it’s up to you.</p><p>In “knowledge-base” all the text files with all the extra information that you want to add, for example the contact details of your colleges.</p><p>2 Create the diary files. In the example, the diary is organized by months. At the top of each document, write the month with a <em>header-1</em> (#) to provide context for Copilot. Each day, add a new entry with a <em>header-2</em> (##). For tasks, use lists to make the notes clear and structured.</p><figure><img alt="Example of the diary notes for January." src="https://cdn-images-1.medium.com/max/1024/1*qZHo_KYVJyt7dGjBEsLpkg.png" /><figcaption>Example of the diary notes for January.</figcaption></figure><p>The following piece of code is the content of the previous example.</p><pre># January 2025<br><br>## January 09, 2025<br><br>- Daily<br>    - Alex to resolve the critical bug in the authentication module by EOD. QA Lead to prepare test cases for the new feature.<br>- Business refinement<br>    - We don&#39;t know the API key of the special order service. Juliette will ask for it.<br>    - A new consumer for the Kafka topic of images should be created. It is not clear the meaning of a few fields, so we should ask the owners.<br><br>## January 10, 2025<br><br>- Training<br>  - I have pending the security awareness courses.</pre><h3>Asking to Copilot</h3><p>Open the chat to talk with Copilot by clicking on <em>View &gt; Chat</em>. By default, the context of the currently opened file is selected. To extend the context to the entire diary, click on the “@” symbol and select “@workspace”. Then, write human-readable questions.</p><figure><img alt="Detail of the input of “Ask Copilot” chat." src="https://cdn-images-1.medium.com/max/758/1*yttX4MUF2CvNO4h_2uxzig.png" /><figcaption>Detail of the input of “Ask Copilot” chat.</figcaption></figure><p>After this point, you write a spell and the magic happens…</p><figure><img alt="Example of a response from Copilot to a question." src="https://cdn-images-1.medium.com/max/740/1*jiMY4w_QkJ-ft8DpOSg_ug.png" /><figcaption>Example of a response from Copilot to a question.</figcaption></figure><p>You can even ask in a different language, and it translates it. In the following example, I asked the same thing but in Spanish.</p><figure><img alt="Example of a response from Copilot to a question in Spanish with the rest of the diary in English." src="https://cdn-images-1.medium.com/max/712/1*azuT-jl1GXEP1YSMEL_lAg.png" /><figcaption>Example of a response from Copilot to a question in Spanish with the rest of the diary in English.</figcaption></figure><h3>Adding Knowledge Base</h3><p>While adding extra information is beneficial, it can be time-consuming, or you might need a method to export that data.</p><p>For contacts, you can create a file named contacts.md with a table listing the people you want to keep track of. In the following example, there are three fictional colleagues.</p><pre>| Name         | Job Title        | Team         | Email                 | Company    |<br>| ------------ | ---------------- | ------------ | --------------------- | ---------- |<br>| Juliette Doe | Senior Developer | Backend Team | john.doe@example.com  | TechCorp   |<br>| Alex Roe     | Project Manager  | PMO          | jane.roe@example.com  | Innovatech |<br>| Sam Smith    | UX Designer      | Design Team  | sam.smith@example.com | Creatives  |</pre><p>And if I can’t recall them, I can simply ask Copilot for assistance.</p><figure><img alt="Example of a response from Copilot asking about one person." src="https://cdn-images-1.medium.com/max/685/1*uxbI0EYHH2c4ZsFGAFJ5Rg.png" /><figcaption>Example of a response from Copilot asking about one person.</figcaption></figure><h3>Conclusions</h3><p>Integrating AI tools like Microsoft Copilot with Visual Studio Code can significantly enhance your productivity and organization. These tools streamline workflows, automate routine tasks, and help maintain a well-structured professional diary. The benefits are clear: saving time, easy access to crucial information, and improved organization. As AI technology continues to evolve, the potential for even greater productivity and efficiency is on the horizon, making this an exciting time for professionals looking to optimize their work processes.</p><h3>How to cite this story</h3><p>Caballero, P. (2025, January). Boost Your Productivity: AI Assisted Professional Diary Using Visual Studio Code + Copilot. Medium. Retrieved from <a href="https://medium.com/p/b1ce830a9e8f">https://medium.com/p/b1ce830a9e8f</a></p><h3>References</h3><p>[1] García Ferré, M. (1982). <em>EL LIBRO GORDO DE PETETE. TOMO AMARILLO</em>. Buenos Aires: P.P.T. ISBN 978–848602703–2.</p><p>[2] Microsoft (2024). <em>Visual Studio Code</em>. [online] VisualStudio.com. Available at: <a href="https://code.visualstudio.com/">https://code.visualstudio.com/.</a></p><p>[3] Microsoft.com. (2024). <em>Copilot Pro Plan &amp; Pricing — Premium AI Features &amp; Latest Models I Microsoft Store</em>. Retrieved from: <a href="https://www.microsoft.com/en/store/b/copilotpro?market=af">https://www.microsoft.com/en/store/b/copilotpro?market=af</a>.</p><p>[4] Yu Zhang (2024, January). <em>GitHub — yzhang-gh/vscode-markdown: Markdown All in One</em>. Retrieved from: <a href="https://github.com/yzhang-gh/vscode-markdown">https://github.com/yzhang-gh/vscode-markdown</a>.</p><p><em>This story, provided by </em><a href="https://www.linkedin.com/in/pcaballero/"><em>Pablo Caballero</em></a><em> on Medium, is intended for general information purposes only. All information has been provided in good faith; however, I make no representation or warranty of any kind, express or implied, regarding the accuracy, adequacy, validity, reliability, availability, or completeness of any information in this story.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b1ce830a9e8f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/bestsecret-tech/boost-your-productivity-ai-assisted-professional-diary-b1ce830a9e8f">Boost Your Productivity: AI Assisted Professional Diary</a> was originally published in <a href="https://medium.com/bestsecret-tech">BESTSECRET Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Delete old GitLab pipelines]]></title>
            <link>https://medium.com/bestsecret-tech/delete-old-gitlab-pipelines-7dc61a76e91?source=rss-a48e2d312a34------2</link>
            <guid isPermaLink="false">https://medium.com/p/7dc61a76e91</guid>
            <category><![CDATA[delete]]></category>
            <category><![CDATA[pipeline]]></category>
            <category><![CDATA[api-pipeline]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[gitlab]]></category>
            <dc:creator><![CDATA[Pablo Caballero]]></dc:creator>
            <pubDate>Fri, 07 Oct 2022 13:56:01 GMT</pubDate>
            <atom:updated>2025-10-10T08:18:32.780Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Delete old pipelines button (fiction)." src="https://cdn-images-1.medium.com/max/1024/1*M2doxLz7j7TBXj9gC8K_Zw.png" /><figcaption>Delete old pipelines button.</figcaption></figure><h3>Problem</h3><p>GitLab does not currently provide a built‑in “Delete old pipelines” action. While such a feature may appear on GitLab’s roadmap, teams cannot rely on that. Fortunately, GitLab’s Pipeline API [<a href="https://medium.com/p/7dc61a76e91#2f9a">1</a>] tis well documented and allows automation of pipeline cleanup.</p><h3>Why clean up pipelines?</h3><p>Pipelines typically serve their purpose while the associated branch is active. After a short period many build records, logs, artifacts and triggers lose value while continuing to consume storage and management effort. Evaluate retention needs and balance the cost of keeping historical pipeline data against its usefulness.</p><h3>Manual removal</h3><p>On an individual pipeline page there is a red “Delete” button in the top‑right corner. Clicking it opens a confirmation dialog; the developer must explicitly confirm the action. Deletion is irreversible and requires appropriate project permissions (Maintainer or Owner). Deleting a pipeline removes related logs, artifacts and triggers; stop and preserve any objects you need before proceeding.</p><figure><img alt="Screenshot of delete button." src="https://cdn-images-1.medium.com/max/369/1*r1S6kFXZt97jykhq3K4XFQ.png" /><figcaption>Screenshot of delete button.</figcaption></figure><figure><img alt="Warning message when a user tries to delete a pipeline." src="https://cdn-images-1.medium.com/max/969/1*S5YAekenmxKu1WmgXW045Q.png" /><figcaption>Warning message when a user tries to delete a pipeline.</figcaption></figure><h3>Automating cleanup with the Pipeline API</h3><p>This guide demonstrates a simple Python script that uses the GitLab Pipeline API to delete pipelines older than a configured threshold.</p><p>1 Create a GitLab Access Token for accessing to GitLab API. In GitLab, in top-right corner: <em>Edit Profile&gt; Personal Access Tokens &gt; Add new token</em></p><p>Or directly go to URL: <a href="https://gitlab.com/-/user_settings/personal_access_tokens">https://gitlab.com/-/user_settings/personal_access_tokens</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*GBFFksVm9OhIGhnyzFW4xQ.png" /><figcaption>Personal Access Tokens.</figcaption></figure><p>The <strong>scope </strong>should be api and due to security reasons I strongly recommend an <strong>expiration date</strong>. After clicking on “<em>Create token</em>”, the new code will appear. Please, write it down in a <strong>secure place</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*mo68_beUZzSoWrcFoxZ4iA.png" /><figcaption>New personal access token detail.</figcaption></figure><p>2 Look for the <strong>project ID</strong>. In the main page of your GitLab repository, it is shown (it is a natural number). Please, write it down.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/373/1*ZmbGqB-nDSfbZmAWyox5FQ.png" /><figcaption>Project ID detail.</figcaption></figure><p>Archived projects are read-only, if you need to perform this clean up then first you need to unarchive them.</p><p>3 Install Python 3 (latest version): <a href="https://www.python.org/downloads/">https://www.python.org/downloads/</a></p><figure><img alt="Python logo." src="https://cdn-images-1.medium.com/max/1024/0*up7IBebHaHvOVfXD" /><figcaption>Photo by <a href="https://unsplash.com/es/@rubaitulazad?utm_source=medium&amp;utm_medium=referral">Rubaitul Azad</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>4 Install the following Python libraries:</p><ul><li><strong><em>request</em></strong><em> </em>library [<a href="https://medium.com/p/7dc61a76e91#63a5">2</a>] is used for using an API:</li></ul><blockquote>pip install request</blockquote><ul><li><strong><em>python-dateutil</em></strong> library [<a href="https://medium.com/p/7dc61a76e91#27e0">3</a>] is used to parse ISO 8601 dates:</li></ul><blockquote>pip install python-dateutil</blockquote><p><a href="https://gist.githubusercontent.com/p-caballero/cccefa6f78199f8c9f04b68c94ba523e/raw/6529217cefcb56fd1d5fcc5d172a1f52d26c415c/delete_pipelines.py">5 Download </a>the script <em>delete_pipelines.py</em>. In the next section the different parts will be explained.</p><blockquote><strong>Disclaimer of Implied Warranties</strong></blockquote><blockquote>THIS GUIDE IS PROVIDED FOR INFORMATIONAL PURPOSES. TEST CAREFULLY AND USE AT YOUR OWN RISK. FOR QUESTIONS OR FEEDBACK, CONTACT THE AUTHOR.</blockquote><figure><img alt="Read disclaimer of implied warranties." src="https://cdn-images-1.medium.com/max/1024/0*BUL9W6DZhA4ZjjqU" /><figcaption>Photo by <a href="https://unsplash.com/@tingeyinjurylawfirm?utm_source=medium&amp;utm_medium=referral">Tingey Injury Law Firm</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>6In the script <em>delete_pipelines.py</em>, modify the value of the variable ACCESS_TOKEN to <strong>your</strong> GitLab access token. All the request to GitLab API must be authenticated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*K4P3c2XlYhAHArnwKVoPJQ.png" /><figcaption>Constant with an access token.</figcaption></figure><p>7 In the script <em>delete_pipelines.py</em>, modify the value of the variable PROJECT_ID to your GitLab project ID.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/286/1*6PIq9swUmzE5bRgG3G0j5w.png" /><figcaption>Constant with a project ID.</figcaption></figure><p>8 (OPTIONAL) In the script <em>delete_pipelines.py</em>, modify the value of the variable NO_DAYS (number of days) if you want to delete pipelines older than 1 year. It is in <strong>days</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/199/1*vld5Iz7b3l1lsAzigaqHew.png" /><figcaption>Constant with the threshold of days</figcaption></figure><p><strong>Explanation</strong>:</p><ul><li>If NO_DAYSis 365(default), all the pipelines younger than 1 year won’t be deleted.</li><li>If NO_DAYSis 30 , all the pipelines younger than 30 days won’t be deleted.</li></ul><p>9Don’t forget <strong>saving </strong>the script <em>delete_pipelines.py </em>with your changes.</p><figure><img alt="Save your document!" src="https://cdn-images-1.medium.com/max/1024/0*x0-9Da_Xff8LbmtS" /><figcaption>Photo by <a href="https://unsplash.com/@0asa?utm_source=medium&amp;utm_medium=referral">Vincent Botta</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>10Finally, run the script <em>delete_pipelines.py</em>.</p><blockquote>python delete_pipelines.py</blockquote><h3>The code</h3><p>Here there is a brief explanation of the code. So, you can understand it and you could customize <a href="https://gist.githubusercontent.com/p-caballero/cccefa6f78199f8c9f04b68c94ba523e/raw/6529217cefcb56fd1d5fcc5d172a1f52d26c415c/delete_pipelines.py"><em>delete_pipelines</em></a><em>.py</em> for your needs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IqPWWkimgpXmbbSB" /><figcaption>Photo by <a href="https://unsplash.com/@cdr6934?utm_source=medium&amp;utm_medium=referral">Chris Ried</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Constant section</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a40a2b65c4ac1491a69eb899d9e52342/href">https://medium.com/media/a40a2b65c4ac1491a69eb899d9e52342/href</a></iframe><p>The global constants for the step 6, 7 and 8 are at the beginning of the script.</p><p>Do NOT upload this code in a repository with an active access token.</p><blockquote>I know global variables are the devil. However, it is a really small script.</blockquote><h4>Method get_old_pipelines</h4><p>Based on a UTC timestamp, the routine retrieves comprehensive pipeline metadata by iteratively fetching pages from the API. Because the API caps results at 100 items per page, the implementation requests pages of up to 100 records and follows the provided pagination tokens/parameters until no more pages remain, ensuring all pipeline records for the given UTC date are downloaded reliably and efficiently [<a href="https://medium.com/p/7dc61a76e91#c134">4</a>].</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bf4d8bca70504ae807cfd048526f20c0/href">https://medium.com/media/bf4d8bca70504ae807cfd048526f20c0/href</a></iframe><p>The pipelines are filtered using the field updated_at with a date in ISO 8601 format. E.g. <em>2016–08–11T11:32:35.169Z</em></p><blockquote>By the way, I need a do-while loop in Python!!! 🐼</blockquote><h4>Method delete_pipeline</h4><p>Deletion of a pipeline [<a href="https://medium.com/p/7dc61a76e91#2f9a">1</a>] based on the pipeline ID is requested.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f46e41b184662af7e740c0a4f7a1ccfb/href">https://medium.com/media/f46e41b184662af7e740c0a4f7a1ccfb/href</a></iframe><h4>Method main</h4><p>At a high level, the method identifies stale GitLab pipelines based on a configured cutoff, paginates through the results, and issues individual delete requests for each pipeline. It includes basic error handling, respects API rate limits, and logs each deletion so the cleanup remains controlled, auditable, and resilient to transient failures.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2959f5ed810e0f8aa7da1639f4e81138/href">https://medium.com/media/2959f5ed810e0f8aa7da1639f4e81138/href</a></iframe><h4>Full code</h4><p>Please, have a look at the code.</p><blockquote>Some Python snippets can be condensed into fewer lines, but brevity should not come at the expense of readability — I prefer clean, well-structured code.</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cbf66cb0af853ec45441e124dd385a56/href">https://medium.com/media/cbf66cb0af853ec45441e124dd385a56/href</a></iframe><h3>Conclusion</h3><p>This story demonstrated a practical procedure to remove obsolete GitLab pipelines to reclaim storage and simplify repository maintenance.</p><p>The GitLab Pipeline API enables broad automation, and a concise Python script can reliably automate routine clean-up tasks.</p><h3>Than you for your attention</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ROBQ97c2fANGwiMW" /><figcaption>Photo by <a href="https://unsplash.com/@wilhelmgunkel?utm_source=medium&amp;utm_medium=referral">Wilhelm Gunkel</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Please don’t hesitate to <a href="https://www.linkedin.com/in/pcaballero/">contact me</a> if you want to talk about this or anything else.</p><h3>How to cite this story</h3><blockquote><em>Caballero, P. (2025, October). Delete old GitLab pipelines. Medium. Retrieved from </em><a href="https://medium.com/p/7dc61a76e91"><em>https://medium.com/p/</em>7dc61a76e91</a></blockquote><h3>References</h3><p>[1] GitLab. API Docs Pipelines API. Retrieved from <a href="https://docs.gitlab.com/ee/api/pipelines.html">https://docs.gitlab.com/ee/api/pipelines.html</a></p><p>[2] Python request library. Requests: HTTP for Humans™. Retrieved from <a href="https://requests.readthedocs.io/">https://requests.readthedocs.io/</a></p><p>[3] Python python-dateutil library. dateutil — powerful extensions to datetime. Retrieved from <a href="https://dateutil.readthedocs.io/en/stable/">https://dateutil.readthedocs.io/en/stable/</a></p><p>[4] GitLab. API Docs Pagination. Retrieved from <a href="https://docs.gitlab.com/ee/api/index.html#pagination">https://docs.gitlab.com/ee/api/index.html#pagination</a></p><p><em>This story (it isn’t a paper) provided by </em><a href="https://www.linkedin.com/in/pcaballero/"><em>Pablo Caballero</em></a><em> on Medium is for general information purposes only. All information has been provided in good faith, however I make no representation or warranty of any kind, express or implied, regarding the accuracy, adequacy, validity, reliability, availability or completeness of any information on this story.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7dc61a76e91" width="1" height="1" alt=""><hr><p><a href="https://medium.com/bestsecret-tech/delete-old-gitlab-pipelines-7dc61a76e91">Delete old GitLab pipelines</a> was originally published in <a href="https://medium.com/bestsecret-tech">BESTSECRET Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GitLab Runner with Docker Compose in Windows]]></title>
            <link>https://medium.com/bestsecret-tech/gitlab-runner-with-docker-compose-in-windows-9d19dcc04763?source=rss-a48e2d312a34------2</link>
            <guid isPermaLink="false">https://medium.com/p/9d19dcc04763</guid>
            <category><![CDATA[docker-compose]]></category>
            <category><![CDATA[gitlab]]></category>
            <category><![CDATA[runners]]></category>
            <category><![CDATA[windows]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Pablo Caballero]]></dc:creator>
            <pubDate>Mon, 25 Jul 2022 08:46:29 GMT</pubDate>
            <atom:updated>2022-07-25T08:46:29.448Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*T5_igYS4s3Vyg5Lo" /><figcaption>Photo by <a href="https://unsplash.com/@pankajpatel?utm_source=medium&amp;utm_medium=referral">Pankaj Patel</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>What is a GitLab Runner?</h3><p>A <strong>GitLab runner </strong>[<a href="https://medium.com/p/9d19dcc04763#f046">1</a>] is an application responsible of the creation and handling of CI/CD jobs of GitLab pipelines. It can be installed on Linux, macOS, FreeBSD and <strong>Windows</strong>.</p><p>As you know, we can use tags in your pipeline to select the runner that you want. So, you could have multiple runners, each one with a different configuration.</p><p>Usually companies have their own runners and for personal small projects we can use the shared runners provided by GitLab (every account has a limit of minutes per month).</p><p>The current setup is a non-enterprise project, the developer machine is a Windows 10 and we need jobs with Linux or Windows images. This setup is common when we’re maintaining <strong>.NET-Framework</strong> applications (Windows containers) and we’re developing <strong>.NET-Core</strong>, <strong>.NET-Standard</strong>, <strong>.NET5</strong>, <strong>.NET6</strong>, and <strong>Java </strong>applications (Linux containers).</p><h3>What is Docker Compose?</h3><p><strong>Docker Compose</strong> [<a href="https://medium.com/p/9d19dcc04763#d3df">2</a>] is a container orchestrator, so we can easily configure a docker container with a manifest file (<em>compose.yaml</em>).</p><p>Docker Compose is installed with <strong>Docker Desktop</strong> so you just need to install it from <a href="https://www.docker.com/products/docker-desktop/">docker.com</a>. Beware of the service agreement, it has changed.</p><h3>Configuring Docker Desktop</h3><p>First of all, I’d recommend install and configure WSL 2 [<a href="https://medium.com/p/9d19dcc04763#2f50">3</a>] in your Windows 10 machine. How to do it is out of the scope of this story.</p><p>You have to download and install Docker Desktop. Or just run the following command.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1da12c5547610d59d7c170026a5752db/href">https://medium.com/media/1da12c5547610d59d7c170026a5752db/href</a></iframe><p>After installing it, you should see the whale icon and you can open the dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W7oJAB9wOFFVqC_W9woadQ.png" /><figcaption>Docker Desktop dashboard.</figcaption></figure><p>If you need a Windows container, then you should <strong>switch to Windows containers</strong> mode. In this story I’m going to explain how to do it with Linux containers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/316/1*3FpJeul-Ug6vCR8ObMKEvg.png" /><figcaption>Docker Desktop context menu (<strong>Switch to Windows containers…</strong> is marked).</figcaption></figure><h3>Configuring our runner</h3><p>1 We should create a folder (e.g. my-project-runner) for our runner.</p><p>2 Copy the following manifest file (<em>compose.yaml</em>) in the runner folder.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/429e0600a12e3c9050ebdb794d51ba55/href">https://medium.com/media/429e0600a12e3c9050ebdb794d51ba55/href</a></iframe><p>The configuration file for the runner will be stored in the folder named config (e.g. <em>c:\my-project-runner\config</em>).</p><p>3 Copy the following installation PowerShell script in the runner folder.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/20004167ba41daaca7d9cdb8a29e1733/href">https://medium.com/media/20004167ba41daaca7d9cdb8a29e1733/href</a></iframe><p>Warning: Docker Desktop should be running in background, otherwise all docker commands will fail.</p><p>4 For the next steps we need some information. In GitLab, go to your project and then in left menu: <em>Settings </em>&gt; <em>CI/CD </em>&gt; <em>Runners </em>&gt; <em>Specific runners</em></p><p>It should be in the a URL similar to:</p><blockquote><a href="https://gitlab.com/pablo.caballero/helloworld6/-/settings/ci_cd">https://gitlab.com/my-user/my-project/-/settings/ci_cd</a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/976/1*jNnM7ECpt7IXYAqHcKZkpQ.png" /><figcaption>Specific runners section</figcaption></figure><p>We have to note the following information:</p><ol><li><strong>GitLab instance URL</strong> (<a href="https://gitlab.com/pablo.caballero/helloworld6/-/settings/ci_cd">https://gitlab.com/</a>).</li><li>The <strong>registration token</strong>.</li></ol><p>5 Register the runner for our project (or group). Execute the previous script. It will start the container called <em>gitlab-runner</em> and it will execute the command <em>register </em>inside the container.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*CA4yQDE2PSlj-JtxHWZCBA.png" /><figcaption>Screenshot of calling install.ps1</figcaption></figure><p>6 The <strong>GitLab instance URL</strong> is requested so we should fill it up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/458/1*UdJamaqg_0LXKGbaVFeF0Q.png" /></figure><p>7 The <strong>registration token</strong> of your project is requested (copy it from the web and paste it in the your terminal).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/209/1*qOGomnjYjC2JP8BZLTzHeA.png" /><figcaption>Screenshot of calling install.ps1 &gt; Section registration token</figcaption></figure><p>8 A description is requested. You can leave it empty or you can set a name for it (e.g. helloworld6-runner-1).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/258/1*Ri_FaKWYmNSDENUYnTWVjQ.png" /><figcaption>Screenshot of calling install.ps1 &gt; Section description of the runner</figcaption></figure><p>9 The <strong>tags </strong>to identify you runner. In my case I’ve used <em>linux </em>and <em>docker</em>, but you can use whatever you want (it should be in tags section in your .gitlab-ci file).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/314/1*vNxO8Q9kgCil87ldGh8ayQ.png" /><figcaption>Screenshot of calling install.ps1 &gt; Section tags</figcaption></figure><p>10 An <strong>optional maintenance note</strong> can be added. You can leave it empty.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/341/1*4Cej8Zs3zIdwwugFSnDitQ.png" /><figcaption>Screenshot of calling install.ps1 &gt; Section maintenance note</figcaption></figure><p>11 The <strong>executor </strong>is requested, it has to be <strong><em>docker</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/1*LXoGZnA_JYmSIXk46hFylA.png" /></figure><p>12 The <strong>default image</strong> is requested (you can change it in your jobs in the section <em>image</em>), in my case it will be one of the lightest, <strong>alpine:latest</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/903/1*gP40oyJUvdMNeucND8Y4fA.png" /><figcaption>Screenshot of calling install.ps1 &gt; Section executor and default image</figcaption></figure><p>13 Now the runner is registered and it is ready to be used (it is taken automatically based on the tags).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*BW-VH9KT_BLUehCZiZlsxw.png" /><figcaption>Specific runners section with the new runner.</figcaption></figure><p>The new runner is visible is your Docker Desktop dashboard and the jobs appears during their execution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J4rKy9BtoQ2m1tTb03q_3w.png" /><figcaption>Docker Desktop dashboard with our runner.</figcaption></figure><p>We can see in the log of the job that the runner is our runner instead of a shared runner.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/637/1*FgQhxjIrmdquztRCQIh11g.png" /><figcaption>Screenshot of a GitLab job log.</figcaption></figure><h3>Stop our runner</h3><p>1 If we want to stop the runner locally we can call to the docker compose command. Don’t forget starting it later.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6105f97afdc2fadf4b74bed5f1b3892a/href">https://medium.com/media/6105f97afdc2fadf4b74bed5f1b3892a/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/399/1*HJx-I-98UlD8-zV3pfTYtg.png" /><figcaption>Screenshot of the execution of the command stop.</figcaption></figure><p>2 Or we could close Docker Desktop, so it won’t be available.</p><p>3 Or we can pause it in the specific runner section (there is a pause symbol button).</p><h3>Remove our runner</h3><p>When we don’t our runner anymore, we can remove it.</p><p>1In GitLab, in <em>available specific runners</em> clicking on the red button “<strong><em>Remove runner</em>”</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*BW-VH9KT_BLUehCZiZlsxw.png" /><figcaption>Specific runners section with the new runner.</figcaption></figure><p>2 Remove it locally calling to the following command.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/11d0ffd7e36184a361abd4f1189b6078/href">https://medium.com/media/11d0ffd7e36184a361abd4f1189b6078/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/399/1*ctjVpuHuyICj2DffccisrA.png" /><figcaption>Screenshot of the execution of the command down.</figcaption></figure><h3>Conclusions</h3><p>The pipelines are a key point of the quality of any project and we need to spend some resources to run them.</p><p>We’ve seen how to easily install and configure a GitLab runner locally. Henceforth, now we don’t have excuses to prepare our pipelines for our personal projects.</p><h3>References</h3><p>[1]: GitLab. Run GitLab Runner in a container. Retrieved from <a href="https://docs.gitlab.com/runner/install/docker.html">https://docs.gitlab.com/runner/install/docker.html</a></p><p>[2]: Docker Documentation. Overview of Docker Compose. Retrieved from <a href="https://docs.docker.com/compose/">https://docs.docker.com/compose/install/</a></p><p>[3]: Microsoft Docs. Install WSL. Retrieved from <a href="https://docs.microsoft.com/en-us/windows/wsl/install">https://docs.microsoft.com/en-us/windows/wsl/install</a></p><p><em>This story (it isn’t a paper) provided by </em><a href="https://www.linkedin.com/in/pcaballero/"><em>Pablo Caballero</em></a><em> on Medium is for general information purposes only. All information has been provided in good faith, however I make no representation or warranty of any kind, express or implied, regarding the accuracy, adequacy, validity, reliability, availability or completeness of any information on this story.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9d19dcc04763" width="1" height="1" alt=""><hr><p><a href="https://medium.com/bestsecret-tech/gitlab-runner-with-docker-compose-in-windows-9d19dcc04763">GitLab Runner with Docker Compose in Windows</a> was originally published in <a href="https://medium.com/bestsecret-tech">BESTSECRET Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SOLID is not a state]]></title>
            <link>https://medium.com/bestsecret-tech/solid-is-not-a-state-720795e57cf6?source=rss-a48e2d312a34------2</link>
            <guid isPermaLink="false">https://medium.com/p/720795e57cf6</guid>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[solid-principles]]></category>
            <category><![CDATA[example]]></category>
            <category><![CDATA[oop]]></category>
            <dc:creator><![CDATA[Pablo Caballero]]></dc:creator>
            <pubDate>Tue, 07 Jun 2022 15:03:05 GMT</pubDate>
            <atom:updated>2022-06-17T08:42:39.336Z</atom:updated>
            <content:encoded><![CDATA[<p>A typical question that I see in many technical interviews is “tell me something about <strong>SOLID principles</strong>”. Here we can see three types of candidates, the first one begin wearing poker face, the second type has heard about the topic but they repeat the theory as a parrot and the third one is a white blackbird.</p><figure><img alt="Blackbird" src="https://cdn-images-1.medium.com/max/1024/0*485ejTFKprsDtQAS" /><figcaption>Photo by <a href="https://unsplash.com/@stafra?utm_source=medium&amp;utm_medium=referral">Stephen Tafra</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>What is a principle?</h3><p>First of all, I’d like to reference to the definition of principle in <a href="https://dictionary.cambridge.org/dictionary/english/principle">Cambridge dictionary</a>.</p><blockquote>If you agree with or believe something in principle, you agree with the idea in general, although you might not support it in reality or in every situation.</blockquote><p>So, the first thing in mind could be… — Can we break them? — Yes, we can and sometimes we have to do it. Hence, the second question comes… — When should we do it? It isn’t a stupid question, but maybe a stupid answer and a song (by Jarabe de Palo) comes to my mind. — As everything in life it depends on… As an experienced software engineer you should balance the risk of breaking one of them and a possible overengineering. In any case <strong>try </strong>to follow these ideas.</p><p>Consequently, we’ve a list of ideas to make our life easier and that is good for our colleges as well. One effect would be having a cleaner code.</p><h3>Let’s do it</h3><figure><img alt="Acronyms" src="https://cdn-images-1.medium.com/max/1024/0*5jWgoWtLQL34BSVs" /><figcaption>Photo by <a href="https://unsplash.com/@seffen99?utm_source=medium&amp;utm_medium=referral">Sven Brandsma</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>SOLID</strong> is an acronym, this acronym is for 5 principles:</p><ul><li><strong>S</strong>ingle Responsibility Principle (<a href="https://medium.com/p/720795e57cf6#7d94">SRP</a>).</li><li><strong>O</strong>pen-Closed Principle (<a href="https://medium.com/p/720795e57cf6#829d">OCP</a>).</li><li><strong>L</strong>iskov’s Substitution Principle (<a href="https://medium.com/p/720795e57cf6#af82">LSP</a>).</li><li><strong>I</strong>nterface Segregation Principle (<a href="https://medium.com/p/720795e57cf6#5f82">ISP</a>).</li><li><strong>D</strong>ependency Inversion Principle (<a href="https://medium.com/p/720795e57cf6#4bef">DIP</a>).</li></ul><h3>Single Responsibility Principle</h3><blockquote>There should never be more than one reason for a class to change.</blockquote><figure><img alt="Swiss army knife" src="https://cdn-images-1.medium.com/max/354/1*P00VWgKbRtHtq3Vd596HQQ.png" /><figcaption>Idea: What shouldn’t not be done.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/240/1*yNcPoOvF3vuoFCf0snIo-A.png" /><figcaption>Robert C. Martin</figcaption></figure><p>It was introduced in 2003 by the software engineer Robert C. Martin or just “Uncle Bob” in his book “Agile Software Development, Principles, Patterns, and Practice” [<a href="https://medium.com/p/720795e57cf6#47f7">1</a>].</p><p>Nobody wants to remake a class, so if business wants another feature or functionality the development team should reduce the number of changes. Bear in mind business can change their mind like a weather vane.</p><p>One recommendation is using domain-driven-design (DDD) or any kind of layered architecture, so the developer has an idea where the code should be otherwise some it’s a chaos (or a spaghetti code).</p><figure><img alt="C. L. “Kelly” Johnson" src="https://cdn-images-1.medium.com/max/240/1*ohtRTju912nFZfX3tRABaQ.png" /></figure><p>Ergo this principle I would summed it up in “<strong>KISS principle”</strong> [<a href="https://medium.com/p/720795e57cf6#242f">2</a>] introduced by the engineer Kelly Johnson: <strong>Keep It Simple Stupid</strong>. Honestly, we should apply it in our life…</p><p><strong><em>Use case 1</em></strong>: We’re making a class and we need its loader, then we create a method or a constructor to load it… Later we receive a new functional requirement, so it will be loaded in another way and hence we will have to change it again. However the real functionality of our class remains.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fc0fbe7e8690ce1d498d9786795ae0e1/href">https://medium.com/media/fc0fbe7e8690ce1d498d9786795ae0e1/href</a></iframe><p>Thus, we could split it in some specific classes:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/955ce2a1bbee3486fb2aeddd051bfb04/href">https://medium.com/media/955ce2a1bbee3486fb2aeddd051bfb04/href</a></iframe><p><strong><em>Use case 2</em></strong>: When we’re applying DDD, it’s really common merging the application layer (an orchestrator) and the domain layer (the business logic)… At the beginning it could be fine when we just have two methods and a constructor. However, we shouldn’t forget to split it when the size is bigger than a little “monster”.</p><h4>➕ <strong>Benefits</strong>:</h4><ul><li><strong>Decoupling</strong>. Instead of having one class that does everything we have multiple parts of a complex organism.</li><li>A lot of responsibilities then a lot of reasons to change it.</li><li>Easier to <strong>read</strong>. The code should be readable, we’re not in the assembler ages.</li><li>Easier to <strong>maintain</strong>. More classes with less code.</li><li>Easier <strong>testing</strong>. We’ve simpler classes to test.</li></ul><h4>➖ <strong>Drawbacks:</strong></h4><ul><li>Outbreak of classes (currently the space is not a problem), a well defined architecture is needed.</li></ul><h3>Open-Closed Principle</h3><blockquote>Software entities (classes , modules , functions , etc .) should be open for extension , but closed for modification</blockquote><figure><img alt="Dr. Bertrand Mayer" src="https://cdn-images-1.medium.com/max/300/1*HGMH4FwGctJtqTAUMhSdKw.png" /><figcaption>Dr. Bertrand Mayer</figcaption></figure><p>It was introduced in 1988 by Dr. Bertrand Mayer in his book “Object Oriented Software Construction” [<a href="https://medium.com/p/720795e57cf6#bb4f">3</a>].</p><h4>1️⃣ Open for extension</h4><ul><li>The behaviour of a module can be extended to meet the new requirements.</li></ul><h4>2️⃣ Closed for modification</h4><ul><li>The source code of that module is inviolate.</li><li>A program cannot be 100% closed, we have to find a strategy to modify it.</li></ul><h4>How can we do?</h4><ul><li><strong>Abstraction</strong>. We should detect the required properties and behaviours of an object to differentiate it from other objects.</li><li><strong>Polymorphism</strong>.[<a href="https://medium.com/p/720795e57cf6#8d3f">↗</a>] Our objects should inherit from other more generic and then we can reuse attributes and methods from other classes.</li></ul><h4>Polymorphism (extra)</h4><ul><li>Method/Constructor overloading: Same name with different arguments.</li><li>Method overriding: Same name and same arguments. It replaces the inherited implementation.</li><li>[Overriding in Java] The method has a new implementation than the parent class. In the parent class the method has not to be marked as <em>final</em>.</li><li>[Overriding in C#] The parent class the method has to be marked as <em>virtual </em>and in our class the method has to be marked as <em>override</em>.</li></ul><p><strong>Use case 3</strong>: We’ve several ways to do a method. So we could call to a specific method depending on an instance variable…</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f826446b67af894d1a3464620343c7a6/href">https://medium.com/media/f826446b67af894d1a3464620343c7a6/href</a></iframe><p>In the following method we’ve the same functionality:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e4b64202af312cb35a6f973366903ef4/href">https://medium.com/media/e4b64202af312cb35a6f973366903ef4/href</a></iframe><h4>➕ Benefits:</h4><ul><li>Easier to <strong>maintain</strong>.</li><li><strong>Reusable</strong>.</li></ul><h4>➖ <strong>Drawbacks:</strong></h4><ul><li>Some effort to change the mentality to object-oriented programming.</li></ul><h3>Liskov’s Substitution Principle</h3><blockquote><em>Objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program.</em></blockquote><figure><img alt="Dr. Barbara H. Liskov &amp; Dr. Jeannette M. Wing" src="https://cdn-images-1.medium.com/max/594/1*ORuc-OJMN5OlM0aBaFErhg.png" /><figcaption>Dr. Barbara H. Liskov &amp; Dr. Jeannette M. Wing</figcaption></figure><p>It was introduced in 1994 by Dr. Barbara H. Liskov and Dr. Jeannette M. Wing [<a href="https://medium.com/p/720795e57cf6#28e2">4</a>]. Later in 1996, Robert C. Martin officially the principle was named.</p><p>In my opinion, current object oriented programming languages ease developers to don’t think about this principle… We always can see exceptions…</p><h4>👩‍🎓 Summing up:</h4><blockquote>S is a subtype of T ➡ Objects of type T may be replaced with objects of type S</blockquote><p><strong>Use case 4</strong>: We’ve applied inheritance, however we are overriding a behaviour…</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/42d2ff3758905319d87c066517fb7348/href">https://medium.com/media/42d2ff3758905319d87c066517fb7348/href</a></iframe><p>We could create a base class to define a behaviour, and one implementation per class.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/382730cba0d204deeb3d56a773d967af/href">https://medium.com/media/382730cba0d204deeb3d56a773d967af/href</a></iframe><p>In the previous examples the method <em>calculateArea()</em> is defined once and used in both classes due to the inheritance. We’re applying this principle to the list as well in combination with ISP.</p><p>➕ Benefits:</p><ul><li>Easier to <strong>maintain</strong>. And code reviews are easier with smaller files…</li><li><strong>Reusable.</strong> The common code goes to parent classes<strong>.</strong></li></ul><h4>➖ Drawbacks:</h4><ul><li>Some effort to change the mentality to object-oriented programming.</li></ul><h3>Interface Segregation Principle</h3><blockquote><em>Many client-specific interfaces are better than one general-purpose interface.</em></blockquote><p><strong>Use case 5</strong>: We’ve been grouping all the functionality in the same interface but some methods are not supported by all the classes… A bad approach is throwing an exception.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/513351fca90c2fc571617a8679f82473/href">https://medium.com/media/513351fca90c2fc571617a8679f82473/href</a></iframe><p>The interface <em>IProduct </em>can be split in 2 or more specific interfaces, so you implement what you have.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/230f2f87c96ef7f77d4095a9a0fb0b33/href">https://medium.com/media/230f2f87c96ef7f77d4095a9a0fb0b33/href</a></iframe><p><strong>Use case 6</strong>: A common example is the implementation of the collections in <strong>Java </strong>(<em>List</em>, <em>Collection </em>or <em>Iterable</em>) and in <strong>.NET</strong> (<em>ICollection</em>, <em>IEnumerable </em>or <em>IQueriable</em>) as well.</p><h4>➕ Benefits:</h4><ul><li>Easier to <strong>maintain</strong>. The number of methods are reduced, you should have what you need and nothing more.</li><li>Reduced <strong>coupling</strong>. The usage if coupled to a contract.</li><li>Reduce <strong>“fat” interfaces</strong>. Clients should not be forced to depend upon interfaces that they do not use.</li></ul><h4>➖ Drawbacks:</h4><ul><li>Explosion of interfaces. A difficult question comes to my mind… — When should we stop splitting them? I have no answer…</li></ul><h3>Dependency Inversion Principle</h3><blockquote><em>High level modules should not depend upon low level modules. Both should depend upon abstractions.</em></blockquote><blockquote><em>Abstractions should not depend upon details . Details should depend upon abstractions.</em></blockquote><p>It was introduced by Rober C. Martin in 2003.</p><p>At this point, you should know (or not) what is an interface. An interface is a contract [<a href="https://medium.com/p/720795e57cf6#80b0">5</a>]. So you depend on what you need, you don’t depend on how to do it.</p><h4>Why?</h4><ul><li><strong>Rigidity</strong>. One change can affect many parts due to those specific implementations.</li><li><strong>Fragility</strong>. Unexpected errors happens because the developer could forget one of the dependencies (passing a null) or multiple implementations of classes with small behavioural differences…</li><li><strong>Immobility</strong>. It’s hard to reuse, we have constructions of classes everywhere. It’s really hard to test it or mock it.</li></ul><h4>How?</h4><ul><li><strong>Layering</strong>. Multiple layers and every layer has their responsibility. A common design pattern can be followed such as Domain Driven Development or Hexagon Architecture [6].</li><li><strong>Separate </strong>interface from implementation.</li><li>Finding the <strong>underlying abstraction</strong>.</li></ul><h4>Is IoC the same as DI?</h4><p>A typical mistake about this principle is thinking that the inversion of control (<em>IoC</em>) is the same as dependency injection (<em>DI</em>).</p><ul><li><strong>IoC</strong>. It’s a feature of the frameworks [<a href="https://medium.com/p/720795e57cf6#a583">7</a>]. The system calls me instead of my code calling to the framework. It’s the <em>Hollywood principle</em>:</li></ul><blockquote>Don’t call us, we’ll call you.</blockquote><ul><li><strong>DI</strong>. It’s a form of IoC where an object is passed through constructors/setters/services.</li><li><strong>IoC without DI</strong>. E.g. a template pattern where the implementation changes throught subclassing.</li></ul><p><strong>Use case 7</strong>: We need to access to more specific services either repositories or other services.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9ba1f6c90620fb7565db9f46d46dc493/href">https://medium.com/media/9ba1f6c90620fb7565db9f46d46dc493/href</a></iframe><p>The services should be injected before using them. In this example the service <em>IPaymentMethod </em>and the repository <em>IRepository </em>are passed in the constructor of <em>ShoppingBag</em>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ba39f82ea63c4bf9d28aeaf9d39851c6/href">https://medium.com/media/ba39f82ea63c4bf9d28aeaf9d39851c6/href</a></iframe><p><strong>Use case 8</strong>: Example of <em>ServiceLocator </em>as example IoC without DI.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fcc3efae258fd2afcdfc30e725787ff2/href">https://medium.com/media/fcc3efae258fd2afcdfc30e725787ff2/href</a></iframe><p>The previous class <em>ServiceLocator </em>is a simple container that maintains a list of implementations and those services can be requested wherever you need. Usually the dependencies are initialized in the constructor of the class.</p><p>In Spring Framework, IoC can be defined using an annotation mechanism or an xml configuration [<a href="https://medium.com/p/720795e57cf6#84c2">8</a>]. It isn’t the only one, there are also other libraries such as <a href="http://picocontainer.com/"><em>PicoContainer</em> </a>or <a href="https://github.com/google/guice"><em>Google Guice</em></a>.</p><p>In ASP.NET Core, with <em>IServiceCollection defined in Microsoft.Extensions.DependencyInjection</em> [<a href="https://medium.com/p/720795e57cf6#187b">9</a>] allows you to define the IoC. For older versions there were multiple libraries such as <a href="https://autofac.org/"><em>AutoFac</em></a>, <a href="http://www.ninject.org/"><em>NInject</em></a>, <a href="http://unitycontainer.org/articles/introduction.html"><em>Unity</em></a>, <a href="https://www.castleproject.org/"><em>Castle Windsor</em></a>…</p><h4>➕ Benefits:</h4><ul><li><strong>Maintainability</strong>. The <strong>coupling </strong>is <strong>reduced </strong>between layer/modules.</li><li><strong>Easier testing</strong>. We can create mocks, otherwise we’re coupled to the external services.</li><li><strong>Readability</strong>. You only declare what you need and then you just use them.</li></ul><h4>➖ Drawbacks:</h4><ul><li><strong>Non supported IoC</strong>. In system without native IoC, we’ve to implement it or spend time creating a way to use it.</li><li><strong>Multiple implementations</strong>. Sometimes there are multiple implementations for the same interface so you need a way to select unequivocally the desired class.</li></ul><h3>Than you for your attention</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GJxQiPQ1oqROqY8v" /><figcaption>Photo by <a href="https://unsplash.com/@wilhelmgunkel?utm_source=medium&amp;utm_medium=referral">Wilhelm Gunkel</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Please don’t hesitate to <a href="https://www.linkedin.com/in/pcaballero/">contact me</a> if you want to talk about this or anything else.</p><h3>How to cite this story</h3><blockquote>Caballero, P. (2022, June). SOLID is not a state. Medium. Retrieved from <a href="https://medium.com/p/720795e57cf6">https://medium.com/p/720795e57cf6</a></blockquote><h3>Acknowledgments</h3><p>I would like to acknowledge <a href="https://www.linkedin.com/in/juan-alfredo-2685b543/">De Jerónimo, J. A.</a> and Byle, D. for their assistance with review of this story.</p><h3>References</h3><p>[1]: Winter, R.J. (2014). Agile Software Development: Principles, Patterns, and Practices. Perf. Improv., 53: 43–46. DOI: <a href="https://doi.org/10.1002/pfi.21408">https://doi.org/10.1002/pfi.21408</a></p><p>[2]: Rich, B. (1995), 231. Clarence L. Johnson. National Academies Press. Washington D.C.. Retrieved from <a href="http://www.nasonline.org/publications/biographical-memoirs/memoir-pdfs/johnson-clarence.pdf">http://www.nasonline.org/publications/biographical-memoirs/memoir-pdfs/johnson-clarence.pdf</a></p><p>[3]: America, P. (1989). Object-oriented software construction. Science of Computer Programming, 12(1), 88–90. DOI: <a href="https://doi.org/10.1016/0167-6423(89)90034-8">https://doi.org/10.1016/0167-6423(89)90034-8</a></p><p>[4]: Liskov, B. and Wing, J. (1994). A behavioral notion of subtyping. ACM Trans. Program. Lang. Syst. 16, 6 (Nov. 1994), 1811–1841. DOI: <a href="https://doi.org/10.1145/197320.197383">https://doi.org/10.1145/197320.197383</a></p><p>[5]: Microsoft Doc (2022). interface-C# Reference. Retrieved from <a href="https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/interface">https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/interface</a></p><p>[6]: Stenberg, J. (2014). Exploring the Hexagonal Architecture. InfoQ. Retrieved from <a href="https://www.infoq.com/news/2014/10/exploring-hexagonal-architecture/">https://www.infoq.com/news/2014/10/exploring-hexagonal-architecture/</a></p><p>[7]: Fowler, M. (2005). InversionOfControl. Retrieved from <a href="https://martinfowler.com/bliki/InversionOfControl.html">https://martinfowler.com/bliki/InversionOfControl.html</a></p><p>[8]: The IoC container. Spring Framework Reference Documentation. Retrieved from <a href="https://docs.spring.io/spring-framework/docs/3.2.x/spring-framework-reference/html/beans.html">https://docs.spring.io/spring-framework/docs/3.2.x/spring-framework-reference/html/beans.html</a></p><p>[9]: Larkin, K. and Smith, S. and Dahler, B. (2022). Dependency injection in ASP.NET Core. Microsoft Doc. Retrieved from <a href="https://docs.microsoft.com/en-us/aspnet/core/fundamentals/dependency-injection?view=aspnetcore-6.0">https://docs.microsoft.com/en-us/aspnet/core/fundamentals/dependency-injection?view=aspnetcore-6.0</a></p><p><em>This story (it isn’t a paper) provided by </em><a href="https://www.linkedin.com/in/pcaballero/"><em>Pablo Caballero</em></a><em> on Medium is for general information purposes only. All information has been provided in good faith, however I make no representation or warranty of any kind, express or implied, regarding the accuracy, adequacy, validity, reliability, availability or completeness of any information on this story.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=720795e57cf6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/bestsecret-tech/solid-is-not-a-state-720795e57cf6">SOLID is not a state</a> was originally published in <a href="https://medium.com/bestsecret-tech">BESTSECRET Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[In memory SQLite for testing NHibernate + SQL Server]]></title>
            <link>https://medium.com/bestsecret-tech/in-memory-sqlite-for-testing-nhibernate-sql-server-ad07254685d2?source=rss-a48e2d312a34------2</link>
            <guid isPermaLink="false">https://medium.com/p/ad07254685d2</guid>
            <category><![CDATA[sqlite]]></category>
            <category><![CDATA[fluent-nhibernate]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[nhibernate]]></category>
            <category><![CDATA[dotnet]]></category>
            <dc:creator><![CDATA[Pablo Caballero]]></dc:creator>
            <pubDate>Tue, 15 Jun 2021 13:49:57 GMT</pubDate>
            <atom:updated>2021-06-16T08:01:24.418Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="DDD focused on the persistence layer." src="https://cdn-images-1.medium.com/max/1024/1*vFbhFKwuHg1tfsvRY4v54w.png" /><figcaption>Domain Driven Design focused on the persistence layer.</figcaption></figure><p>In <strong>.Net</strong> applications with a <strong>DDD </strong>architecture, when it is needed to create a <a href="https://martinfowler.com/articles/microservice-testing/">component test</a>, the database is a problem. A real database should not be used (it would be a system test) so ideally it should be an in-memory database. An additional problem appears when NHibernate <strong>ORM </strong>is used to handle SQL Server databases. This article will show a proposal of how to use an in-memory SQLite database to test it.</p><p>First of all, can you use <a href="https://docs.microsoft.com/en-us/ef/">EntityFramework</a>? If then answer is yes then move to it (it supports in-memory database natively), otherwise this article is for you.</p><h3>Required NuGet Dependencies</h3><figure><img alt="SQLite logo" src="https://cdn-images-1.medium.com/max/240/1*rRkoBSmccuop10wH5GJjYw.png" /><figcaption>SQLite logo.</figcaption></figure><p>Some NuGet libraries are needed to perform these kind of tests.</p><p><a href="https://www.nuget.org/packages/System.Data.SQLite.Core/"><strong>System.Data.SQLite.Core</strong></a> has to be added to the testing projects. This library contains all the necessary classes to use SQLite in a .Net application.</p><figure><img alt="NHibernate logo" src="https://cdn-images-1.medium.com/max/320/1*XaJ5RtfbArPj_dqhXHaq0w.png" /><figcaption>NHibernate logo.</figcaption></figure><p><a href="https://www.nuget.org/packages/NHibernate/"><strong>NHibernate </strong></a>and <a href="https://www.nuget.org/packages/FluentNHibernate/"><strong>FluentNHibernate</strong></a> should be already added to the projects to be tested. The first one is the library of the ORM and the second one is a configuration system of NHibernate.</p><h3>Incompatibilities SQL Server vs SQLite</h3><p>It is not compatible by default so the faced incompatibilities are described below and how to sort them out. Mainly they are:</p><ul><li>Tables with version/timestamp.</li><li>Usage of the type Guid (<em>uniqueidentifier</em>).</li><li>Views.</li><li>Schemas.</li><li>Custom SQL Scripts.</li></ul><p>Tables with dedicated version/timestamp columns. Those columns are used to configure the <a href="https://nhibernate.info/doc/nhibernate-reference/transactions.html">concurrency policy.</a> This feature is <a href="https://docs.microsoft.com/en-us/sql/t-sql/data-types/rowversion-transact-sql?redirectedfrom=MSDN&amp;view=sql-server-ver15">deprecated</a> in SQL Server 2019, however there are legacy codes that still use this feature. When an entity is defined using <a href="https://github.com/nhibernate/fluent-nhibernate/wiki/Fluent-configuration"><strong>FluentNHibernate.Mapping</strong></a>, its mapping (inheriting from ClassMap&lt;T&gt;) should be something like the following code.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6f7336c13f7f3379fc7a596528f835d6/href">https://medium.com/media/6f7336c13f7f3379fc7a596528f835d6/href</a></iframe><p>SQLite doesn’t support this feature but a value should be assigned, otherwise some queries could fail. The field <em>Version </em>is a byte array so it will be treated as an empty blob (using the method <a href="https://www.sqlite.org/lang_corefunc.html#zeroblob"><em>zeroblob</em></a>).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ecb17963e6736cac908da57f8c492e2b/href">https://medium.com/media/ecb17963e6736cac908da57f8c492e2b/href</a></iframe><p>Guid as keys. Whatever the reason, Sometimes a table could use a guid instead of an integer. SQL Server represents them as <a href="https://docs.microsoft.com/en-us/sql/t-sql/data-types/uniqueidentifier-transact-sql?view=sql-server-ver15">uniqueidentifier</a>. Moreover, the <a href="https://docs.microsoft.com/en-us/sql/t-sql/functions/newid-transact-sql?view=sql-server-ver15">method </a><em>NEWID()</em> should be defined as the default value in the CREATE TABLE script.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2f5c0551dbf09c965b84b396dca345d2/href">https://medium.com/media/2f5c0551dbf09c965b84b396dca345d2/href</a></iframe><p>SQLite doesn’t support guid, though the column can be a <a href="https://www.sqlite.org/datatype3.html">TEXT</a> with the guid format (<em>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</em>). Every section in guid is generated randomly and flacky tests should not appear due to this because the database should be destroyed after the test (or a rollback sould be called).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/29839c560a72309572b494666e3a304e/href">https://medium.com/media/29839c560a72309572b494666e3a304e/href</a></iframe><p><em>GuidAsText</em> class is used by NHibernate to serialize/deserialize all guid columns. It specifies the source and target types and the way to read them.</p><p><strong>FluenNHibernate</strong> has a way to connect to a SQLite database by default, however the default implementation is a <a href="https://github.com/nhibernate/nhibernate-core/blob/master/src/NHibernate/Dialect/SQLiteDialect.cs">dialect </a>for <strong>binary guid, </strong>so it is necessary to activate the text mode with <strong><em>BinaryGUID=False.</em></strong> The <a href="https://www.connectionstrings.com/sqlite/">connection string</a> and the proper way to generate a Guid (with <em>MySQLiteDialect</em> class) should be specified. If a binary guid is used then in the database it will be represented as a blob, and a blob cannot be easily readed.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4a547843413e9c889dac0cbde6c00814/href">https://medium.com/media/4a547843413e9c889dac0cbde6c00814/href</a></iframe><p>Debugging and testing go hand-in-hand, and it isn’t possible connecting to a in-memory database. Therefore for debugging the connection string should be changed to use an in-file SQLite database. It is slower nevertheless it can be queried with <a href="https://sqlitebrowser.org/">DB Browser for SQLite</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b38b541bbe15095d56afc902fc414a9c/href">https://medium.com/media/b38b541bbe15095d56afc902fc414a9c/href</a></iframe><p><strong>Views </strong>are supported by SQLite but NHibernate treats them like a read only table. A first approach could be use <a href="https://github.com/nhibernate/nhibernate-core/blob/master/src/NHibernate/Tool/hbm2ddl/SchemaExport.cs"><em>SchemaExport </em></a>to create the database, but it doesn’t generate the code for the views and in some cases the mapping is not exactly the same to the real structure.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fe811f3fb0164330d61fe91365e59383/href">https://medium.com/media/fe811f3fb0164330d61fe91365e59383/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/256/1*iGWCl6xAQ8eaY6gSqeYxOw.png" /></figure><p>On the one hand a SQL script has to be added to create all the database structure (it has <strong>to be maintained</strong>), but on the other hand we can use the file ddl.log to prepare it (most of this one is done in the file).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/080b90553c3aab18a68fcb7020b3f00d/href">https://medium.com/media/080b90553c3aab18a68fcb7020b3f00d/href</a></iframe><p><strong>Schemas</strong> are not supported by SQLite but it applies a workaround putting the name of the schema as a prefix. E.g. <em>dbo_MyTable</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bfdb3199973dc8a3b354efe6fdac727c/href">https://medium.com/media/bfdb3199973dc8a3b354efe6fdac727c/href</a></iframe><p>Dots (<em>My.Schema.Name</em>) aren’t allowed in the schema name in SQLite (they are in SQL Server) so a class for the schema names should be used to hide the names with constants or properties. In general, magic strings are a bad practice.</p><p>Maybe a static property should be used to distinguish a normal execution from a test (don’t forget to restore the status after running the test).</p><h3>Open a session</h3><p>To open a session using FluenNHibernate the previous configuration is used, either SQL Server or SQLite.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2ae6c04ba51b3a3f7afe3dbc2d5a67e3/href">https://medium.com/media/2ae6c04ba51b3a3f7afe3dbc2d5a67e3/href</a></iframe><h3>Transactions</h3><p>Fortunately they <strong>are compatible</strong> so no changes are needed.</p><p>When the approach of testing is one database per test-class then a transaction should be opened before running the test and an rollback should be called after running the test, otherwise <strong>flacky tests</strong> could appear.</p><figure><img alt="Metaphor of a flacky test" src="https://cdn-images-1.medium.com/max/1024/0*A3TGnbyJKx8L9fLE" /><figcaption>Photo by <a href="https://unsplash.com/@mrthetrain?utm_source=medium&amp;utm_medium=referral">Joshua Hoehne</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Drawbacks</h3><p>The creation of the database takes some time (few milliseconds). It depends on the decision of the developer/tester using one for the entire test-class or one per test.</p><p>The database is detroyed when the session is closed/disposed, so don’t dispose it before the test finises.</p><p>SQL script for the creation has to be maintained. Depending on the size of the database and how often it is modified, it could add an overhead in the development.</p><p>SQL queries has to be maintained. An approach could be create a wrapper for <em>ISession </em>and another for <em>ISQLQuery </em>to replace the specific methods.</p><h3>Acknowledgements</h3><p>I wish to acknowledge the help provided by <a href="https://medium.com/u/b3ff0cf50289">Juan Alfredo</a> and <a href="https://medium.com/u/cb0e4c9146d0">Manuel Mazuecos</a>.</p><h3>Conclusions</h3><p>There are a lot of <strong>incompatibilities </strong>that can be avoided with the previous changes.</p><p>How to <strong>open a session</strong> has been explained in the component tests too. It is agnostic of the testing framework.</p><p>The speed is a little bit <strong>faster</strong>. E.g. a test class using NUnit with 30 test, with a SQL Server Express database it takes 6.6–7 seconds and with an in-memory SQLite 3 it takes 5–5.2 seconds, so it could be around 40% less.</p><p>Another approach could be use a SQL Server, create a template database an attach a copy into a SGBD. It can be a local/remote instance, or a SQL Server Express or in a docker container. I would recommend this options for<strong> integration test</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ad07254685d2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/bestsecret-tech/in-memory-sqlite-for-testing-nhibernate-sql-server-ad07254685d2">In memory SQLite for testing NHibernate + SQL Server</a> was originally published in <a href="https://medium.com/bestsecret-tech">BESTSECRET Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>