Skip to content

Instantly share code, notes, and snippets.

View ITotalJustice's full-sized avatar
💜
Coding away...

ITotalJustice

💜
Coding away...
View GitHub Profile
cmake_minimum_required(VERSION 3.11.0)
project(minibug LANGUAGES C CXX)
add_executable(minibug main.cpp)
include(FetchContent)
Set(FETCHCONTENT_QUIET FALSE)
FetchContent_Declare(minizip
@ITotalJustice
ITotalJustice / strstr_s.cpp
Created March 16, 2022 21:04
find string when string is not null terminated.
// goto will be constexpr in c++23 (finally)
// for my c version: https://github.com/ITotalJustice/TotalGBA/blob/3172ffea3b3c11d0714c6425c74e89efdc219ae1/src/util/string.c#L6
auto strstr_s(std::string_view haystack, std::string_view needle) -> std::string_view
{
for (std::size_t i = 0; i < haystack.size(); i++)
{
// if we find the first matching char, start the inner loop
if (haystack[i] == needle[0])
{
set(LIBDRAGON "/opt/libdragon")
set(LIBDRAGON_LIBS "-ldragon -lc -lm -ldragonsys") # order matters
SET(CMAKE_SYSTEM_NAME Generic)
SET(CMAKE_SYSTEM_VERSION 1)
SET(CMAKE_SYSTEM_PROCESSOR mips)
SET(CMAKE_C_COMPILER ${LIBDRAGON}/bin/mips64-elf-gcc)
SET(CMAKE_CXX_COMPILER ${LIBDRAGON}/bin/mips64-elf-g++)
set(CMAKE_LINKER ${LIBDRAGON}/bin/mips64-elf-ld)
set(CMAKE_AR ${LIBDRAGON}/bin/mips64-elf-ar)
@ITotalJustice
ITotalJustice / CMakeLists.txt
Last active February 10, 2022 11:36
psp sdl2 sample
cmake_minimum_required(VERSION 3.18.0)
project(TotalGB LANGUAGES C)
set(myname "TotalGB_SDL2")
add_executable(${myname} main.c)
option(UPSTREAM_SDL "use upstream sdl2" ON)
if (UPSTREAM_SDL)
#include "curl_wrapper.hpp"
#include "../../utils/logger.hpp"
// todo: fix dkp curl. complains about fd_set missing
#ifdef __SWITCH__
#include <sys/select.h>
#endif
#include <curl/curl.h>
namespace curl {
@ITotalJustice
ITotalJustice / hlsparse.cpp
Created November 9, 2021 18:01
crapi hls parser
#include "hlsparse.hpp"
#include "../../utils/logger.hpp"
#ifndef NDEBUG
#include <iostream>
#endif
#include <cassert>
#include <ranges>
#include <algorithm>
@ITotalJustice
ITotalJustice / helper.hpp
Created November 9, 2021 18:00
nlohmann::json helper
#include "json.hpp"
#include <optional>
using json = nlohmann::json;
namespace nlohmann {
// https://github.com/nlohmann/json/issues/1910#issuecomment-615843605
template <typename T>
struct adl_serializer<std::optional<T>> {
#include "crunchy.hpp"
#include "crapi/crapi.hpp"
#include "../utils/logger.hpp"
#include <algorithm>
#include <ranges>
namespace fs {
static auto CheckCrDataError(const auto& a) noexcept {
#pragma once
#include "../nlohmann/json_fwd.hpp"
#include <cstdint>
#include <string>
#include <vector>
#include <optional>
namespace funi {
#pragma once
#include "../nlohmann/json_fwd.hpp"
#include <vector>
#include <string>
#include <optional>
namespace cr {