Skip to content

Instantly share code, notes, and snippets.

View PureKrome's full-sized avatar
💭
🦘🕺🏻🎶🕹

Justin Adler PureKrome

💭
🦘🕺🏻🎶🕹
View GitHub Profile
@egil
egil / Program.cs
Last active December 18, 2024 14:03
Custom "Import database" and "Import BacPac" Aspire commands for a SQL Server Database resource. The first will create a bacpac from a source database and import that bacpac into the Aspire SQL Database resource. The latter will use an existing bacpac file and import that.
var builder = DistributedApplication.CreateBuilder(args);
var sqlPassword = builder.AddParameter("sql-password", secret: true);
var sqlserver = builder
.AddSqlServer("sqlserver", password: sqlPassword)
.WithDataVolume()
.WithLifetime(ContainerLifetime.Persistent);
var importSourceConnectionString = "Server=[REPLACE].database.windows.net;Authentication=Active Directory Interactive;Database=[REPLACE];Encrypt=True;"
var db = sqlserver
@PureKrome
PureKrome / Node-plus-Docker.md
Last active February 28, 2025 02:54
Running NPM inside a docker container

How to run some Node code in Docker because you're smart and don't want to have evil Node installed on your PC.

NODE DOCKER VERSIONS: https://hub.docker.com/_/node


docker run --rm -it -v ${PWD}:/src/someProject --name npm-stuff node /bin/bash
@davidfowl
davidfowl / MinimalAPIs.md
Last active March 16, 2025 16:47
Minimal APIs at a glance
@sixeyed
sixeyed / profile.ps1
Created November 1, 2018 11:25
PowerShell profile with a Linux-style prompt and aliases for common Docker commands
function Prompt(){
$W = Split-Path -leaf -path (Get-Location)
$prompt = Write-Prompt "$($env:UserName)@$($env:ComputerName):" -ForegroundColor Green
$prompt += Write-Prompt $W -ForegroundColor DarkCyan
$prompt += Write-Prompt '>'
return ' '
}
function Remove-StoppedContainers {
docker container rm $(docker container ls -q)
@frankradocaj
frankradocaj / DeltaHelper.cs
Created April 13, 2018 04:07
A helper to resolve the list of differences (delta) between two lists
public static class DeltaHelper
{
public static (IEnumerable<TItem> Left, IEnumerable<TItem> Both, IEnumerable<TItem> Right) Compute<TItem, TValue>(
IEnumerable<TItem> list1,
IEnumerable<TItem> list2,
Func<TItem, TValue> getItemValue)
where TValue : IEquatable<TValue>
{
var comparableList1 = list1.Select(x => new EqualityComparer<TItem, TValue>
{
@a3dho3yn
a3dho3yn / mongodb_c#_cheatsheet.md
Last active March 10, 2025 21:41
MongoDB C# Driver Cheat Sheet

MongoDB C# Driver Cheat Sheet

(C) 2015 by Derek Hunziker, (C) 2017 by AppsOn

As of releasing MongoDB 3.4 and C# Driver v2.4, original cheatsheet by Derek is outdated. In addition, it has some deficiencies like connecting to MongoDB, creating indexes, etc. This updated version works fine with C# Driver v2.4.7 and MongoDB v3.4.

Setup

Define Document Models

Note: Defined models and collections will be used in entire cheatsheet.

@davidfowl
davidfowl / Example1.cs
Last active September 2, 2024 12:36
How .NET Standard relates to .NET Platforms
namespace Analogy
{
/// <summary>
/// This example shows that a library that needs access to target .NET Standard 1.3
/// can only access APIs available in that .NET Standard. Even though similar the APIs exist on .NET
/// Framework 4.5, it implements a version of .NET Standard that isn't compatible with the library.
/// </summary>INetCoreApp10
class Example1
{
public void Net45Application(INetFramework45 platform)
@NickCraver
NickCraver / BotLovin.cs
Last active January 5, 2023 11:36
Some bot/crawler fun on Stack Overflow. 10 hours of fun, to be precise.
private static readonly string[] tenHoursOfFun =
{
"https://www.youtube.com/watch?v=wbby9coDRCk",
"https://www.youtube.com/watch?v=nb2evY0kmpQ",
"https://www.youtube.com/watch?v=eh7lp9umG2I",
"https://www.youtube.com/watch?v=z9Uz1icjwrM",
"https://www.youtube.com/watch?v=Sagg08DrO5U",
"https://www.youtube.com/watch?v=5XmjJvJTyx0",
"https://www.youtube.com/watch?v=IkdmOVejUlI",
"https://www.youtube.com/watch?v=jScuYd3_xdQ",
@thefringeninja
thefringeninja / Dude.cs
Created February 3, 2015 22:47
Raven Async and Tests
public class RavenTestBase {
Task<IDocumentStore> _createDocumentStore;
ctor() {
var source = new TaskCompletionSource<IDocumentStore>();
_createDocumentStore = source.Task;
Task.Run(async () => {
var store = InitializeDocumentStore();
@PureKrome
PureKrome / NuGetPackageAndPublish.ps1
Last active September 1, 2023 09:33
Powershell NuGet publish script
############################################################################
### ###
### NUGET PACKAGE and PUBLISH ###
### ###
############################################################################
param (