Skip to content

Instantly share code, notes, and snippets.

View R2D221's full-sized avatar
🤔
Pondering

Arturo Torres Sánchez R2D221

🤔
Pondering
View GitHub Profile
@Petrusion
Petrusion / Parser.cs
Last active April 26, 2022 00:28
Quickly thrown together Interpolated String Handler based Parser
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace ParserTest;
public static class Parser
{
[InterpolatedStringHandler]
[StructLayout(LayoutKind.Auto)]
@akarpov89
akarpov89 / InterpolatedParsing.cs
Created October 1, 2021 14:58
Interpolated parsing technique
using System.Runtime.CompilerServices;
using static ParsingExtensions;
string input = "Name: Andrew; Age: 31";
string? name = null;
int age = 0;
if (input.TryParse($"Name: {Placeholder(ref name)}; Age: {Placeholder(ref age)}"))
{
@byme8
byme8 / DuckInterface.md
Last active January 5, 2021 09:27
DuckInterface

DuckInterface

I was playing with new .Net 5 and the Source Generator lately and got an idea that it is possible to add "duck typing" support to C#. I would say it is purely academic(no one will use it in production I hope), but it is fun stuff so I decided to try.

The nuget package with results you can find here

Nuget

The repository is here: https://github.com/byme8/DuckInterface

@dotcomboom
dotcomboom / Donkey Konga 2 Chart.RTrackTemplate
Last active October 18, 2022 04:04
Donkey Konga 2 Modding Guide
<TRACK
NAME Chart
PEAKCOL 32559202
BEAT -1
AUTOMODE 0
VOLPAN 0.4316101837015 0 -1 -1 1
MUTESOLO 0 0 0
IPHASE 0
PLAYOFFS 0 1
ISBUS 1 1
@dsyme
dsyme / rant.md
Last active December 31, 2022 05:54
@Jason5Lee
Jason5Lee / async-await-no-stackoverflow.md
Last active October 29, 2023 11:11
Using async/await to avoid stack overflow error.

Inspired by elizarov/DeepRecursiveFunction.kt.

Normally, when recursively evaluating the depth of a deep tree, it will result in stack overflow error. But, by using async/await, it keeps its stack on the heap, and evaluates correct result without error.

C#

public static class Program
{
@pmunin
pmunin / WeakMapExtensions.cs
Created August 5, 2019 16:52
WeakMapExtensions
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
namespace WeakMap
{
/// <summary>
/// Allows to link additional properties to any objects by weakly linking a dictionary for any object.
/// Weakly means the dictionary exists in memory only as long as object it linked to is still stored in memory
#!/usr/bin/env python3
#
# Test script to convert between xtilt/ytilt (Qt, Windows) and azimuth/altitude (iOS)
# Free to use for any purpose
import math
import secrets
# [azimuthRad, altitudeRad] => [tiltXrad, tiltYrad]
# azimuth in [0, 2*pi] range, altitude in [0, pi/2]
setTimeout(function() {
function getAllModules() {
return new Promise((resolve) => {
const id = _.uniqueId("fakeModule_");
window["webpackJsonp"](
[],
{
[id]: function(module, exports, __webpack_require__) {
resolve(__webpack_require__.c);
}
@ufcpp
ufcpp / CovariantClass.cs
Created September 28, 2017 01:47
道を踏み外すかどうかの瀬戸際な共変アップキャスト
using System;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
interface ICovariant<T> // Task<T> とか (bool, T) を含むので out は付けれない
where T : class
{
T A();
Task<T> B();
(bool, T) C();