Skip to content

Instantly share code, notes, and snippets.

View yoloroy's full-sized avatar

yoloroy

View GitHub Profile
using System;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
public class TitleInspectorDecorum : MonoBehaviour
{
#if UNITY_EDITOR
[SerializeField] private string text = "";
@yoloroy
yoloroy / Main.kt
Created October 15, 2023 10:04
GraphicsLab stl to my json format convertation
import java.io.File
import kotlin.io.path.Path
fun main(args: Array<String>) {
println("Write stl path file to convert: ")
val stlPath = readln()
val triangles = STLParser.parseSTLFile(Path(stlPath))
val (points, connections) = trianglesToPointsAndConnections(triangles)
val resultPath = "$stlPath.converted.json"
val state = """
@yoloroy
yoloroy / array.lua
Created May 21, 2023 14:30
lua class containing methods for functional data processing + small extension functions for std lua table library
--- table.insertAll
--- @generic T
--- @param a T[]
--- @param b T[]
function table.insertAll(a, b)
for _, v in pairs(b) do
table.insert(a, v)
end
end
@yoloroy
yoloroy / ListInput.kt
Last active September 7, 2022 20:42
ListInputComponent
package components
import androidx.compose.desktop.ui.tooling.preview.Preview
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.OutlinedTextField
@yoloroy
yoloroy / PatternStrategyExample.kt
Last active August 25, 2022 20:33
The story of how someone passed through the crossroad
import kotlin.properties.ReadOnlyProperty
import kotlin.reflect.KProperty
interface AnimatedSlide<in T, out Slide> : ReadOnlyProperty<T, Slide> {
val currentSlide: Slide
override fun getValue(thisRef: T, property: KProperty<*>) = currentSlide
class VarargImpl<in T, out Slide>(private vararg val slides: Slide) : AnimatedSlide<T, Slide> {
private var i = 0
#include "ArrayList.h"
#include <stdlib.h>
#include <string.h>
#define INITIAL_SIZE 10
struct ArrayListImpl {
struct List list;
void **values;
unsigned long size;
object Presenter { // presentation layer
fun loadDataForList() {
val dataToShow: List<UiDataShort> = DataStore.retrieveDataList()
}
fun loadDataForDetailedView(clickedData: UiDataShort) {
val dataToShow: UIDataDetailed = DataStore.getDetails(clickedData)
}
}
@yoloroy
yoloroy / InfiniteIterator.kt
Created June 22, 2022 13:56
Infinite iterator extension for Iterable
fun <T> Iterable<T>.infiniteIterator() = iterator {
while (true) yieldAll(this@infiniteIterator)
}
@yoloroy
yoloroy / FlexibleAdaptiveGridDsl.kt
Last active June 22, 2022 20:59
Grid layout for even distribution of items across rows if they can fit on that rows
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.defaultMinSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.width
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.Layout
@yoloroy
yoloroy / binaryTreeTraveral.kt
Last active April 20, 2022 06:34
solution for task of printing binary tree in all orders
package dates2.mar11.binaryTreeTraversal
fun main() {
val size = readLine()!!.toInt()
val pointers = Array(size) {
val (value, firstChildIndex, secondChildIndex) = readLine()!!
.split(" ")
.map(String::toInt)
Triple(value, firstChildIndex, secondChildIndex)