Skip to content

Instantly share code, notes, and snippets.

View kassane's full-sized avatar
🏠
Working from home

Matheus C. França kassane

🏠
Working from home
View GitHub Profile
@kassane
kassane / Dockerfile
Created April 1, 2024 20:14
Modm.io - C++ modern for embedded - STM32
# Based on: https://modm.io/guide/installation/
FROM ubuntu:latest
RUN apt-get update && \
apt-get install -y \
python3 \
python3-pip \
scons \
cmake \
@kassane
kassane / builtin_cnl.zig
Last active March 26, 2024 14:15
zig esp32 (espressif llvm backend)
const std = @import("std");
/// Zig version. When writing code that supports multiple versions of Zig, prefer
/// feature detection (i.e. with `@hasDecl` or `@hasField`) over version checks.
pub const zig_version = std.SemanticVersion.parse(zig_version_string) catch unreachable;
pub const zig_version_string = "0.12.0-dev.xtensa.2858+8e52bb152";
pub const zig_backend = std.builtin.CompilerBackend.stage2_llvm;
pub const output_mode = std.builtin.OutputMode.Obj;
pub const link_mode = std.builtin.LinkMode.Static;
pub const is_test = false;
@kassane
kassane / main.zig
Last active February 16, 2024 20:14
zig build to PSVita target
// replacing https://github.com/vitasdk/samples/blob/master/hello_world/src/main.c
const c = @cImport({
@cInclude("psp2/kernel/processmgr.h");
@cInclude("psp2/kernel/threadmgr.h");
@cInclude("stdio.h");
@cInclude("debugScreen.h");
@cDefine("printf", "psvDebugScreenPrintf");
});
pub export fn main() c_int {
@kassane
kassane / gdextension_interface.zig
Last active December 29, 2023 17:13
Godot 4 - GDExtension for zig bindings
// GDExtension - zig (v0.11.0 or master) binding
// cmd: godot --dump-gdextension-interface -q --headless
// based on: https://github.com/godot-dlang/godot-dlang/blob/master/gdextension_interface.h
const std = @import("std");
pub const GDExtensionVariantType = enum(c_uint) {
GDEXTENSION_VARIANT_TYPE_NIL = 0,
GDEXTENSION_VARIANT_TYPE_BOOL = 1,
GDEXTENSION_VARIANT_TYPE_INT = 2,
GDEXTENSION_VARIANT_TYPE_FLOAT = 3,

Named arguments in D language

DIP1030

Named/labeled/keyword arguments are useful in Python and OCaml, but in the D language they were proposed by DIP1030 and adopted three years ago.

Currently, templates are not supported, but recent DMDs -preview allow you to try out these features without any flags. The verification environment this time is DMD2.106.0.

module intrusive_mpsc_queue;
import core.atomic;
// An intrusive MPSC queue in D.
struct IntrusiveQueue(T)
{
private T* head;
private T* tail;
private T stub;
@kassane
kassane / dlang_UEFI_Boot.md
Last active December 7, 2023 12:55
Running D language with Zephyr

Development environment

  • LDC
  • lld
  • qemu
  • ovmf(Open Virtual Machine Firmware)

Also, although it is not required, I use just as the command runner, just like the reference source. Make is fine, but I felt like I could understand the FAQ's philosophy, so I tried using it.

UEFI target

@kassane
kassane / ldc2_zig_cc.sh
Last active November 4, 2023 15:10
LDC2 cross-compiling using zig toolchain - D language
#!/usr/bin/env bash
# Based on: https://github.com/kassane/xwin-zig-test/
# download and unpack WinSDK and MSCRT libs
# manifest 16 == VS2019
# xwin --manifest-version 16 --accept-license splat --output $PWD/.xwin --include-debug-symbols --preserve-ms-arch-notation --include-debug-libs
# "$HOME/ldc-xcross/lib64" - need prebuilded libs
# curl -LO https://github.com/ldc-developers/ldc/releases/download/v1.35.0/ldc2-1.35.0-windows-multilib.7z
@kassane
kassane / Dockerfile
Created October 27, 2023 20:20
Dlang - LDC latest version on Debian
FROM debian:latest
ENV LDC_PATH /usr/local/ldc
RUN apt-get update && \
apt-get install -y --no-install-recommends curl wget gcc ca-certificates xz-utils libxml2 && \
rm -rf /var/lib/apt/lists/* /var/cache/apt/*
RUN set -ex && \
LDC_VERSION=$(curl -sL https://ldc-developers.github.io/LATEST)
@kassane
kassane / Instructions.md
Last active October 1, 2023 13:58 — forked from karbassi/Instructions.md
Create a ZIP file from an SVN url

Installing

  • Need install svn application!!!
  • on svn-zip get gist raw-url
  • Download svn-zip into local folder. For example: curl [raw-url] > svn-zip
  • add run privilege with chmod +x snv-zip or execute bash svn-zip SVN_URL ZIP_FILE_NAME

Usage

In your terminal, use: