Skip to content

Instantly share code, notes, and snippets.

View zehuac2's full-sized avatar

Zehua Chen zehuac2

View GitHub Profile
@zehuac2
zehuac2 / NoStoryboard.swift
Created July 26, 2022 17:08
AppKit app without storyboard
import AppKit
class ApplicationDelegate: NSObject, NSApplicationDelegate {
let window: NSWindow
override init() {
window = NSWindow(
contentRect: NSRect(x: 0, y: 0, width: 400, height: 300),
styleMask: [.closable, .resizable, .miniaturizable, .titled, .fullSizeContentView],
backing: .buffered, defer: true)
#include "stdafx.h"
LPWSTR classname = TEXT("Win32 Notepad");
HINSTANCE g_hInstance;
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdCommand, int nCmdShow)
{
g_hInstance = hinstance;
#include <iostream>
using std::cout;
using std::endl;
void print(size_t length) {
size_t i = length;
while (i > 0) {
i--;
namespace FastRemoveList
{
public class UObject
{
public int GetInstanceID() { return 0; }
}
public class FastRemovalListBase<T, K> where K : notnull
{
private List<(T, K)> _list = new List<(T, K)>();

Fonts

Best fonts for programming.

  • Jetbrains Mono
  • Cascadia
//
// RTTI (Reflection) the LLVM Way
// Source: https://llvm.org/docs/HowToSetUpLLVMStyleRTTI.html
//
#include <iostream>
using std::cout;
using std::endl;
@zehuac2
zehuac2 / Ruler.tsx
Last active November 19, 2020 22:51
React Slider
import React from "react";
import { css } from "@emotion/core";
import { Ticks } from "./Tick";
export interface RulerProps {
ticks: Ticks;
}
function Ruler(props: RulerProps): JSX.Element {
const { ticks } = props;
@zehuac2
zehuac2 / Unity Resources.md
Created November 1, 2020 06:55
Resources for Unity
// Assume LifeCycleManager is imported from a C header
struct LifeCycleManager {
var release: @convention (c) (_ ptr: UnsafeMutableRawPointer, _ context: UnsafeMutableRawPointer) -> Void
};
struct ComponentLifeCycleManager {
var lifeCycleManager: LifeCycleManager
var release: (_ ptr: UnsafeMutableRawPointer) -> Void
init<Component>(component: Component.Type) {