Skip to content

Instantly share code, notes, and snippets.

View jsmolina's full-sized avatar

Jordi Sesmero jsmolina

  • Barcelona
View GitHub Profile
@jsmolina
jsmolina / dat_compress.c
Created December 16, 2024 19:12
dat file manager for any size
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_FILENAME_LEN 16
// Estructura para almacenar la cabecera de cada archivo (nombre y tamaño)
typedef struct {
char filename[MAX_FILENAME_LEN];
long long filesize;
@jsmolina
jsmolina / dat.c
Created August 22, 2024 16:50
Simplest ever static files compacter for games onto one datafile. Use dat.c as a commandline utility to generate data.dat file, use dat_manager to uncompress on runtime.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dirent.h>
#include <sys/stat.h>
#include <unistd.h>
// Code based on mills32 Little-Game-Engine-for-VGA-EGA
struct dirent *direntry;
@jsmolina
jsmolina / docker-compose.yml
Created August 18, 2024 16:22
Allegro 4: using allegro tools from any OS by running them from docker
version: "3"
services:
allegro:
image: docker.io/amarillion/alleg4-buildenv
volumes:
- ./static:/data
# allegro tools in version 4 fail for no reason even on DOS.
@jsmolina
jsmolina / gist:394625ee50fe660a0d076334647f8f3e
Created June 6, 2023 16:31
YUP: Validating a dynamic field object (profiles) that appears when another field (selected_groups) is checked.
profiles: Yup.lazy((value, { parent }) => {
if (value && parent.selected_groups?.length) {
const newEntries = parent.selected_groups.reduce(
(acc, val) => ({
...acc,
[val]: Yup.string().test("hasValue", "item cannot be empty", (value) => {
return !!value;
}),
}),
{}
@jsmolina
jsmolina / TextField.js
Last active June 2, 2023 13:08
Working with a dynamic array of multiple Fields in React Formik (very basic example)
export const TextField = ({name}) => {
const { touched, values, errors, handleBlur, handleChange } = useFormikContext();
const isTouched = getIn(touched, name);
const value = getIn(values, name);
const error = getIn(errors, name);
// getIn automates for you getting values["text"][0]
const isTouched = getIn(touched, name);
const value = getIn(values, name);
@jsmolina
jsmolina / MuiTable.js
Last active June 14, 2023 14:05
Generic Material UI table component, simple! Compatible with mui-datatables
import PropTypes from "prop-types";
import { useCallback, useMemo, useState } from "react";
import Table from "@mui/material/Table";
import TableBody from "@mui/material/TableBody";
import TableCell from "@mui/material/TableCell";
import TableHead from "@mui/material/TableHead";
import TableRow from "@mui/material/TableRow";
import TableSortLabel from "@mui/material/TableSortLabel";
import Box from "@mui/material/Box";
// disables weird keyboard behaviours in mac ~/Library/KeyBindings/DefaultKeyBinding.dict
{
"\UF729" = moveToBeginningOfLine:; // home
"\UF72B" = moveToEndOfLine:; // end
"$\UF729" = moveToBeginningOfLineAndModifySelection:; // shift-home
"$\UF72B" = moveToEndOfLineAndModifySelection:; // shift-end
"@\UF700" = noop:; // command-up
"@\UF701" = noop:; // command-down
"$@\UF700" = noop:; // shift-command-up
"$@\UF701" = noop:; // shift-command-down
import os, glob
import shutil
import string
# generates RLOADER https://github.com/marco-sacchi/RLoader LIST.txr
translation_table = dict.fromkeys(map(ord, ' [](),.~!@#$%^&*{}: '), None)
OUT = "/Users/jordism/Downloads/DOS/GAMES"
ROOT = ["./DIST/games1",
"./games2",
"./games3"]
@jsmolina
jsmolina / main.py
Created October 23, 2022 16:42
generates menu for dos launching games
import os, glob
import shutil
import string
translation_table = dict.fromkeys(map(ord, ' [](),.~!@#$%^&*{}: '), None)
# todo use argparse to parametrize
OUT = "./games"
ROOT = ["./DIST/games1",
"./DIST/games2",
"./DIST/games3"]
@jsmolina
jsmolina / gist:5550a0490e1dd327599790c863c706e4
Created April 26, 2022 14:00
Open Macos keyboardAssistant
sudo open /System/Library/CoreServices/KeyboardSetupAssistant.app/Contents/MacOS/KeyboardSetupAssistant