Skip to content

Instantly share code, notes, and snippets.

View Vake93's full-sized avatar

Vishvaka Ranasinghe Vake93

View GitHub Profile
@Vake93
Vake93 / FertilizerRatioFinder.cs
Last active July 7, 2022 03:42
Fertilizer Ratio Finder
using Models;
var slsSpecification = new Specification(C: 20.00f, N: 1.00f, P: 0.50f, K: 1.00f, Ca: 0.70f, Mg: 0.50f);
var pineapplePeel = new Sample(Name: "Pineapple Peel" , Seasonal: true , C: 59.43f, N: 0.80f, P: 0.21f, K: 2.00f, Ca: 0.39f, Mg: 0.23f);
var bananaStem = new Sample(Name: "Banana Stem" , Seasonal: false, C: 59.75f, N: 0.62f, P: 0.22f, K: 7.43f, Ca: 0.58f, Mg: 0.33f);
var bananaPeel = new Sample(Name: "Banana Peel" , Seasonal: false, C: 81.29f, N: 0.04f, P: 0.09f, K: 5.98f, Ca: 0.60f, Mg: 0.36f);
var breadfruit = new Sample(Name: "Breadfruit" , Seasonal: true , C: 82.36f, N: 1.06f, P: 0.06f, K: 1.58f, Ca: 1.12f, Mg: 0.25f);
var jackfruit = new Sample(Name: "Jackfruit" , Seasonal: true , C: 70.79f, N: 1.12f, P: 0.15f, K: 1.21f, Ca: 0.52f, Mg: 0.36f);
var tea = new Sample(Name: "Tea" , Seasonal: false, C: 86.04f, N: 3.14f, P: 0.13f, K: 0.38f, Ca: 0.76f, Mg: 0.38f);
@Vake93
Vake93 / index.html
Created March 8, 2022 06:46
Simple Drag and Drop Demo
<!DOCTYPE HTML>
<html>
<head>
<style>
#div1, #div2, #div3, #div4 {
float: left;
width: 100px;
height: 35px;
margin: 10px;
padding: 10px;
int x = Pipe<string>.Unit
| "Hello there..."
| (g => $"{g} General Kenobi")
| Console.WriteLine
| Pipe<string, int>.Select(s => s.Length)
| Console.WriteLine;
class Pipe<T>
{
public Pipe(T item)
@Vake93
Vake93 / DynamicMethod.cs
Created August 30, 2021 14:42
Dynamic Method Experiments
using System.Reflection.Emit;
var dynamicMethod = new DynamicMethod("MethodA", typeof(void), Array.Empty<Type>());
var methodIL = dynamicMethod.GetILGenerator();
methodIL.Emit(OpCodes.Newobj, typeof(Random).GetConstructor(Array.Empty<Type>())!);
methodIL.EmitCall(OpCodes.Call, typeof(Test).GetMethod(nameof(Test.MethodB))!, null);
methodIL.Emit(OpCodes.Ret);
dynamicMethod.Invoke(null, null);
@Vake93
Vake93 / UberQueue.cs
Created August 14, 2021 10:18
UberQueue
class UberQueue<T>
{
private readonly SemaphoreSlim _semaphore;
private readonly IAsyncQueue<T>[] _queues;
public UberQueue(IAsyncQueue<T>[] queues)
{
_semaphore = new SemaphoreSlim(1, 1);
_queues = queues;
}
@Vake93
Vake93 / TodoService
Created May 19, 2021 18:50
Simple Todo Service in Express.NET!
using System;
using System.Linq;
using System.Collections.Generic;
service "api/v1/todo" TodoService;
csharp
{
public record TodoItem(Guid Id, string Description);
@Vake93
Vake93 / ffmpeg.md
Created April 25, 2021 07:27 — forked from steven2358/ffmpeg.md
FFmpeg cheat sheet
@Vake93
Vake93 / Program.cs
Last active August 13, 2019 09:26
TailCallElimination
using System;
using System.Numerics;
using System.Reflection.Emit;
namespace TailCallElimination
{
public class Program
{
public static BigInteger Fibonacci(BigInteger n, BigInteger a, BigInteger b)
{
using System;
using System.Linq;
using System.Linq.Expressions;
namespace Extensions
{
public static class PredicateBuilder
{
public enum CombinationLogic
{