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/
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
code Manipulating JSON with Gron Poking around with curl trying to do things and found a nice supplemental tool Say you have curl https://api.weather.gov/points/32.7687,-97.3093 Gives you the big JSON response { "@context": [ "https://raw.githubusercontent.com/geojson/geojson-ld/master/contexts/geojson-base.jsonld", { "wx&
code Renaming a Git branch local+remote Rename your local branch * When you have the target branch checked out locally git branch -m desired_name * When you do not have the target branch checked out locally git branch -m wrong_name desired_name Delete the wrong_named remote branch and push the desired_name local branch git
code Read JSON with Powershell Get-Content -Raw -Path <my_json_file>.json | ConvertFrom-Json Syntax: $my_file = Get-Content -Raw -Path .\<my_json_file>.json | ConvertFrom-Json or to separate for piping further ( Get-Content -Raw -Path .\<my_json_file>.json | ConvertFrom-Json ) Example: Input JSON file { "fruit": "Apple", "
code Using Xargs to delete git history Needed to delete the .git history out of a folder and subfolders and thought xargs [http://man7.org/linux/man-pages/man1/xargs.1.html] would do what I needed to do. First find [http://man7.org/linux/man-pages/man1/find.1.html] all the relevant files using find * find . -type
code Treatise on code review * Code Review should default to approved, broken tests will stop the approval process * If new code has no tests you can ask for a test * Styling is optional. If styling is important to you don't make a comment, make a template or choose a language that forces a
code Reinstall Nuget packages without updating This situation comes up often enough that I need to look it up and write it down. Run this command from the Package Manager Console [https://docs.microsoft.com/en-us/nuget/tools/package-manager-console] Update-Package -reinstall -Project <YOUR PROJECT NAME> Or use the default selected Project and leave off
code Stop unresponsive processes Windows - Taskkill [https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/taskkill] In this case you have a non responsive msbuild that you can't find and want to terminate I would use the following command taskkill /f /im msbuild.exe /t which translates to kill all msbuild.exe
code Reset Branch: Git+{Your shell} Helpful reminder on how to reset a branch on all changes you have been doing PowerShell git reset --hard $(git rev-parse HEAD) Bash git reset --hard $(git rev-parse HEAD) Command Prompt (a lot more work) git rev-parse HEAD > last_sha.txt set /p last=<last_sha.txt git
code Mature Sustainable Operations From Toward a Maturity Model for Observability [https://www.honeycomb.io/blog/toward-a-maturity-model-for-observability/] * Quality Code * Predictable release * Managed debt * Operational Resiliency * User insight
code SQL Server UTC Date Functions Ran across some SQL statements that were using the expression SYSUTCDATETIME() [https://docs.microsoft.com/en-us/sql/t-sql/functions/sysutcdatetime-transact-sql?view=sql-server-2017] which is a statement I have not used and wanted to know the difference between this and my common go to statement of GETUTCDATE() [https://docs.microsoft.com/
code Every Nth item in a list Today I was asked a straightforward question on how would you get every 4th element from an array of numbers starting at 1 - 11 I immediately thought oh I can do this in a functional fluent manner, but then I flubbed it up because I tried to do a
code Set X11 Forwarding for all Users Setting the X Windows [https://token2shell.com/x410/] forwarding for your own personal user is usually set in the .profile file, but most of the time you really want to enable X Window [https://token2shell.com/x410/] forwarding for all users of the system. I mean you already went through
code List where Environment Variables are set Wanted to know where shell [https://en.wikipedia.org/wiki/Bash_(Unix_shell)] environment variables are being set on linux [https://www.debian.org/] and came across this helpful piece of scripting PS4='+$BASH_SOURCE> ' BASH_XTRACEFD=7 bash -xl 7>&2 Originally from StackOverflow
code Using Artillery to load test Doing user load testing with Artillery [https://artillery.io/] and finding it to be clean, useful, and fully featured [https://artillery.io/docs/cli-reference/] Install Artillery npm install artillery@latest -g Sample configuration file The following is a simple load test with the following parameters * Only 1 phase [https://artillery.
code Elevated Command Line Prompt Shortcut Use PowerShell to launch an elevated classic command line prompt Target C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command "Start-Process cmd -Verb RunAs" Start in C:\WINDOWS\System32\WindowsPowerShell\v1.0
code Lightning Talk - WSL in 5 minutes Windows Subsystem for Linux (WSL) A short and happy guide -------------------------------------------------------------------------------- What is Windows Subsystem for Linux? WSL is a collection of components that enables native Linux ELF64 [https://en.wikipedia.org/wiki/Executable_and_Linkable_Format] binaries to run on Windows. It contains both user mode and kernel mode
code Lightning Talk - .NET CLI in 5 Minutes Wrote this up after reading through Jeremy Miller' [https://jeremydmiller.com/]s article on .NET CLI [https://www.infoq.com/articles/netcore-cli] as a 5 minute lightning talk. -------------------------------------------------------------------------------- .NET Core Command Line Interface Can we be friends with it? -------------------------------------------------------------------------------- Test Setup * .NET Core installed 2.2 * Windows