Blog

  • amazon-cloudwatch-agent-nix

    Amazon CloudWatch Agent on NixOS

    Flake to install’s the CloudWatch Agent on NixOS.

    TODO

    • more configuration options
    • more documentation
    • PR for nixpkgs

    Usage

    This is how you Install Amazon CloudWatch Agent on NixOS. In the inputs of your
    flake, add the Amazon CloudWatch Agent flake.

    {
      inputs = {
        nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
        amazon-cloudwatch-agent.url = "github:mipmip/amazon-cloudwatch-agent-nix";
      }
    }

    Then you will need to import the module and also add the cloudwatch agent
    software to the system packages.

    Below is an example setup.

    {
      description = "NixOS configuration Amazon CloudWatch Agent";
    
      inputs = {
        nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
        amazon-cloudwatch-agent.url = "github:mipmip/amazon-cloudwatch-agent-nix";
      };
    
      outputs = { self, nixpkgs, amazon-cloudwatch-agent }:
        let
          system = "x86_64-linux";
    
          amazon-cloudwatch-module = amazon-cloudwatch-agent.nixosModules.default;
          amazon-cloudwatch-config = {
            services.amazon-cloudwatch-agent.enable = true;
            environment.systemPackages = [
             amazon-cloudwatch-agent.packages."${system}".amazon-cloudwatch-agent
            ];
          };
    
        in {
          nixosConfigurations."<hostname>" = nixpkgs.lib.nixosSystem {
            inherit system;
            modules = [
              amazon-cloudwatch-module
              amazon-cloudwatch-config
              ./configuration.nix
            ];
          };
        };
    }

    Give CloudWatch Agent permission to publish to CloudWatch

    Once the agent is installed, you just need to make sure it has permission to
    publish its metrics to CloudWatch. You grant this permission by adding a policy
    to the IAM Instance Profile.

    Below is an example piece of Terraform code on how to add this to your EC2
    profile.

    resource "aws_iam_instance_profile" "ssm-access-iam-profile" {
      name = "ec2_profile"
      role = aws_iam_role.ssm-access-iam-role.name
    }
    
    resource "aws_iam_role" "ssm-access-iam-role" {
      name        = "ssm-access-role"
      description = "The role to access EC2 with SSM"
    
      assume_role_policy = jsonencode({
        Version = "2012-10-17"
        Statement = [
          {
            Effect    = "Allow"
            Principal = {
              Service = "ec2.amazonaws.com"
            }
            Action = "sts:AssumeRole"
          }
        ]
      })
    }
    
    resource "aws_iam_role_policy_attachment" "cloudwatch-policy" {
      role       = aws_iam_role.ssm-access-iam-role.name
      policy_arn = "arn:aws:iam::aws:policy/CloudWatchAgentServerPolicy"
    }

    credits

    Visit original content creator repository

  • carbon

    Carbon Cover

    License C Standard C++ Standard Latest Git Tag OpenSSF Best Practices SCLA signatures count Weekly commit frequency

    Carbon (/ˈkɑːbᵊn/) is the ultimate tiny and easy to use C/C++ standard library to enjoy programming.
    It serves a wide variety of use cases, from CLI programs, graphics-intensive real-time applications, to complex full-fledged testing suites.
    If you’d like to make a contribution, you can check the project’s guidelines; also, keep an eye on both security issues reporting instructions and our Code of Conduct. Furthermore, if you do something cool with Carbon, don’t forget to add the #sk-cbn tag to your topics! ¯\_(ツ)_/¯


    We use CI/CD to ensure the final product has the expected level of quality, if not more 🚀. This is the summary of the pipelines being run:

    KindTargetStatus
    CI (Continuous Integration)master
    CD (Continuous Delivery)master
    CD (Continuous Deployment)master/docs/www

    Do you want to keep up with changes or do you have a question that doesn’t require you to open an issue?
    Join the GitHub Discussions forum, meet other users like you. The more we are, the better for everyone.
    There you can ask questions, exchange ideas, share some of your work, make polls, stay up to date with new updates and announcements of the library, and much more.

    Do you want to support Carbon? Consider becoming a sponsor, or making a donation via Ko-fi or Buy Me a Coffee. Many thanks to all of you who are reading this; I hope it’ll be useful and it’ll make you enjoy programming a little bit more.

    Warning

    Carbon is currently in an alpha quality stage, and is not production-ready yet.

    Table of Contents

    Usage

    Carbon is in essence a two-part library: the static/dynamic lib pkg itself (where all symbols and instructions are defined), and the C/C++ header file (which gets generated by the build process as an amalgamation of all internal headers the library uses).

    Get the code

    We can get Carbon in our preferred way of managing dependencies or external libraries in our projects. It’s important to do so via the OFFICIAL Git repository hosted on GitHub, and not through any other website or server. Appart from that, any ref can be checked out, being master (the trunk of all dev progress), a tagged commit (e.g. v1.0), an actively maintained version branch (e.g. v1.0.y/stable) or a LTS version branch (e.g. v1.0.y/lts) the preferred ones.

    Here are the main options of obtaining it:

    Git Clone:

    git clone --recursive https://github.com/sparky-game/carbon

    Git Submodule:

    git submodule add https://github.com/sparky-game/carbon [...]
    git submodule update --init --recursive

    CMake FetchContent:

      —  Мои соболезнования.

    include(FetchContent)
    FetchContent_Declare(
      carbon
      GIT_REPOSITORY "https://github.com/sparky-game/carbon"
      GIT_TAG        [...]
      GIT_PROGRESS   TRUE
    )
    FetchContent_MakeAvailable(carbon)

    Pre-compiled Package:

    You might want to take a look to the latest release available and download the appropriate pre-compiled package for your CPU’s architecture and OS.

    Build from source

    If wanted to build Carbon from source yourself, it can be done without any problems. We use a custom make utility (which uses Carbon under the hood) as our build system to manage testing, compiling and packaging the library, both static and dynamic.

    This custom build system can rebuild itself properly (using our preferred compilation flags), which means that you’ll only need to bootstrap it once:

    cc src_build/make.c -o make

    Once built, we can take a look at the available subcommands and options by issuing the command ./make help. To run the full build pipeline it’s just as easy as:

    ./make

    Tip

    Checkout the installation instructions to make Carbon available on your system as any other library (the PREFIX is customizable according to your needs).

    Examples

    A good place to start learning and discovering all the things you can do with Carbon is reading and executing the examples. One can issue the command ./make examples to build them all: for each example source file (.c or .cc) it produces a .bin executable file, which can be run normally without problems.

    Furthermore, you can also take a look at the amalgamated distributable header file (carbon.h), where each module of the library is declared and documented. This is all the documentation you’ll ever need, and it’s also a good place to find new things Carbon can do.

    Lastly, for a more advanced understanding of all available and tested functionality that Carbon provides, reading the tests is a great next step. There it can be learnt both how to work with the different modules, and how to use Carbon itself to test your own applications and programs. One can issue the command ./make test to build and run all tests.

    Licensing

    Copyright (C) Wasym A. Alonso. All Rights Reserved.

    Carbon is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License Version 3 (GNU AGPL-3.0) as published by the Free Software Foundation (FSF) on November 19th 2007.
    Carbon is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License Version 3 for more details.
    For more information, see https://www.gnu.org/licenses/agpl-3.0.

    As mentioned above, Carbon is licensed under the GNU’s AGPL-3.0-only, which means that any software created or that uses it is also subject to the same license. This implies that if you develop an application using Carbon, it must also be released as free software under the GNU’s AGPL-3.0-only. This ensures that the freedoms to use, study, modify and share the software are preserved for everyone.

    If you prefer to release your application under a different, more commercially friendly license, there is an option available. You can purchase a copy of the Carbon Runtime Library Exception (CRLE), which is in essence a distinct commercial license, for you to use this library without releasing your software under GNU’s AGPL-3.0-only. Some key aspects of the CRLE are the following:

    • One-Time Purchase (OTP): Once obtaining a copy of the CRLE, it lasts forever without expiration date.
    • Project-specific: Each CRLE is tied to a single project of yours.
    • Version compatibility: Each CRLE applies to a specific branch or minor version of Carbon (e.g. v1.0.y/lts), enabling you to update the library to a more up-to-date version with the same CRLE.
    • Professional support: You also gain access to more advanced support regarding the library, as well as a private channel to make high-priority requests such as bug fixes or security vulnerabilities.

    For more details and to acquire a copy of the CRLE, please visit https://libcarbon.org.

    References

    1. Alshahwan, N., Chheda, J., Finegenova, A., Gokkaya, B., Harman, M., Harper, I., Marginean, A., Sengupta, S., Wang, E. (2024, February 14). Automated Unit Test Improvement using Large Language Models at Meta [Paper]. arXiv, Cornell University. https://doi.org/10.48550/arXiv.2402.09171
    2. Barrett, S. (2015, June 7). Advice for Writing Small Programs in C [Video]. YouTube. https://www.youtube.com/watch?v=eAhWIO1Ra6M
    3. Catto, E. (2024, August 27). Determinism [Article]. Box2D. https://box2d.org/posts/2024/08/determinism/
    4. Christensen, T. (2002, January 1). The Cambridge History of Western Music Theory [Book]. Cambridge University Press. https://doi.org/10.1017/CHOL9780521623711
    5. De Vries, J. (2020, June 17). Learn modern OpenGL graphics programming in a step-by-step fashion [Book]. LearnOpenGL. https://learnopengl.com
    6. Gallego Durán, F. J. (2021, December 7). C++ Slotmap: qué es y por qué usarlo en tu motor de videojuegos [Video]. YouTube. https://www.youtube.com/watch?v=GKfRDAUvFoE
    7. Gallego Durán, F. J. (2021, December 10). C++ Programamos un Slotmap para nuestro motor de videojuegos ECS [Video]. YouTube. https://www.youtube.com/watch?v=ZfWF9tqQOh0
    8. Gallego Durán, F. J. (2022, January 28). C++ Template Metaprogramming: Introducción [Video]. YouTube. https://www.youtube.com/watch?v=4NKbmCfZ9OI
    9. Gallego Durán, F. J. (2022, March 2). C++ Operadores: cómo programar un vector 3D [Video]. YouTube. https://www.youtube.com/watch?v=cBMbhJPuw1w
    10. Holden, D. (2021, April 16). orangeduck/Cello: Higher level programming in C [Code]. GitHub. https://github.com/orangeduck/Cello
    11. Immisch, L., Wilstrup C. (2017, January 1). PCM Terminology and Concepts [Article]. pyalsaaudio’s Website. https://larsimmisch.github.io/pyalsaaudio/terminology.html
    12. Kutepov, A. (2023, June 30). tsoding/nn.h: Simple stb-style header-only library for Neural Networks [Code]. GitHub. https://github.com/tsoding/nn.h
    13. Kutepov, A. (2024, November 5). tsoding/nob.h: Next generation of the NoBuild idea [Code]. GitHub. https://github.com/tsoding/nob.h
    14. Kutepov, A. (2025, February 3). tsoding/coroutines: Custom coroutines implementation in GNU C [Code]. GitHub. https://github.com/tsoding/coroutines
    15. Matsumoto, M., Nishimura, T. (1998, January 1). Mersenne twister: a 623-dimensionally equidistributed uniform pseudo-random number generator [Paper]. Transactions on Modeling and Computer Simulation (TOMACS), Association for Computing Machinery (ACM). https://doi.org/10.1145/272991.272995
    16. Matsumoto, M., Nishimura, T. (2004, September 29). A C-program for MT19937-64 (2004/9/29 version) [Code]. Department of Mathematics, Hiroshima University. http://www.math.sci.hiroshima-u.ac.jp/m-mat/MT/VERSIONS/C-LANG/mt19937-64.c
    17. Nishimura, T. (2000, October 1). Tables of 64-bit Mersenne twisters [Paper]. Transactions on Modeling and Computer Simulation (TOMACS), Association for Computing Machinery (ACM). https://doi.org/10.1145/369534.369540
    18. OptumSoft. (2016, January 5). Dangers of using dlsym() with RTLD_NEXT [Article]. OptumSoft. https://optumsoft.com/dangers-of-using-dlsym-with-rtld_next/
    19. Rice, B. (2018, January 23). You Can’t Unit Test C, Right? [Video]. YouTube. https://www.youtube.com/watch?v=z-uWt5wVVkU
    20. Santell, J. (2019, April 14). Model View Projection [Article]. jsantell.com. https://jsantell.com/model-view-projection/
    21. Ten Bosch, M. (2020, January 30). Let’s remove Quaternions from every 3D Engine [Article]. marctenbosch.com. https://marctenbosch.com/quaternions/
    22. Viotti, J. C. (2023, December 1). Understanding Objective-C by transpiling it to C++ [Article]. jviotti.com. https://www.jviotti.com/2023/12/01/understanding-objective-c-by-transpiling-it-to-cpp.html
    Visit original content creator repository
  • spellweaver-7drl

    Spellweaver

    This is my 2021 7DRL entry. This is a classic roguelike with ASCII graphics.
    This is the 7DRL version of the game, so bugs certainly abound.

    Libraries

    Game Premise

    You are an apprentice sorcerer sent into a musty dungeon to retrieve your
    master’s spellbook. You will encounter various monsters along the way,
    using combinations of spells to defeat them.

    How to Build

    You will need JDK 15 or higher to build this. I personally used the OpenJDK.

    git clone https://github.com/Rakaneth/spellweaver-7drl
    cd spellweaver-7drl
    gradlew clean build
    

    The resultant executable JAR file will be in
    ./build/libs/spellweaver-7drl-<version number>.jar.

    Jars will also be available under this repo’s Releases.

    How to Play

    The game is turn-based, as is standard. The world only moves when you do.

    Symbols

    • # – a solid wall
    • . – empty floor
    • @ – you
    • any letter – a monster
    • > – stairs down
    • < – stairs up
    • X – targeting UI assistance
    • , – shallow water(150% time to move through)
    • ~ – deep water (triple time to move through)
    • ? – a spellbook, perhaps your master’s

    Controls

    • W, A, S, D – movement (up, left, down, right respectively)
    • 1-7 – prepare a spell with up to three elements
    • >, < – descend or ascend stairs (either works for any stairway)
    • ENTER – enter targeting mode (after preparing a spell)

    Gameplay Notes

    There are seven elements: FIRE, ICE, LIGHTNING, EARTH, FORCE, LIGHT, DARK. You begin play knowing
    how to weave FIRE, ICE, LIGHTNING, and EARTH. You may find the others as lost spellbooks in the
    dungeon.

    The first element of any spell dictates the base element of the spell. The second element changes
    the spell in different ways, applying an effect to the targets or perhaps a helpful enchantment to
    yourself. The third element changes the shape of the spell from a simple point to a variety of shapes,
    again depending on element.

    Some creatures are vulnerable to certain (primary) elements and resistant to others.

    DevLog

    3.6

    Started with some scaffolding to ensure VTerminal would work how
    I wanted. Implemented the scaffolding for GameMap and MapBuilder classes,
    which encapsulate the state of the game map and build it, respectively.
    I come to my first major design decision – while it is easier to ask the
    maps to hold the state of Entities (which is what I have now), I think I would
    rather store them in the GameState class for easier serialization. I’m
    going to sleep on that decision for now. Also, I need to try to build a
    JAR now so that I can release dev builds to my testers who have graciously
    volunteered to test for me.

    Moved Entity storage to the GameState. Ideally, I should only need to
    serialize one object when I get to that point.

    Also, basic map generation and a properly scrolling map are in. It will need
    some color and checks against the player moving into walls.

    Furthermore, gradlew build creates a running jar now. Why
    IntelliJ’s Build Artifacts does not baffles me.

    Added some color to map tiles and Entity

    This might be a case of premature optimization, but I appear to be
    thrashing the GC somehow. I’ll keep going for now, but I will keep
    an eye on this.

    Also added FOV. SquidLib makes putting in a lot of the plumbing
    very simple.

    3.7

    Added basic saving and loading, the main game view, and file reading.
    Java generics are a mess.

    3.8

    Working on the game’s main mechanic – spellcasting. The general idea is
    for the player to use 1 to 3 different magical elements, with the first
    element providing a base effect and the other two modifying the spell,
    giving it properties like AOE and increased power, at the expense of
    Power.

    3.9

    In working on the code behind this mechanic, I discovered I had a lot of
    plumbing that still needed to be done, so now Combatant entities
    have proper stats, can receive damage, be healed, and can have
    Effects on them – buffs, debuffs, crowd-control, damage-over-time, etc.

    Combatants have the following stats by default:

    • atk: attack power, how hard it hits in melee
    • dfp: defense power, how well it absorbs damage
    • will: mental fortitude, the ability to resist things like Fear and Stun.
      Will also affects the hero’s spellcasting.
    • spd: General speed, how fast it moves
    • hp: Hit points, dead at 0

    Added a MessageDispatcher class to send messages to the GameState
    without needing to pass it around like a football.

    Also added a Poison effect and changed some of the plumbing on Effects
    to make messaging regarding them easier.

    3.10

    More hacking on creatures – the MapBuilder now can seed its own
    creatures. There is an argument for leaving that to the caller,
    but I like the idea of having everything the map needs to function
    in the builder.

    Some new creatures got added to the creatures.yml file.

    3.11

    Scheduling system is in. It isn’t perfect, but here we are at day 6 and
    it seems to work.

    Bump combat is finally in, as are Weapon and Armor effects.

    • Weapon – empowers bump attacks, granting them power and an element
    • Armor – strengthens defense and grants resistance to an element

    For the 7DRL, these are the closest things to equipment I have time to
    implement. I think it’s more thematic this way, anyway.

    Tweaked the appearance of effects to show modifications, like the number
    of poison stacks or the element an Armor or Weapon buff is keyed to.

    3.12

    Cutting it very close. Spellcasting is in, but is likely to have a lot of
    bugs, as it took me the whole week to figure out how to get this in.

    Implemented a DiceRoller singleton class with access to one of the game’s RNGs
    (two are used, one for generating the map, the other for combat –
    the idea is to allow for seeded runs without also fixing combat luck).
    This is done to avoid having to pass the whole GameState around if I
    need randomness in a part of the engine with no direct access to the
    GameState.

    Saving broke at the last moment after implementing spells, and I don’t have
    time to fix it before the deadline, so I will leave it out of the 7drl
    build.

    Quite a lot of content got cut for the sake of finishing on time, but
    the game is technically winnable now. If there is enough interest
    on my part or others, I may hack on this later.

    Visit original content creator repository