Skip to content

Instantly share code, notes, and snippets.

View fy0's full-sized avatar
🎲
thinking

fy fy0

🎲
thinking
View GitHub Profile
@fy0
fy0 / dict_witk_kv_pair.py
Last active April 17, 2021 13:45
pydantic `patternProperties` validator demo
"""
MIT License
Copyright (c) 2021 fy
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@Yanrishatum
Yanrishatum / hxsl-cheatsheet.md
Last active October 11, 2024 15:31
HXSL cheat-sheet

HXSL cheat-sheet

This is a WIP of a cheat-sheet that I will finish Eventually™

Types

Mapping of the shader types to Heaps types:

Float = Float
Int = Int
Bool = Bool
@laurivosandi
laurivosandi / esp32-oled-demo.py
Last active February 8, 2022 03:22
OLED screen demo on ESP32 with MicroPython
# Pull the SDD1306 lib from here https://github.com/adafruit/micropython-adafruit-ssd1306/blob/master/ssd1306.py
from time import sleep_ms
from machine import Pin, I2C
from ssd1306 import SSD1306_I2C
buf = "wubba lubba dub dub "
i2c = I2C(-1, Pin(4),Pin(5),freq=40000) # Bitbanged I2C bus
assert 60 in i2c.scan(), "No OLED display detected!"
// 程序启动器[win32]
// 一个小玩意,作用就是读取与 exe 同名的 .config 文件,并逐条并行执行,不显示窗口
// 以 # 打头的行忽略
// 用于开机挂载一些自带 cmd 窗口的程序
// 自用 vs2017 编译测试通过
// ver 1.1
// 一个新语法:@命令 可以等待此命令结束后再继续运行
// 例如 @ping 127.1 -n 3 等待3秒
@mochja
mochja / main.c
Last active September 25, 2023 15:08
Yoga + OpenGL Example
#include <GLFW/glfw3.h>
#include <yoga/Yoga.h>
#include <stdlib.h>
int main(void)
{
GLFWwindow* window;
/* Initialize the library */
if (!glfwInit())
@mickdekkers
mickdekkers / SnapshotCamera.cs
Last active August 27, 2024 03:23
Take snapshot images of Prefabs and GameObjects in Unity using Render Textures
using UnityEditor;
using UnityEngine;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
// Object rendering code based on Dave Carlile's "Create a GameObject Image Using Render Textures" post
// Link: http://crappycoding.com/2014/12/create-gameobject-image-using-render-textures/
@ideasman42
ideasman42 / fill_poly_v2i_n.c
Last active August 18, 2023 03:07
Raster poly-filling by Darel Rex Finley, optimized by Campbell Barton.
/* C99, public domain licensed */
#include <limits.h>
#include <stdbool.h>
#include <math.h>
/* utilities */
#define SWAP(type, a, b) do { \
type sw_ap; \
/*!
* The MIT License (MIT)
*
* Copyright (c) 2016 by Blake Bowen (http://codepen.io/osublake/pen/OyPGEo)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@0xKD
0xKD / gist:4433688
Last active August 26, 2022 09:29
DDA in Python
def ROUND(a):
return int(a + 0.5)
def drawDDA(x1,y1,x2,y2):
x,y = x1,y1
length = abs((x2-x1) if abs(x2-x1) > abs(y2-y1) else (y2-y1))
dx = (x2-x1)/float(length)
dy = (y2-y1)/float(length)
print 'x = %s, y = %s' % (((ROUND(x),ROUND(y))))
for i in range(length):