Skip to content

Instantly share code, notes, and snippets.

View aodpi's full-sized avatar
🎯
Focusing

Valeriu Balan aodpi

🎯
Focusing
View GitHub Profile
@aodpi
aodpi / SecretSanta.cs
Created February 15, 2023 12:51
Algorithm to generate secret santa pairs in C#
public static Dictionary<string, string> AssignSecretSanta(List<string> participants)
{
// shuffle the participants randomly
Random rnd = new Random();
List<string> shuffled = participants.OrderBy(p => rnd.Next()).ToList();
// create a dictionary to store the assignments
Dictionary<string, string> assignments = new Dictionary<string, string>();
// assign each participant to the next one in the shuffled list
@aodpi
aodpi / calendar.cs
Last active November 28, 2022 18:49
Calendar testing
using System.Globalization;
namespace ConsoleApp9
{
internal class Program
{
private const int MAX_DAYS_WEEK = 7;
static void Main(string[] args)
{
@aodpi
aodpi / Sender.cs
Created December 23, 2018 16:31
Sender
using SecretSanta.Entities;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Mail;
using System.Text;
namespace SecretSanta.Website.Helpers
@aodpi
aodpi / ProgressStream.cs
Last active November 20, 2018 16:23
Progress Stream
using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
namespace ProgressStreamTest
{
/// <summary>
/// Stream that reports read progress
/// </summary>
@aodpi
aodpi / cqure.cs
Last active June 25, 2018 09:45
MovePath
using SkiaSharp;
using SkiaSharp.Views.Forms;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace CQure
@aodpi
aodpi / saddle.cs
Created April 16, 2018 11:16
Matrix saddle points
using System;
using System.Collections.Generic;
using System.Linq;
public class SaddlePoints
{
private int[,] array;
public SaddlePoints(int[,] values)
{
@aodpi
aodpi / ProgressStream.cs
Created March 9, 2018 14:22
A stream that reports progress (in %) when reading from it. Could be used to get upload progress to a website.
/// <summary>
/// Stream that reports read progress
/// </summary>
public class ProgressStream : Stream
{
/// <summary>
/// The progress will be reported in percent
/// when reading from the stream;
/// </summary>
private IProgress<double> _readProgress;
@aodpi
aodpi / single.json
Created November 28, 2017 21:18
SingleResult
{
"is_success": true,
"error_keys": [],
"result": {
"Name": "Deleted",
"Description": null,
"WorkflowId": "98778716-c2d5-451a-8f93-a2bcbf7a6e43",
"Workflow": null,
"Deadline": null,
"IsFinal": false,
@aodpi
aodpi / paginated.json
Created November 28, 2017 21:14
Paginated
{
"pagination": {
"total_count": 4,
"page": 0,
"page_size": 0,
"TotalPages": 0
},
"is_success": true,
"error_keys": [],
"result": [