Skip to content

Instantly share code, notes, and snippets.

// License Public Domain - miyu on Github
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.CompilerServices;
namespace Dargon.Commons.Collections {
public struct EnumeratorToEnumerableAdapter<TItem, TEnumerator> : IEnumerable<TItem> where TEnumerator : struct, IEnumerator<TItem> {
@miyu
miyu / index.html
Last active October 22, 2021 05:04
Trivial HTML5 Masonry Layout (Public Domain)
<!DOCTYPE>
<!--
Public Domain from https://github.com/miyu
The output looks something like https://imgur.com/a/dGaHxaK (randomized images)
-->
<html>
<head>
<style>
html {
padding:0;
@miyu
miyu / 00 Readme
Last active August 26, 2021 22:45
PAX West 2021 Schedule Table Dumper
Run the first script in console at a page like https://west.paxsite.com/en-us/schedule.html
Then run the second script a split second later (the first script makes asynchronous calls that are pretty fast).
You might need to update the API key in 'https://api-melupufoagt.stackpathdns.com/api/schedules?key=6f51c8aa-c4cd-4391-900c-ed9e1b1e6ad8&id='+eventId
Simply visit a page like https://west.paxsite.com/content/sitebuilder/rna/pax/west/en-us/schedule/panel-information.html?gtID=746173&panel-name=PAX-Arena-Preshow view the API request in chrome inspector, and reuse that key.
The second script dumps a table to the bottom of the document, which you can copy-paste into gdocs (click and drag from the start of the first table to the end of the document, copy, paste to gdocs)
If something breaks or you improve this and want to update the document at https://docs.google.com/document/d/1QLp2hcfH_Si8-01bkFifMU-3lYEF2FrOOWj3L0nPkB4/edit#
Contact me! https://www.reddit.com/user/itzwarty https://twitter.com/ItzWarty War
@miyu
miyu / formatted_transpilation_wip.cpp
Created April 13, 2020 09:04
Luna 2020/04/03 Types to Structs, Baked Array Len
Dargon_Luna_Demos_DiffuseShader___FragmentInput Dargon_Luna_Demos_DiffuseShader___Vert(inout Dargon_Luna_Demos_DiffuseShader self, Dargon_Luna_Demos_DiffuseShader___VertexInput i) {
Dargon_Luna_Demos_DiffuseShader___FragmentInput o = {};
o.position = Dargon_Luna_Lang_Shader___ObjectToClipPosition(self, i.vertex);
o.normalWorld = Dargon_Luna_Lang_Shader___ObjectToWorldNormal(self, i.normal);
o.color = i.color;
Dargon_Luna_Lang_float4 dummy = {};
return o;
}
Dargon_Luna_Lang_float4 Dargon_Luna_Lang_Shader___ObjectToClipPosition(inout Dargon_Luna_Lang_Shader self, Dargon_Luna_Lang_float4 v) {
@miyu
miyu / program.cs
Created February 25, 2020 07:42
Set folder creation/modified date to oldest or newest file
// Just paste this into linqpad and run
var dir = @"C:\my-pictures";
foreach (var cd in Directory.GetDirectories(dir)) {
DateTime? lwt = null;
foreach (var f in Directory.GetFiles(cd)) {
var x = new FileInfo(f).LastWriteTime;
if (lwt == null) lwt = x;
else if (x < lwt) lwt = x; // < oldest file, > newest file
}
if (lwt != null) {
@miyu
miyu / Quadxels.cs
Last active February 15, 2020 07:04
Irregular quad grid
using System;
using System.Collections.Generic;
using System.Linq;
using Dargon.Commons;
using UnityEngine;
using Random = System.Random;
public class Quadxels : MonoBehaviour {
[SerializeField] private Material lineRendererMaterial;
// 1a:
$("pre").innerText.trim().split('\n').map(x => ~~(~~x/3)-2).reduce((a, b) => a+b, 0)
// 1b:
fuel = (x) => { var f = ~~(~~x/3)-2; return f <= 0 ? 0 : f + fuel(f); }
$("pre").innerText.trim().split('\n').map(fuel).reduce((a, b) => a+b, 0)
// 2a
exec = (ops) => {
for (var ip = 0; ip < ops.length; ip += 4) {
var op = ops[ip], a0 = ops[ip + 1], a1 = ops[ip + 2], a2 = ops[ip + 3];
my little...
MSG THINGY!!!
I am learning c# out of a book so heres my first application..
its really basic.. yet it takes a LOT of instructions...
---------------
source code!
---------------
using System;
using System.Collections.Generic;
@miyu
miyu / additional
Created June 2, 2018 08:18
Stream Panels
# My Incomplete Blog
I highly recommend skimming my incomplete [Building a 2D RTS Terrain Engine](https://miyu.gg/blog/building-2d-rts-terrain-engine) - it'll give you the background necessary to follow my stream or roll your own 2D RTS. 😃
# Source Code + Twitter
- [OpenMOBA on GitHub](https://github.com/miyu/OpenMOBA)
- [@WartyTheNerd on Twitter](https://twitter.com/WartyTheNerd)
# Additional Background Reading
- Piano Mover's Problem (PMP)
@miyu
miyu / FMatrix.cs
Last active May 24, 2018 07:55
System.Numerics.Matrix4x4 is not vectorized.
using System;
using System.Globalization;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Microsoft.CodeAnalysis;
using static System.Numerics.Vector4;
namespace MatrixMultiplicationPerformanceBenchmark {
[StructLayout(LayoutKind.Sequential, Pack = 4)]