Skip to content

Instantly share code, notes, and snippets.

@jonsagara
jonsagara / UnbufferedQuerySample.cs
Created September 12, 2023 21:46
Dapper unbuffered query
var sql = """
SELECT
*
FROM
Widgets
WHERE
AccountId = @AccountId
ORDER BY
SomeField
""";
@jonsagara
jonsagara / PluralsightCourses.txt
Created April 7, 2022 16:36
Getting started with ASP.NET Core MVC development
C#: Getting Started
https://app.pluralsight.com/library/courses/c-sharp-getting-started/table-of-contents
Building Web Applications with ASP.NET Core MVC
https://app.pluralsight.com/library/courses/building-aspdotnet-core-mvc-web-applications/table-of-contents
Entity Framework Core: Getting Started
https://app.pluralsight.com/library/courses/entity-framework-core-get-started/table-of-contents
Introduction to SQL Server
@jonsagara
jonsagara / HugoRSS.md
Created March 27, 2022 22:00
Adding RSS to my hugo site

In my config.toml file, I have this configuration that mentions RSS:

[outputs]
home = ["HTML", "RSS"]
page = ["HTML", "RSS"]

[outputFormats]
[outputFormats.RSS]
mediatype = "application/rss+xml"
@jonsagara
jonsagara / dotnet-core-uninstall.txt
Last active July 20, 2021 17:14
dotnet-core-uninstall commands for macOS
# List the installed SDKs and runtimes.
sudo ./dotnet-core-uninstall list
# Remove a specific runtime version without a confirmation prompt.
sudo ./dotnet-core-uninstall remove -y --runtime 3.1.10
# Remove a specific SDK version without a confirmation prompt.
sudo ./dotnet-core-uninstall remove -y --sdk 3.1.10
@jonsagara
jonsagara / elastic-gnaf.fsx
Created September 18, 2019 15:32 — forked from codebrain/elastic-gnaf.fsx
Building a realtime address search with the Australian G-NAF dataset
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
@jonsagara
jonsagara / macos_shell_commands.txt
Last active May 18, 2019 06:12
Create new F# .NET Core solution on macOS via CLI and using paket
# Create a solution and directory
dotnet new sln -o Test3
cd Test3
# Add an F# project to the solution file
dotnet new console -lang F# -o src/App
# Add the F# project to the solution file
dotnet sln add src/App/App.fsproj
@jonsagara
jonsagara / remove_bin_obj_nodemodules.bat
Last active April 16, 2019 22:10
Recursively remove bin, obj, packages, and node_modules directories
REM ===============================================================================================
REM Recursively remove bin, obj, packages, and node_modules directories.
REM ===============================================================================================
FOR /F "tokens=*" %%G IN ('DIR /B /AD /S bin') DO RMDIR /S /Q "%%G"
FOR /F "tokens=*" %%G IN ('DIR /B /AD /S obj') DO RMDIR /S /Q "%%G"
FOR /F "tokens=*" %%G IN ('DIR /B /AD /S packages') DO RMDIR /S /Q "%%G"
FOR /F "tokens=*" %%G IN ('DIR /B /AD /S node_modules') DO RMDIR /S /Q "%%G"
echo Done.
@jonsagara
jonsagara / start_elasticsearch.sh
Last active January 30, 2021 19:05
Start elasticsearch and kibana on macOS
#!/bin/bash
#
# Start elasticsearch in a new Terminal window.
#
echo "Starting elasticsearch in a new Terminal.app window..."
# See: https://stackoverflow.com/a/989357/731
osascript -e 'tell application "Terminal" to do script "~/Downloads/elasticsearch-7.10.2/bin/elasticsearch"'
@jonsagara
jonsagara / PwnedPasswords.cs
Last active October 19, 2023 11:09
C# Pwned Passwords helper
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
namespace Pwnage
{
public static class PwnedPasswords
@jonsagara
jonsagara / Program.cs
Last active February 1, 2018 17:09
How many Friday the 13ths occur in a year?
void Main()
{
var startYear = 2000;
var endYear = DateTime.UtcNow.Year;
var spookyYears = new List<(int year, int occurrences)>();
for (var ixYear = startYear; ixYear <= endYear; ixYear++)
{
var spookyDaysThisYear = 0;