Skip to content

Instantly share code, notes, and snippets.

View evillegas92's full-sized avatar
💭
Senior Fullstack engineer at Polestar (.Net, React, AWS, GraphQL).

Esteban Villegas evillegas92

💭
Senior Fullstack engineer at Polestar (.Net, React, AWS, GraphQL).
View GitHub Profile
function* fibonacci() {
let prev = 0;
let next = 1;
yield prev;
yield next;
// Add previous and next and yield them forever
while (true) {
const newValue = next + prev;
@evillegas92
evillegas92 / Barista.ts
Created January 15, 2024 17:57
TypeScript OOP Polymorphism, Liskov Substitution Principle with Decorator Pattern
// POLYMORPHISM
// Liskov Substitution principle with composition and the Decorator Pattern
// source: https://blog.appsignal.com/2022/04/06/principles-of-object-oriented-programming-in-typescript.html
interface Coffee {
getCost(): number;
getIngredients(): string;
}
class SimpleCoffee implements Coffee {
getCost(): number {
public static class EnumerableExtensions
{
public static T WithMinimum<T, TKey>(this IEnumerable<T> sequence, Func<T, TKey> criterion)
where T: class
where TKey : IComparable<TKey> =>
sequence.Select(obj => Tuple.Create(obj, criterion(obJ)))
.Aggregate((Tuple<T, Tkey>)null,
(best, cur) => best == null || cur.Item2.CompareTo(best.Item2) < 0 ? cur : best)
.Item1;
}

Upload NuGet Package (.nupkg) to NuGet Feed with NuGet API v3 in C#

If you want to upload a NuGet package you downloaded, or maybe one you created yourself, to your company's NuGet feed, but that feed uses NuGet 3 instead of NuGet 2; fear no more. I will show you how to push that package to NuGet 3 feed in your app.

So in NuGet version 2, all you needed was to use the Nuget.Core package in your app, and with a few lines of code you could upload you're package to any version 2 feed. That is no longer the case in NuGet v3.

Below you will find a utility class that can download a NuGet package (given its id) and upload a NuGet package (given the .nupkg file) to NuGet v3 feed, using NuGet API v3: