Skip to content

Instantly share code, notes, and snippets.

View lnaie's full-sized avatar
🏠

Lucian Naie lnaie

🏠
View GitHub Profile
using System;
using System.Threading.Tasks;
namespace System.Collections.Concurrent
{
public static class ConcurrentDictionaryExtensions
{
/// <summary>
/// Provides an alternative to <see cref="ConcurrentDictionary{TKey, TValue}.GetOrAdd(TKey, Func{TKey, TValue})"/> that disposes values that implement <see cref="IDisposable"/>.
/// </summary>
@saschwarz
saschwarz / commands.js
Last active August 31, 2022 07:16
Automated Azure AD login and session token capture to json file for reading by Cypress commands. Heavily inspired by https://gist.github.com/pieterdv/82773fbe036719479d76ab0a4985dc3b
const API = Cypress.env('API');
const headers = {
Authorization: '',
};
Cypress.Commands.add('loginUser', () => {
return cy.readFile('aad-tokens.json')
.then(creds => {
// set auth headers so test setup calls are authorized
@pieterdv
pieterdv / get-aad-token.js
Created May 30, 2018 12:01
Login through Azure AD with puppeteer
function getAadToken(user, password, identifier) {
return puppeteer.launch({ headless: true }).then(async browser => {
try {
const page = await browser.newPage();
await page.goto("SITEURL");
await page.click(
"LOGINBUTTON"
);
@shanselman
shanselman / aspnetcore.yml
Created October 31, 2017 17:00
Basic ASP.NET Core YAML
---
apiVersion: v1
kind: Service
metadata:
name: aspnetcoreapp
labels:
app: aspnetcoreapp
spec:
type: NodePort
ports:
@shanselman
shanselman / Dockerfile
Last active November 10, 2023 19:17
Smarter ASP.NET Core Docker File
FROM microsoft/dotnet:2.0-sdk as builder
RUN mkdir -p /root/src/app/aspnetcoreapp
WORKDIR /root/src/app/aspnetcoreapp
#copy just the project file over
# this prevents additional extraneous restores
# and allows us to resuse the intermediate layer
# This only happens again if we change the csproj.
# This means WAY faster builds!
@therightstuff
therightstuff / RSAKeys.cs
Last active November 3, 2023 16:34
Import and export RSA Keys between C# and PEM format using BouncyCastle
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.OpenSsl;
using Org.BouncyCastle.Security;
using System;
using System.IO;
using System.Security.Cryptography;
namespace MyProject.Data.Encryption
{
@alexellis
alexellis / k8s-pi.md
Last active April 11, 2024 14:17
K8s on Raspbian
@lnaie
lnaie / Database.cs
Created July 29, 2017 20:52 — forked from matpag/Database.cs
Xamarin Forms SQLite database upgrade strategy
using ProjectTest.MyModels;
using SQLite.Net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace ProjectTest.Database
@a3dho3yn
a3dho3yn / mongodb_c#_cheatsheet.md
Last active March 27, 2024 00:04
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.

@cknaap
cknaap / SimpleLogCheck.cs
Last active December 17, 2021 22:11
Easily check ILogger<T> interactions with ASP.NET Core Logging and Moq
using Microsoft.Extensions.Logging;
using Moq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Xunit;
namespace Knaap.Utilties
{