Skip to content

Instantly share code, notes, and snippets.

View dcagnetta's full-sized avatar

Dillan Cagnetta dcagnetta

View GitHub Profile
@AnthonyGiretti
AnthonyGiretti / listpattern.cs
Created November 29, 2022 22:51
Example of C# 11 List pattern syntax on vowels and consonants arrays
namespace Csharp11Demo.Models;
string[] consonants = { "b", "d", "k", "l" };
string[] vowels = { "a", "e", "o", "l" };
consonants is ["b", "d", "k", "l" ]; // returns true
vowels is ["b", "d", "k", "l"]; // returns false
consonants is ["b", "d", "k"]; // returns false
consonants is [_, "d", "k", _]; // returns true
vowels is [.., "l"]; // returns true
@bradtraversy
bradtraversy / tailwind-webpack-setup.md
Last active June 16, 2024 17:28
Setup Webpack with Tailwind CSS

Webpack & Tailwind CSS Setup

Create your package.json

npm init -y

Create your src folder

Create a folder called src and add an empty index.js file. The code that webpack compiles goes in here including any Javascript modules and the main Tailwind file.

@davidfowl
davidfowl / .NET6Migration.md
Last active June 16, 2024 05:29
.NET 6 ASP.NET Core Migration
<link rel="shortcut icon" width=32px>
<canvas style="display: none" id="loader" width="16" height="16"></canvas>
<script>
class Loader {
constructor(link, canvas) {
this.link = link;
this.canvas = canvas;
this.context = canvas.getContext('2d');
this.context.lineWidth = 2;
@LayZeeDK
LayZeeDK / configuration.ts
Last active January 14, 2022 19:11
Providing a configuration as a static dependency.
import { InjectionToken } from '@angular/core';
// We create an interface for the configuration JSON object
export interface Configuration {
readonly apiUrl: string;
readonly timezone: string;
readonly websocketUrl: string;
}
// We use a dependency injection token to access the configuration
@litetex
litetex / Description.md
Last active March 2, 2024 03:12
Serilog (C#): How to get current MethodName, FileName/Path and LineNumber without reflection

Serilog (C#): How to get the current MethodName, FileName/Path and LineNumber without reflection

This is a simple setup for reflectionless logging with serilog using caller information (and a single static class).

See also https://stackoverflow.com/a/46905798

Log.cs

Create your own Log.cs in your Root-Namespace (you can use the class below).

This class is required to detect where the call is coming from; it uses Caller-Information to speed up the program execution, because the attributes are resolved at compile-time.

import {Injectable} from '@angular/core';
import {FlatTreeControl} from '@angular/cdk/tree';
import {CollectionViewer, SelectionChange} from '@angular/cdk/collections';
import {BehaviorSubject, merge, Observable} from 'rxjs';
import {map} from 'rxjs/operators';
/** Flat node with expandable and level information */
export class DynamicFlatNode<T> {
constructor(public item: T, public level: number = 1, public hasChildren: boolean = false, public isLoading: boolean = false) {}
@anthonny
anthonny / webpack.config.js
Created March 15, 2019 14:38
Use dotenv with NativeScript
// ...
const dotenv = require("dotenv");
// ...
console.log(`Bundling application for entryPath ${entryPath}...`);
dotenv.config()
const isUppercase = key => key.toUpperCase() === key;
const envKeys = Object.keys(env);
@LayZeeDK
LayZeeDK / angular-cli-node-js-typescript-rxjs-compatiblity-matrix.csv
Last active June 16, 2024 12:26
Angular CLI, Angular, Node.js, TypeScript, and RxJS version compatibility matrix. Officially part of the Angular documentation as of 2023-04-19 https://angular.io/guide/versions
Angular CLI version Angular version Node.js version TypeScript version RxJS version
~16.0.0 ~16.0.0 ^16.13.0 || ^18.10.0 >=4.9.5 <5.1.0 ^6.5.5 || ^7.4.0
~15.2.0 ~15.2.0 ^14.20.0 || ^16.13.0 || ^18.10.0 >=4.8.4 <5.0.0 ^6.5.5 || ^7.4.0
~15.1.0 ~15.1.0 ^14.20.0 || ^16.13.0 || ^18.10.0 >=4.8.4 <5.0.0 ^6.5.5 || ^7.4.0
~15.0.5 ~15.0.4 ^14.20.0 || ^16.13.0 || ^18.10.0 ~4.8.4 ^6.5.5 || ^7.4.0
~14.3.0 ~14.3.0 ^14.15.0 || ^16.10.0 >=4.6.4 <4.9.0 ^6.5.5 || ^7.4.0
~14.2.0 ~14.2.0 ^14.15.0 || ^16.10.0 >=4.6.4 <4.9.0 ^6.5.5 || ^7.4.0
~14.1.3 ~14.1.3 ^14.15.0 || ^16.10.0 >=4.6.4 <4.8.0 ^6.5.5 || ^7.4.0
~14.0.7 ~14.0.7 ^14.15.0 || ^16.10.0 >=4.6.4 <4.8.0 ^6.5.5 || ^7.4.0
~13.3.0 ~13.3.0 ^12.20.2 || ^14.15.0 || ^16.10.0 >=4.4.4 <4.7.0 ^6.5.5 || ^7.4.0
@OliverJAsh
OliverJAsh / foo.ts
Last active July 29, 2023 18:16
Records and dictionaries in TypeScript
/*
In JavaScript, objects can be used to serve various purposes.
To maximise our usage of the type system, we should assign different types to our objects depending
on the desired purpose.
In this blog post I will clarify two common purposes for objects known as records and dictionaries
(aka maps), and how they can both be used with regards to the type system.