Skip to content

Instantly share code, notes, and snippets.

@ivanxpetrov
ivanxpetrov / private_fork.md
Created January 4, 2025 19:16 — forked from 0xjac/private_fork.md
Create a private fork of a public repository

The repository for the assignment is public and Github does not allow the creation of private forks for public repositories.

The correct way of creating a private frok by duplicating the repo is documented here.

For this assignment the commands are:

  1. Create a bare clone of the repository. (This is temporary and will be removed so just do it wherever.)

git clone --bare [email protected]:usi-systems/easytrace.git

@ivanxpetrov
ivanxpetrov / Fibers.cs
Created September 7, 2024 01:05 — forked from Horusiath/Fibers.cs
Minimal example of working async method builder
using System;
using System.Runtime.CompilerServices;
using System.Runtime.ExceptionServices;
using System.Threading;
namespace Fibers
{
public struct AsyncFiberMethodBuilder<T>
{
private Fiber<T>? fiber;
using System;
using System.Linq;
using System.Threading;
namespace TearDateTime
{
class Program
{
public const int ITERATIONS = 20000;
public const int MAX_THREADS = 30;

Memory<T> usage guidelines

This document describes the relationship between Memory<T> and its related classes (MemoryPool<T>, IMemoryOwner<T>, etc.). It also describes best practices when accepting Memory<T> instances in public API surface. Following these guidelines will help developers write clear, bug-free code.

First, a tour of the basic exchange types

  • Span<T> is the basic exchange type that represents contiguous buffers. These buffers may be backed by managed memory (such as T[] or System.String). They may also be backed by unmanaged memory (such as via stackalloc or a raw void*). The Span<T> type is not heapable, meaning that it cannot appear as a field in classes, and it cannot be used across yield or await boundaries.

  • Memory is a wrapper around an object that can generate a Span. For instance, Memory instances can be backed by T[], System.String (readonly), and even SafeHandle instances. Memory cannot be backed by "transient" unmanaged me

@ivanxpetrov
ivanxpetrov / ProcessWrapper.cs
Created June 11, 2020 09:54 — forked from corngood/ProcessWrapper.cs
C# Process wrapper
using System;
using System.Diagnostics;
using System.Linq;
static class Program {
static int Main(string[] args) {
var p = new ProcessStartInfo {
FileName = args[0],
// TODO: quote args
Arguments = String.Join(" ", args.Skip(1).ToArray()),
@ivanxpetrov
ivanxpetrov / business-models.md
Created February 2, 2019 23:30 — forked from ndarville/business-models.md
Business models based on the compiled list at http://news.ycombinator.com/item?id=4924647. I find the link very hard to browse, so I made a simple version in Markdown instead.

Business Models

Advertising

Models Examples
Display ads Yahoo!
Search ads Google
void Main()
{
// Write code to test your extensions here. Press F5 to compile and run.
}
public static class MyExtensions
{
// Write custom extension methods here. They will be available to all queries.
public static IEnumerable<T> Prepend<T>(this IEnumerable<T> sequence, T element) =>
new[] { element }.Concat(sequence);
System.Reflection.MethodBase.GetCurrentMethod().Name
//using System.Runtime.CompilerServices;
public void SendError(string Message, [CallerMemberName] string callerName = "")
{
Console.WriteLine(callerName + "called me.");
}
/*
RUN in LinqPad.
NUnitLite 3.2 depedency from NUget
A program that outputs the possible sequences of digits from 1 to 9 whose sum is 100.
e.g.
12-3-4+5-6+7+89
*/
void Main()
{
var list0 = new List<int>();
var list1 = new List<int>()
{
1
};
var list2 = new List<int>