Skip to content

Instantly share code, notes, and snippets.

@h0nza
h0nza / FindOracle.cmake
Created October 14, 2025 12:47 — forked from ibre5041/FindOracle.cmake
CMake: Configure Oracle libraries
#.rst:
# FindOracle
# ----------
#
# Configure Oracle libraries
#
# ORACLE_FOUND - system has Oracle OCI
# ORACLE_HAS_XML - Oracle has XDK support(thick client installed)
# ORACLE_INCLUDES - where to find oci.h
# ORACLE_LIBRARIES - the libraries to link against to use Oracle OCI
@h0nza
h0nza / GNU-Make.md
Created July 30, 2025 07:14 — forked from rueycheng/GNU-Make.md
GNU Make cheatsheet

C/C++ performance pitfall: int8_t, aliasing and the ways out

When I was working on a generic port of Google's hashmap to C, I wrote a function that (ignoring irrelevant parts) looked like this:

typedef struct {
    uint8_t *bytes;
    size_t len;
} bytebuf;
@h0nza
h0nza / uuidv7.c
Created January 17, 2024 23:06 — forked from fabiolimace/uuidv7.c
UUID v7 for C
#include <time.h>
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <stdint.h>
#include <sys/random.h>
#define UUID_T_LENGTH (16)
#define UNIX_TS_LENGTH (6)
@h0nza
h0nza / effective_modern_cmake.md
Created May 24, 2023 09:48 — forked from mbinna/effective_modern_cmake.md
Effective Modern CMake

Effective Modern CMake

Getting Started

For a brief user-level introduction to CMake, watch C++ Weekly, Episode 78, Intro to CMake by Jason Turner. LLVM’s CMake Primer provides a good high-level introduction to the CMake syntax. Go read it now.

After that, watch Mathieu Ropert’s CppCon 2017 talk Using Modern CMake Patterns to Enforce a Good Modular Design (slides). It provides a thorough explanation of what modern CMake is and why it is so much better than “old school” CMake. The modular design ideas in this talk are based on the book [Large-Scale C++ Software Design](https://www.amazon.de/Large-Scale-Soft

@h0nza
h0nza / Quirks of C.md
Created November 20, 2022 21:40 — forked from fay59/Quirks of C.md
Quirks of C

Here's a list of mildly interesting things about the C language that I learned mostly by consuming Clang's ASTs. Although surprises are getting sparser, I might continue to update this document over time.

There are many more mildly interesting features of C++, but the language is literally known for being weird, whereas C is usually considered smaller and simpler, so this is (almost) only about C.

1. Combined type and variable/field declaration, inside a struct scope [https://godbolt.org/g/Rh94Go]

struct foo {
   struct bar {
 int x;
@h0nza
h0nza / delete_git_submodule.md
Created October 4, 2022 14:52 — forked from myusuf3/delete_git_submodule.md
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
@h0nza
h0nza / esm-package.md
Created January 10, 2022 10:05 — forked from sindresorhus/esm-package.md
Pure ESM package

Pure ESM package

The package linked to from here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@h0nza
h0nza / mvc-mvvm.md
Created January 8, 2022 20:49 — forked from ostinlviv/mvc-mvvm.md
MVC / MVVM differences

MVC

MVC

All input coming from user interaction, such mouse click. are directed to the Controller first. The Controller then kick off some functionality. A single Controller may render many different Views based on the operation being executed. Also view doesn’t have any knowledge of or reference to the Controller. Controller interact with the Model and pass the model to the View. So there is a knowledge between the View and Model being passed on to it.

MVVM

MVVM

The input is directed to the View. View hold a reference to the ViewModel. But ViewModel is not aware of the View. So it is possible to have one ViewModel to support many Views. Also the Model is decoupled from the View. ViewModel interact with the Model and feed the View with the data.

@h0nza
h0nza / module-loading.md
Created January 8, 2022 20:48 — forked from ostinlviv/module-loading.md
Module loading

js-modules

CommonJS

The CommonJS format is used in Node.js and uses require and module.exports to define dependencies and modules. CommonJS modules were designed with server development in mind. Naturally, the API is synchronous. In other words, modules are loaded at the moment and in the order they are required inside a source file.

AMD

The AMD format is used in browsers and uses a define function to define modules. The main difference between AMD and CommonJS lies in its support for asynchronous module loading. Asynchronous loading is made possible by using JavaScript's traditional closure idiom: a function is called when the requested modules are finished loading. Module definitions and importing a module is carried by the same function: when a module is defined its dependencies are made explicit.