Skip to content

Instantly share code, notes, and snippets.

View fredeil's full-sized avatar
🤔

Fredrik Eilertsen fredeil

🤔
View GitHub Profile
@fredeil
fredeil / main.cs
Created June 26, 2024 11:18
UDP broadcast connection suite server
var port = 4539;
var client = new System.Net.Sockets.UdpClient();
var ip = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("10.0.104.255"), port);
var bytes = System.Text.Encoding.ASCII.GetBytes("HelpINeedDatabaseConfigPlease🫡🫡");
_ = client.Send(bytes, bytes.Length, ip);
var result = await client.ReceiveAsync();
@fredeil
fredeil / Program.cs
Last active June 20, 2020 10:50
Cleaning up orphaned chunks in GridFS
using MongoDB.Bson;
using MongoDB.Driver;
using Serilog;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
namespace Mongo
@fredeil
fredeil / README.md
Created March 29, 2020 20:28
GitHub action for versioning your repository using NBGV

Simple versioning of your repository

Using NBGV to tag your master branch on push.

using System;
public class Program
{
public static int[] Reverse(int[] values)
{
int N = values.Length;
for (var i = 0; i < N; i++)
{
values[i] = values[N-i];
@fredeil
fredeil / mongodb_c#_cheatsheet.md
Created January 3, 2020 07:41 — forked from a3dho3yn/mongodb_c#_cheatsheet.md
MongoDB C# Driver Cheat Sheet

MongoDB C# Driver Cheat Sheet

(C) 2015 by Derek Hunziker, (C) 2017 by AppsOn

As of releasing MongoDB 3.4 and C# Driver v2.4, original cheatsheet by Derek is outdated. In addition, it has some deficiencies like connecting to MongoDB, creating indexes, etc. This updated version works fine with C# Driver v2.4.7 and MongoDB v3.4.

Setup

Define Document Models

Note: Defined models and collections will be used in entire cheatsheet.

using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
namespace Test
{
public class AsyncProgress<T> : IProgress<T>
{
module Kalkis
open System.Threading.Tasks
type Operation = Add | Sub | Mul | Div | Pow
and Calculator =
| Value of double
| Expr of Operation * Calculator * Calculator
@fredeil
fredeil / spam_http_post.go
Last active January 28, 2019 09:49
Endlessly spam random bytes over HTTP POST to a server
package main
import (
"math/rand"
"fmt"
"time"
"strings"
"net/http"
)
const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
@fredeil
fredeil / rxtpl.cs
Created January 25, 2019 08:55 — forked from valm/TPL DataFlow and Reactive Extensions Examples
TPL DataFlow and Reactive Extensions Example
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Reactive.Linq;
using System.Text;
using System.Threading;
@fredeil
fredeil / Benchmark.cs
Last active November 19, 2018 10:05
Benchmarking parsing of Guids in .NET Core using BenchmarkDotNet
using System;
using System.Collections.Generic;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using Util;
namespace Benchmarking
{
[MemoryDiagnoser, CoreJob]
public class ExtractClaimsBenchmarks