code Quick Copy table structure with Dapper While working through a complicated SQL [https://en.wikipedia.org/wiki/SQL] series of steps I had the need to make a copy of an existing table, specifically in this case a temporary table to use for bulk loading. The into [https://www.postgresql.org/docs/9.1/sql-selectinto.html]
code Table Track Changes Audit - MS SQL Tracking the changes from a DELETE [https://www.zentut.com/sql-tutorial/sql-delete/] or UPDATE [https://www.zentut.com/sql-tutorial/sql-update/] statement at the table level by creating a compatible [audit].[TableToTrack] and then attaching an after DELETE, UPDATE [https://www.tutorialgateway.org/after-update-triggers-in-sql-server/] trigger [https://docs.microsoft.com/en-us/sql/
code MS SQL Batch Scripts To Run This batch [https://en.wikipedia.org/wiki/Batch_file] script is designed to run a series of sql [https://en.wikipedia.org/wiki/SQL] script files in default order of a directory. In this case this batch file called for example: run_scripts.bat Is in the same folder as
code Ghost 3.X Theme Override Fighting with the css [https://developer.mozilla.org/en-US/docs/Web/CSS] for override the main menu header bar. I want to display my custom google site search bar and this was working previously with my Ghost [https://github.com/TryGhost/Ghost] 2.X theme, but then 3.X changed
code Insert or Update (Upsert) logic Thinking through the case that if you know the key [https://en.wikipedia.org/wiki/Unique_key] beforehand through a deterministic [https://en.wikipedia.org/wiki/Deterministic_algorithm] process. Then MS SQL Server has a very handy builtin constraint that you can turn off so that you no longer have
code Search git commit history with grep When you want to search the actual commit contents in git [https://git-scm.com/docs] from the command line for a regular expression i.e. text you need to find * git rev-list --all [https://git-scm.com/docs/git-rev-list]: Search the entire git commit history * xargs [http://man7.org/linux/man-pages/
code Python 3 JSON Post Uses the https://httpbin.org /anything JSON echo service to demonstrate how to POST JSON encoded data to a URI, using the great requests [https://pypi.org/project/requests/] library * Have python3 [https://www.python.org/downloads/] installed on your machine * Install directly with pip3 [https://pip.pypa.io/en/
code NodeJS JSON Post Uses the https://httpbin.org /anything JSON echo service to demonstrate how to POST [https://en.wikipedia.org/wiki/POST_(HTTP)] JSON [https://www.json.org] encoded data to a URI. * Have nodejs [https://nodejs.org/en/] installed on your machine * Run the file or text interactively nodejs <file_
code Cleanup with git Common options when trying to reset your repository. * git remote prune origin : Remove merged branches * git reset --hard : Reset your branch changes back to the remote repository * git clean -fd : Remove all local changes that are unstage including untracked files and directories.
code Ghost fix SSL certificates manual I am currently self hosting this ghost [https://ghost.org/] blog and that means from time to time I need to perform maintenance and utility updates. Most of the time this is a hands off approach as ghost [https://ghost.org/] has a command line [https://ghost.org/docs/api/
code Run *.dacpac file command line Dacpac is a binary produced by a source controlled MS SQL database that will allow you to script and source control your database schemas. Automates the Data Definition Language [https://en.wikipedia.org/wiki/Data_definition_language] script creation and deployment through the use of either.WARNING the dacpac utilities
code Programming with times Was reading through the Fortran 77 specification for Astronomy [http://www.iausofa.org/2019_0722_F/Timescales.html] and the time/date stuff when dealing with non earth centric times is crazy. I already ask to always use UTC [https://en.wikipedia.org/wiki/Coordinated_Universal_Time] time now, but
code .NET Core 3.0 and Single Binaries .NET Core 3.0 allows for single binary distribution on applications in cleaner and easier way than before * Check your .NET Version firstdotnet --version Results 3.0.100 * Create a directory for your project mkdir native; cd native * Create a new project from the templates dotnet new console * Build and
code Custom .NET Headers Adding a custom header to instruct browsers on rendering directives (in this case Internet Explorer) In Classic .NET Do this <?xml version="1.0" encoding="utf-8"?> <configuration> <system.webServer> <httpProtocol> <customHeaders> <add name="X-UA-Compatible&
code C++ Type Helper Use const auto and auto when in local methods to allow for implicit type checking of variables while preserving static typing [https://en.wikipedia.org/wiki/Type_system] like the var [https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/var] keyword in C#. It will save you thought and
code MS SQL Parameterized Database Creation Security static code scanner was complaining that creation of a database with parameters was susceptible to SQL injection [https://www.owasp.org/index.php/SQL_Injection]. In theory this could be possible as the database creation script was a sql command run, the likelihood was low as the parameters were
code Encryption + Decryption extension methods Encryption/Decryption extension methods in C# for working with the abstract class of SymmetricAlgorithm
code Debian keeping packages current I use the following command to keep my packages up to date and clean sudo apt-get upgrade -y && sudo apt-get update -y && sudo apt-get autoremove -y && sudo apt-get autoclean -y apt-get [https://linux.die.net/man/8/apt-get] * upgrade: Some people reverse the order
code Copy/Paste Windows Subsystem for Linux Trying to copy some text out of the command line output from a Windows Subsystem for Linux [https://docs.microsoft.com/en-us/windows/wsl/install-win10] prompt. I am using Pengwin [https://github.com/WhitewaterFoundry/Pengwin] Debian variant as my WSL as well as I have a X410 [https://token2shell.com/
personal In solidarity with the Zapatista Movement Standing up for the right to be treated as a human being is a universal movement we should all embrace and strive for. > The world we want to transform has already been worked on by history and is largely hollow. We must nevertheless be inventive enough to change it
code Command aliases in Windows: Use doskey I wanted to add some aliases to the command prompt [https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/cmd] in Windows (not Powershell [https://docs.microsoft.com/en-us/powershell/]) * Create a doskey [https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/doskey] file, this is mine. Please note that all the
code Global PowerPlant Database - Extraction Wanted to get the latest list of all the electrical powerplants in the USA and thanks to the World Resources Institutes [http://datasets.wri.org] Global PowerPlant Database [http://datasets.wri.org/dataset/globalpowerplantdatabase] source. They do a great service in collecting and collating the various datasets available into a
code PowerShell - Stop Screen Locking This script stops screen locking by pressing the Scroll Lock key every 30 seconds on/off with SendKeys [https://ss64.com/vb/sendkeys.html] Clear-Host Echo "...Lock screen avoider..." $WShell = New-Object -com "Wscript.Shell" $sleep = 30 while ($true) { $WShell.sendkeys("{SCROLLLOCK}") Start-Sleep -Milliseconds 100
code PowerShell - Random Text Generator Wanted to try to generate a random text every so often to prevent screen locking which did not work and stumbled upon this [https://devblogs.microsoft.com/scripting/generate-random-letters-with-powershell/] and learned a couple of neat tricks from PowerShell. The actual solution that seems to work for preventing screen locking is
code Zip every subfolder in a folder I needed to zip every subfolder within a folder to it's own separate zip file. In Bash did a for loop to find each folder and then zip [https://www.howtoforge.com/linux-zip-command/] each folder. This is my oneliner to do it for i in */; do zip -r