Skip to content

Instantly share code, notes, and snippets.

View FelixCCWork's full-sized avatar

Felix Strauß FelixCCWork

  • Robert Bosch GmbH
  • Germany, Ansbach
View GitHub Profile
@craigmccauley
craigmccauley / HtmlRenderer.cs
Created December 3, 2022 18:37
Renders Blazor Components and Razor Views into HTML
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.Encodings.Web;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Abstractions;
@decay88
decay88 / # Useful C# References.md
Created March 9, 2020 14:54
C# Useful References

Useful C# References

Guide to using OpenGL's GL.DebugMessageCallback()

When learning OpenGL, one of the most common sources of bugs you'll encounter is from performing OpenGL API calls with invalid arguments, performing them in the wrong order, or performing calls that assume some OpenGL state that differs from the actual state.

With most well-written C# APIs, you'd get an exception thrown the moment you do something you shouldn't. By default, this doesn't happen with OpenGL, but there are still ways to tell if there are errors:

The easy (but tedious) way

The common way to check for errors is to use GL.GetError() to check for errors, often with a helper method such as the following:

@supremeo
supremeo / scroll.css
Created May 27, 2019 02:05
CSS flexbox for horizontal scrolling navigation #flexbox
/*
[1]: Make a flex container so all our items align as necessary
[2]: Prevent items from wrapping
[3]: Automatic overflow means a scroll bar won’t be present if it isn’t needed
[4]: Make it smooth scrolling on iOS devices
[5]: Hide the ugly scrollbars in Edge until the scrollable area is hovered
[6]: Hide the scroll bar in WebKit browsers
*/
.scroll {
display: flex; /* [1] */
public interface IPromiseCallbackHandler
{
void SetResult(string json);
void SetError(string error);
}
@AlexanderBaggett
AlexanderBaggett / gist:d1504da93727a1778e8b5b3453946fc1
Last active October 15, 2024 08:56
Full win32 window from C# with Pinvoke
In this post, .net platform has this pinvoke mechanism where it is allowed that you call into the Native windows .
this is extremely useful when you have some 3rd party libraries or if you try to program against with the low-level windows APIS.
One of the typic application htat utilize the Lowe-level windows apis are those Native win32 applications. Where you creat a message pump with the necessary WNDCLASSEX to represent/register the window message pump and message handler process. What you will deal with the win32 applications include the following.
RegisterClassEx, CreateWindowEx, GetMessage(), TranslateMesage(), and DispatchMessage(...).
to be able to use the Window API, you have to declare tons of Structure and PInvoke Method, while you can find help from the Pinvoke.Net.
First, we will introduce some of the win32/user32 functions and their relative structure definitions.
@ayende
ayende / LetsEncryptClient.cs
Created January 11, 2018 22:26
ACME v2 client for Let's Encrypt
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@darkguy2008
darkguy2008 / UDPSocket.cs
Last active December 19, 2025 07:51
Simple C# UDP server/client in 56 lines
using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
namespace UDP
{
public class UDPSocket
{
private Socket _socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);