Skip to content

Instantly share code, notes, and snippets.

View HudsonSchumaker's full-sized avatar
🎮
Game Dev

Hudson Luiz Sales Schumaker HudsonSchumaker

🎮
Game Dev
View GitHub Profile
@HudsonSchumaker
HudsonSchumaker / cpp-project.md
Created February 12, 2025 16:17
C++17 project

For a C++17 project, a typical directory layout would follow standard conventions to ensure clarity, ease of maintenance, and scalability. Here’s a suggested directory structure:

/ProjectName
├── /build              # Build artifacts (often added to .gitignore)
├── /cmake              # CMake modules and custom scripts
├── /docs               # Documentation files
├── /include            # Public header files (for libraries)
│   └── /ProjectName    # Subdirectory named after the project/library
│       └── *.h         # Header files
@HudsonSchumaker
HudsonSchumaker / enum.md
Created January 6, 2025 08:08
Enum overload

Ways to overload methods with specific enum in Java

You can overload methods in Java with specific enum members as parameters. This approach can sometimes be used to avoid if or switch statements by leveraging polymorphism and method overloading. However, Java does not support directly overloading methods based on individual enum constants (e.g., method(YourEnum.CONSTANT) as a unique signature), but you can achieve similar functionality using approaches like the following:

1. Overloading with Enum Types

You can overload methods by passing an enum as a parameter and defining behavior for each constant:

@HudsonSchumaker
HudsonSchumaker / cpp-pointers-reference.txt
Last active January 24, 2025 08:59
C++ pointers and reference
Pointers:
Can be reassigned: Pointers can point to different objects at different times.
Can be null: Pointers can be assigned a nullptr value to indicate that they are not pointing to any object.
Pointer arithmetic: You can perform arithmetic operations on pointers (e.g., incrementing to point to the next element in an array).
Dynamic memory management: Pointers are often used for dynamic memory allocation with new and delete.
References:
Cannot be null: References must always refer to a valid object.
Cannot be reassigned: Once a reference is initialized to an object, it cannot be changed to refer to another object.
Syntactic sugar: References provide a more convenient syntax for accessing the referred object, as they are used like normal variables.
@HudsonSchumaker
HudsonSchumaker / Callback.h
Last active October 23, 2024 07:17
callback function with generics.
#include <functional>
/**
* @class Callback
* @brief The Callback class is a component that stores a callback function.
*/
template<typename... Args>
class Callback {
public:
@HudsonSchumaker
HudsonSchumaker / remote-debugging.txt
Created September 18, 2024 09:24
Enable jvm remote debug
JAVA_TOOL_OPTIONS: "-agentlib:jdwp=transport=dt_socket,address=*:5005,server=y,suspend=n"
@HudsonSchumaker
HudsonSchumaker / tdd_ddd_bdd.txt
Created August 19, 2024 14:04
TDD + DDD + BDD
Domain-Driven Design (DDD)
DDD is an approach to software development that focuses on creating a shared understanding of the problem domain,
and aligning the software model with that domain. It emphasizes collaboration between technical and domain experts to
iteratively refine a conceptual model that drives the software design.
Let's build a calculator with arithmetic and trigonometry functions.
Arithmetic:
- Sum
- Addition
@HudsonSchumaker
HudsonSchumaker / Mapper.kt
Created June 27, 2024 14:13
Mapper interface in Kotlin
package com.hellofresh.dps.shared.mapper
import java.util.function.BiConsumer
interface Mapper<S, T> {
fun from(source: S): T?
fun from(sources: Iterable<S>): List<T>? =
from(sources, BiConsumer { _, _ -> })
--- Endianness ---
Little endian:
higher memory
------------->
+----+----+----+----+
|0x01|0x00|0x00|0x00|
+----+----+----+----+
A
@HudsonSchumaker
HudsonSchumaker / ofwsc.txt
Created March 23, 2024 16:01
macOS open finder with shortcut
1.Open Automator (you can find it using Spotlight search).
2.Click on "New Document" and then choose "Quick Action".
3.In the workflow area, choose "No input" from the "Workflow receives" dropdown, and "any application" from the "in" dropdown.
4.In the Actions library on the left, find "Run AppleScript" and drag it to the workflow area.
5.Replace the default AppleScript code with the following:
tell application "Finder"
activate
make new Finder window
end tell
@HudsonSchumaker
HudsonSchumaker / gradle.txt
Created October 9, 2023 15:32
gradle commands
Find bugs, gradle
./gradlew findbugsMain findbugsTe
./gradlew clean
./gradlew build -x test
./gradlew build --refresh-dependencies
./gradlew build -x test --refresh-dependencies
./gradlew clean build -x test --refresh-dependencies
./gradlew bootRun
./gradlew test // runs the tests the same as CI