Skip to content

Instantly share code, notes, and snippets.

View loic-sharma's full-sized avatar

Loïc Sharma loic-sharma

View GitHub Profile
@loic-sharma
loic-sharma / main.dart
Last active June 28, 2022 23:56
dart:ui app that renders text containing a tab and saves it as a PNG to disk
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This example shows how to use the ui.Canvas interface to draw various shapes
// with gradients and transforms.
//import 'dart:io';
import 'dart:typed_data';
import 'dart:ui' as ui;
@loic-sharma
loic-sharma / Function1.cs
Created October 1, 2021 22:41
AzFuncLogging
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Http;
using Microsoft.Extensions.Logging;
using System.Net;
namespace AzFuncLogging
{
public class Function1
{
private readonly ILogger<Function1> _logger;
@loic-sharma
loic-sharma / import.ps1
Created September 13, 2021 20:20
Import NuGet packages to a new BaGet instance
$destination = "<BaGet package source>"
# Uncomment this line if you've configured BaGet to require an API key
# & nuget.exe setapikey "MY-API-KEY" -Source $destination
$packages = Get-ChildItem -Path .\ -Filter *.nupkg -Recurse -File
$packages |% {
& nuget.exe push -Source $destination $_.FullName
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure.Storage.Blobs" Version="12.9.0" />
<PackageReference Include="NuGet.Packaging" Version="5.9.1" />
@loic-sharma
loic-sharma / 1 - Ideal.cs
Last active April 4, 2021 01:15
The case for async dependency injection
public class MyApp {
private IPackageDownloadClient _nuget;
public MyApp(IPackageDownloadClient nuget) {
_nuget = nuget;
}
public RunAsync() {
// This is the code I want to write.
// The NuGet package download client is injected into my application.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="5.0.0" />
</ItemGroup>
using System;
using System.IO;
using System.IO.Compression;
using System.Net.Http;
using System.Threading.Tasks;
namespace ConsoleApp2
{
class Program
{
@loic-sharma
loic-sharma / ConsoleApp17.csproj
Last active January 22, 2020 19:27
Get the download count for all versions of a package
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NuGet.Protocol" Version="5.5.0-preview.1.6319" />
@loic-sharma
loic-sharma / ConsoleApp17.csproj
Last active January 22, 2020 18:13
Get the download count for all versions of a package
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NuGet.Protocol" Version="5.5.0-preview.1.6319" />
</ItemGroup>
@loic-sharma
loic-sharma / Program.cs
Last active September 11, 2019 06:47
Improving NuGetVersion parse performance
using System;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{