Skip to content

Instantly share code, notes, and snippets.

View Yoticc's full-sized avatar
💭
C# C# C# C# C# C# C# C# C# C# C# C# C# C# C# C# C# C# C# C# C# C# C# C# C# C# C#

Yotic Yoticc

💭
C# C# C# C# C# C# C# C# C# C# C# C# C# C# C# C# C# C# C# C# C# C# C# C# C# C# C#
  • Russia
View GitHub Profile
@Yoticc
Yoticc / Program.cs
Created February 25, 2024 20:12
Output "I am a god" in strange way
using static System.Linq.Enumerable;
using static System.Console;
using static System.String;
using static System.IO.Path;
Write(Join('\n',Range(0,4).Select(i=>Concat(((long[])[0xF0449,0x420,0x8FE2E1441,0x8356AF71C4D,0x420,0x8FE2E1441,0x420,0x7642E1447,0x7A185E184F,0x7C62F1444]).SelectMany(n=>(char[])[..Range(0,(byte)(n>>8)/4).Select(o=>(((int)(n>>16)>>(o+(byte)(n>>8)/4*i))&1)==1?(char)(byte)n:' '),' '])))));
@Yoticc
Yoticc / Code.cs
Last active November 26, 2023 16:27
Dnlib: Add custom attribute UnmanagedCallersOnly. How to add array field argument in CutsomAttribute.
var attbr = new CustomAttribute(module.Import(/*Ctor of UnmanagedCallersOnlyAttribute*/));
attbr.NamedArguments.Add(new(true, module.CorLibTypes.String, "EntryPoint", new(module.CorLibTypes.String, /*entrypoint name, just string*/)));
attbr.NamedArguments.Add(new(true, /*System.Type[] TypeSig*/, "CallConvs", new(/*System.Type[] TypeSig*/, /*CallConv types, just Type[]*/.Select(t => new CAArgument(/*System.Type TypeSig*/, module.ImportAsTypeSig(t))).ToList())));
@Yoticc
Yoticc / FreopenInCSharp
Created October 11, 2023 12:31
C# alternative for "freopen("CONIN$")"
void Main()
{
AllocConsole();
SetupIn();
SetupOut();
Console.WriteLine("Output something");
var input = Console.ReadLine();
}
@Yoticc
Yoticc / WAVWriter
Created August 29, 2023 07:23
WAVWriter
using System.Runtime.InteropServices;
/* Example start */
var data = new short[240000];
for (var i = 0; i < data.Length; i++)
data[i] = (short)((i % short.MaxValue) * 20);
var path = @"C:\a.wav";
var bytes = WAV.GetBytes(ChannelType.Mono, 44000, data);