Skip to content

Instantly share code, notes, and snippets.

View Frityet's full-sized avatar
😁
I have like 60 projects that i am not doing

Frityet

😁
I have like 60 projects that i am not doing
View GitHub Profile
@Frityet
Frityet / CArray.h
Last active March 30, 2024 20:23
Objective C Carray
#import <ObjFW/ObjFW.h>
OF_ASSUME_NONNULL_BEGIN
#define $_concat(a, b) a##b
#define $concat(...) $_concat(__VA_ARGS__)
#if !defined($carray_name)
# define $carray_name(T) $concat(T, Array)
@Frityet
Frityet / README.md
Last active March 9, 2024 08:02
Installing Lua (and wlua!) + Luarocks on native Windows (not WSL)

Installing Lua (and wlua!) + Luarocks on native Windows (not WSL)

This guide will go through the FULL process of installing Lua + MinGW + Luarocks on native Windows. This guide is for those who want to use Lua on Windows without WSL and want everything to work well. By the way, it would be greatly appreciated if anyone wants to make a script that does all of this.

Windows versions

I am only targeting Windows 10/11 in this tutorial, specifically ucrt. If you are using Windows 10/11, ignore this. If you use a different version, you will probably be using msvcrt, so you can skip the steps where I switch Luarocks to ucrt.

Step 1: MinGW

// tic tac toe in F#
open System
module TicTacToe =
type Player = X | O
type Cell = Empty | Checked of Player
type Board = Cell list list
let cellToString cell =
match cell with
local ffi = require("ffi")
---@type string
local brew_prefix do
local f = assert(io.popen("brew --prefix libgccjit", "r"))
brew_prefix = f:read("*a"):sub(1, -2)
f:close()
end
local libgccjit = ffi.load(jit.os == "OSX" and string.format("%s/lib/gcc/current/libgccjit.dylib", brew_prefix) or "libgccjit")
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <assert.h>
struct Array {
size_t type_size, element_count;
uint8_t data[];
};
#import <ObjFW/ObjFW.h>
#define auto __auto_type
@interface AsyncDownloadRequest : OFObject<OFHTTPClientDelegate>
@property(readonly) OFFile *file;
+ (instancetype)requestWithFile: (OFFile *)file;
@Frityet
Frityet / Pointer.m
Created July 16, 2023 23:35
Pointer.h
#include "ObjFW.h"
#define class @interface
#define extends :
#define end @end
#define public @public
#define private @private
#define declare
; const char *, qword STRING.FROM_QWORD(char RDI buffer[RSI], qword RSI, signed qword RDX value)
export_function STRING.FROM_QWORD:
;qword R8 len = 0;
MOV R8, 0
;bool R9 negative = false;
MOV R9, FALSE
;if (value < 0)
CMP RDX, 0
JGE .0_l

How to install game-porting-toolkit (aka proton for macOS)

You also might wanna just use Whisky which does this automatically

This guide works on macOS 13.4+ using Command Line Tools for XCode 15 Beta!

What is this?

In the recent WWDC, Apple announced and released the "game porting toolkit", which upon further inspection this is just a modified version of CrossOver's fork of wine which is a "compatibility layer" that allows you to run Windows applications on macOS and Linux.

=================================================================
==59783==ERROR: AddressSanitizer: heap-use-after-free on address 0x60c000001660 at pc 0x000106f6bcab bp 0x7ff7b93672f0 sp 0x7ff7b93672e8
READ of size 1 at 0x60c000001660 thread T0
#0 0x106f6bcaa in std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::operator=[abi:v160003](std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&) string:1024
#1 0x106f6ad2c in ModulePragmaHandler::HandlePragma(clang::Preprocessor&, clang::PragmaIntroducer, clang::Token&) UAFTest.cpp:46
#2 0x10c80e716 in clang::Preprocessor::HandlePragmaDirective(clang::PragmaIntroducer)+0x56 (libclang-cpp.dylib:x86_64+0x1b9716) (BuildId: 74ad394874763760b74e808d09ca160c32000000200000000100000000000d00)
#3 0x10c7d8dd7 in clang::Preprocessor::HandleDirective(clang::Token&)+0x867 (libclang-cpp.dylib:x86_64+0x183dd7) (BuildId: 74ad394874763760b74e808d09ca160c32000000200000000100000000000d00)
#4 0x10