Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NAudio" Version="1.10.0" />
@VisualMelon
VisualMelon / NoTransition_snip.cs
Created August 27, 2022 09:33
Avalonia immediate transition
public class NoTransition : IPageTransition
{
public Task Start(Visual from, Visual to, bool forward, CancellationToken cancellationToken)
{
if (from is not null)
{
from.IsVisible = false;
}
if (to is not null)
using System;
using System.Text;
using System.Threading.Tasks;
using System.Net.Sockets;
namespace NetTest
{
    class Program
    {
        static void Main(string[] args)
// this would be a shape/concept/whatever, not an interfae
interface ICommutativeOrdinalThing<T>
{
/// <summary>
/// Commutative addition of things
/// </summary>
T Add(T a, T b); // with proposal, might pick up +
/// <summary>
/// Comparision of the strictly orderable things
public static Rectangle GetBrightestRectangle(this Bitmap bitmap, int width, int height)
{
// Each rectangle's value is its average pixel color.
var rectangles = new Dictionary<Rectangle, float>();
// Iterate through all possible rectangle points.
for (var x = 0; x < bitmap.Width - width; x++)
for (var y = 0; y < bitmap.Height - height; y++)
{
var brightnesses = new List<float>();
var model = new PlotModel { Title = "PNG Rendering" };
model.Axes.Add(new LinearAxis { Position = AxisPosition.Left });
model.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom });
model.Series.Add(new FunctionSeries(x => x * x, 0, 1, 1000));
// export as PNG
var pngExporter = new OxyPlot.WindowsForms.PngExporter();
using (var fs = System.IO.File.Open("test.png", System.IO.FileMode.Create))
@VisualMelon
VisualMelon / testing.cs
Last active September 20, 2017 17:05
SVG Text Rendering Testing
var model = new PlotModel { Title = "SVG Text Rendering" };
model.Axes.Add(new LinearAxis { Position = AxisPosition.Left });
model.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom });
model.Annotations.Add(new OxyPlot.Annotations.TextAnnotation()
{
    Text = "A",
    TextPosition = new DataPoint(10, 80),
    TextVerticalAlignment = VerticalAlignment.Bottom,
});
Required Effort: 108
Probability of Success: 0.37527553125
Step Right
Step Right
Step Right
Step Right
Drop
Drop
Step Right
Step Right
@VisualMelon
VisualMelon / chrisstrap.ps1
Last active May 7, 2017 23:07
Chris: Office Escape Testing
# Can used with test.ps1
# > . .\test.ps1 chrisstrap.ps1
# Expects perl (5) to be installed, and chris.pl to be in the current directory
#
# You can investigate issues by first writing the solution to a file...
# > type .\testcase0.txt | . .\chrisstrap.ps1 > chrissol0.txt
# ... and then feeding it to OfficeEscapeSolver.exe
# > type .\testcase0.txt | . .\OfficeEscapeSolver.exe * .\chrissol0.txt
# Which will (hopefully) provide helpful information
@VisualMelon
VisualMelon / OfficeEscapeSolver.cs
Last active May 7, 2017 19:27
OfficeEscapeSolver, Action file, Test Cases, and PowerShell Test Script
using System;
using System.Collections.Generic;
using System.Linq;
namespace OfficeEscapeSolver
{
public struct Vector
{
public static Vector Zero = new Vector(0, 0);