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
-- Constants for chunk size
local arg = {...}
---@param called string
---@return (string | integer)?
local function get_arg(called)
local tofind = "--"..called
for i, v in ipairs(arg) do
if v == tofind then
local val = arg[i+1]
local socket = require("socket")
local xml_gen = require("x-gen")
local xml = xml_gen.xml
---@param document XML.Node
local function build_response(document)
local str = "<!DOCTYPE html>"..tostring(document)
return ([[
HTTP/1.1 200 OK
Content-Type: text/html
Content-Length: %d
#define _XOPEN_SOURCE 700
#include <signal.h>
#include <stdint.h>
#include <stddef.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <unistd.h>
#include <stdbool.h>
@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 September 8, 2024 15:37
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