Skip to content

Instantly share code, notes, and snippets.

View NikiforovAll's full-sized avatar
🇺🇦

Oleksii Nikiforov NikiforovAll

🇺🇦
View GitHub Profile
@richlander
richlander / modernizing-csharp9.md
Last active April 26, 2024 17:14
Modernizing a codebase for C# 9

Modernizing a codebase for C# 9

There are lots of cases that you can improve. The examples use nullable reference types, but only the WhenNotNull example requires it.

Use the property pattern to replace IsNullorEmpty

Consider adopting the new property pattern, wherever you use IsNullOrEmpty.

string? hello = "hello world";
@richlander
richlander / Program.cs
Last active October 12, 2023 17:02
Get Weather Forecast -- with records
using System;
using System.Net.Http;
using System.Net.Http.Json;
string serviceURL = "https://localhost:5001/WeatherForecast";
HttpClient client = new();
Forecast[] forecasts = await client.GetFromJsonAsync<Forecast[]>(serviceURL);
foreach(Forecast forecast in forecasts)
{
//Head+Tail for ROS<T>
static void Deconstruct<T>(this ReadOnlySpan<T> span, out T head, out ReadOnlySpan<T> tail)
{
switch (span.Length)
{
case 0:
head = default;
tail = default;
return;
case 1:
#CHECK THE PATH ON LINE 2 and the FEED on LINE 3
cd "C:\users\scott\Downloads"
$a = ([xml](new-object net.webclient).downloadstring("https://channel9.msdn.com/Series/CSharp-101/feed/mp4"))
$a.rss.channel.item | foreach{
$url = New-Object System.Uri($_.enclosure.url)
$file = $url.Segments[-1]
$file
if (!(test-path $file)) {
(New-Object System.Net.WebClient).DownloadFile($url, $file)
}
@bradtraversy
bradtraversy / vscode_shortcuts.md
Last active May 6, 2024 12:38
Helpful shortcuts for VSCode

VSCode Shortcuts

List of helpful shortcuts for faster coding

If you have any other helpful shortcuts, feel free to add in the comments of this gist :)

Official List of all commands

@natemcmaster
natemcmaster / README.md
Last active April 2, 2024 18:27
runtimeconfig.json schema

This defines the schema for .NET Core's runtimeconfig.json file.

Usage in an editor

Using Visual Studio, you can get auto-completion if you import the schema in your .JSON file like this:

{
  "$schema": "https://gist.githubusercontent.com/natemcmaster/0bdee16450f8ec1823f2c11af880ceeb/raw/runtimeconfig.template.schema.json"
}
@analogrelay
analogrelay / CommandLineException.cs
Last active March 22, 2024 11:50
My Command Line Template
using System;
using System.Runtime.Serialization;
namespace MyTool
{
[Serializable]
internal class CommandLineException : Exception
{
public CommandLineException()
{

Upload images to GitHub

  1. Create a new issue on GitHub.

  2. Drag an image into the comment field.

  3. Wait for the upload process to finish.

  4. Copy the URL and use it in your Markdown files on GitHub.

@wadewegner
wadewegner / devhub.sh
Created July 27, 2017 16:38
A bash script that uses the Salesforce CLI to determine if the org has the dev hub enabled
# specify your username or alias
usernameOrAlias="my@org.com"
# return a json result of
org="$(sfdx force:org:display -u ${usernameOrAlias} --json)"
# parse response
result="$(echo ${org} | jq -r .result)"
accessToken="$(echo ${result} | jq -r .accessToken)"
instanceUrl="$(echo ${result} | jq -r .instanceUrl)"
@ufcpp
ufcpp / Program.cs
Created October 28, 2016 03:33
index付きforeach
// 動作確認用
using System;
using System.Collections;
using System.Collections.Generic;
// ここの using 切り替えで、どの Indexed が呼ばれるかを切り替え
// 手元の環境だと以下の通り(GetTotalMemory の前後差分0が理想)
// A: 0
// B: 237568
// C: 720896