Skip Navigation
OS Backup - what should and what should not be backup'd?
  • you could "dd" your root partition to a partition on that HDD every now and then. and if you don't have your home on a different partition do that and it's easy to back this up with a syncing tool if u decided to do that or at least the .config .local and .cache directories because many programs put their configuration files in there.

    BE VERY CAREFUL WHEN USING "dd" BECAUSE IT CAN MAKE YOU LOSE DATA FOR A WHOLE PARTITION OR DEVICE

    docker keeps some data in ~/.local/share/docker btw

  • [Hyprland]

    cross-posted from: https://programming.dev/post/34004967

    > !

    0
    Unixporn @lemmy.ml nodeluna @programming.dev
    [Hyprland]

    !

    0
    a small implementation for std::expected for C++11
  • alright then.

    I see. expected is such a great library to have regardless of the standard version. oh c++03, I'm not familiar with that standard.

    I enabled support for c++11 regardless, it's kinda cool to do so

  • a small implementation for std::expected for C++11
  • because "if constexpr(...)" is a c++17 feature which i'm using it to allow usage of nl::unexpected() to return a nl::expected<nl::monostate, E> to nl::expected<T, E> in this copy constructor

    template<class U>
    expected(const expected<U, E>& other) : _has_value(other.has_value())   // a copy constructor  
    {
            if (_has_value)
            {
                    if constexpr (std::is_same<U, monostate>::value) // it checks if U == monostate
                    {
                            // makes an empty instance of "T"
                    }
                    else if constexpr (std::is_same<U, T>::value) // it checks if U == T
                    {
                            // otherwise copies "other._value" into _value
                    }
                    else
                    {
                            static_assert(
                                not std::is_same<U, T>::value, "no available conversion between the provided value types");
                    }
            }
            else
            {
                    new (std::addressof(_error)) E(other.error());
            }
    }
    
     template<class E>
     expected<monostate, E> unexpected(const E& e) // then this can covert <monostate, E> to <T, E> fine because of this copy constructor
     {                
             return expected<monostate, E>(e);
     }
    
    
    // example usage
    
    nl::expected<int, std::string> meow = nl::unexpected("error");
    

    but i could take a different approach and make 2 copy constructor one that explicitly takes

    expected(const expected<monostate, E>& other)
    

    and another

    expected(const expected& other)
    

    I was also using "std::is_same_v" which is a c++17 feature instead "std::is_same<>::value" but i made a commit and changed it. it now compiles with c++14 but with c++17 extensions

  • a modern JSON library for C++20 that's convenient to use
  • ** AI GENERATED SHOWCASE THAT'S REVIEWED BY ME **

    Here are some cool and advanced features of the ljson library, with short code snippets for each:

    1. Seamless Construction from C++ Containers

    You can build JSON objects and arrays directly from standard containers (e.g., std::map, std::vector, std::set, etc.): C++

    std::map<std::string, int> obj = {{"a", 1}, {"b", 2}};
    std::vector<std::string> arr = {"x", "y", "z"};
    ljson::node data;
    data.insert("object", obj);
    data.insert("array", arr);
    
    1. Initializer-List Magic (Python/JavaScript-like Syntax)
    ljson::node n = {
        {"name", "Alice"},
        {"age", 30},
        {"active", true},
        {"tags", ljson::node({"dev", "cat_lover"})},
        {"profile", ljson::node({{"city", "Paris"}, {"zip", 75000}})}
    };
    // n is now a JSON object with nested objects and arrays!
    
    1. Type-Safe Value Accessors and Type Queries
    if (n.at("age").is_integer())
        std::cout << "Age: " << n.at("age").as_integer() << "\n";
    if (n.at("tags").is_array()) {
        for (auto& tag : *n.at("tags").as_array())
            std::cout << tag.as_string() << " ";
    }
    
    1. Type-Safe Mutation and Assignment
    n.at("name") = "Bob";      // changes value to "Bob"
    n.at("age")  = 31;         // changes value to 31
    n.at("active") = false;    // changes value to false
    n.at("tags").push_back("gamer"); // add "gamer" to tags array
    
    1. Exception-Free Parsing (Error Handling Without throw)
    auto result = ljson::parser::try_parse(R"({"x":1})");
    if (result) {
        std::cout << "Parsed!\n";
    } else {
        std::cerr << "Parse error: " << result.error().message() << "\n";
    }
    
    1. Pretty Printing and File Output with Custom Indentation
    n.dump_to_stdout({'\t', 2});         // Pretty print using tabs, 2 per indent
    n.write_to_file("output.json");       // Write to file
    std::string s = n.dump_to_string();   // Get pretty JSON string
    
    1. Operator Overloading for JSON Merge and Addition

    Concatenate arrays and objects in a natural way:

    ljson::node a = {1, 2, 3};
    ljson::node b = {4, 5};
    ljson::node c = a + b; // [1,2,3,4,5]
    
    ljson::node obj1 = {{"x", 1}};
    ljson::node obj2 = {{"y", 2}};
    ljson::node obj3 = obj1 + obj2; // {"x":1,"y":2}
    
    1. Automatic Null Support
    n.insert("nothing", ljson::null);
    if (n.at("nothing").is_null())
        std::cout << "It's " << n.at("nothing").stringify() << "!\n"; // It's null!
    
    1. Direct Construction from Nested Initializer Lists
    ljson::node arr = { 1, 2, 3, ljson::node({"nested", "array"}), ljson::null };
    ljson::node obj = { {"a", 1}, {"b", ljson::node({2, 3, 4})}, {"c", ljson::node({"d", 5})} };
    
    1. Safe and Direct Value Setting and Mutation

    You can set a node's value using .set() or assignment:

    n.at("val").set(123.45);
    n.at("flag") = true;
    n.at("sub").insert("newkey", "newval");
    
    1. Full Traversal and Iteration Support
    // Iterating an array
    for (auto& item : *n.at("tags").as_array())
        std::cout << item.as_string() << "\n";
    
    // Iterating an object
    for (auto& [key, value] : *n.as_object())
        std::cout << key << ": " << value.stringify() << "\n";
    
    1. Type-Checked Try-Cast APIs

    Get error info if you try an invalid conversion:

    auto res = n.at("name").try_as_integer();
    if (!res) std::cerr << "Not an integer: " << res.error().message() << "\n";
    
    1. Flexible Construction from Arbitrary Types

    Any supported type (string, int, bool, null, etc.) or nested containers can be used directly in construction or insertion.

    1. Custom Indentation Everywhere
    n.dump_to_stdout({' ', 8}); // 8 spaces per indent
    
    1. Chaining Insertions and Additions
    ljson::node obj = {
        {"a", 1},
        {"b", 2}
    };
    obj += ljson::object_pairs{
        {"c", 3},
        {"d", 4}
    };
    

    Summary: ljson offers a modern, expressive, and type-safe C++ JSON API with C++ types, safety, and STL integration.

  • a modern JSON library for C++20 that's convenient to use
  • thank you! if someone wants a more modern API that's kinda similar to tomlplusplus and a little nicer to use with modern error handling then my library might come in handy. my API is inspired a lot by tomlplusplus . i was trying to make a build system that uses TOML as a config file and I needed a json library so i decided to make my own as a learning experience which was great.

    I'm not familiar with simdjson, but i know a little about nlohmann and I think the exception free path using ljson::expected is a nicer/safer approach. also there is convenient operator overloads in my library to add objects/array together, but nlohmann also has that i think

    // accessing values in ljson
    ljson::node node = ljson::parser::parse(raw_json);
    std::string val = node.at("key").as_string();
    
    // accessing values in nlohmann
    nlohmann::json::json json;
    raw_json >> json;
    std::string val = json["key"].get<std::string>();
    
    
  • safe enum

    for anyone who doesn't know, this "-Werror=switch-enum" compiler option make the compiler throw an error if all of the enum values aren't explicitly handled in a "switch" statement

    ```cpp

    enum class colors { blue, red, purple, }

    void func(colors c) { switch(c) { case colors::blue: // do something break; case colors::red: // do something break; default: // do something break; } }

    int main() { func(colors::blue); } ```

    this code doesn't compile on clang and gcc with the option "-Werror=switch-enum" because the "colors::purple" isn't explicitly handled. be aware that it doesn't throw a compiler error for "if" statements if one of the values isn't handled

    0
    a modern JSON library for C++20 that's convenient to use
    github.com GitHub - nodeluna/ljson: an easy to use header only JSON library for C++20

    an easy to use header only JSON library for C++20. Contribute to nodeluna/ljson development by creating an account on GitHub.

    GitHub - nodeluna/ljson: an easy to use header only JSON library for C++20

    It's not fully finished yet, but it's getting there, and i didn't write documentation beyond the README.md and tests/test.cpp but I'd like some feedback on it.

    features

    • It's a header only library that's currently < 3000 loc
    • no 3rd-party dependencies
    • support for being imported as a module
    • supports inserting std containers into json nodes
    • highly type safe, which is made possible by using concepts
    • easy-to-use object/array iterations
    • easy-to-use type casting from json value to native c++ types which is enabled by std::variant and concepts
    • exception-free parsing and value casting.
    • modern error handling using "expected" type
    • exception-free node.try_at("key") access
    • and more

    edit:

    documentation link: https://nodeluna.github.io/ljson

    3
    a small implementation for std::expected for C++11
    github.com GitHub - nodeluna/expected: an implementation of std::expected for C++11

    an implementation of std::expected for C++11. Contribute to nodeluna/expected development by creating an account on GitHub.

    GitHub - nodeluna/expected: an implementation of std::expected for C++11
    6
    a cli tool that changes your wallpaper when your active workspace changes
  • very fancy and nice to use. i see

    I searched for a River socket or riverctl command that would allow me to get the active workspace number, but i couldn't find a way for that currently in River. so i can't implement it for River not currently at least. unless maybe someone knows a way to get that info who could refer me to the documentation

  • a cli tool that changes your wallpaper when your active workspace changes
    github.com GitHub - nodeluna/lunawp: a tool that changes your wallpaper if your workspace changes

    a tool that changes your wallpaper if your workspace changes - nodeluna/lunawp

    GitHub - nodeluna/lunawp: a tool that changes your wallpaper if your workspace changes

    it works on hyprland, sway or qtile and it uses swww to change the backgroud

    aur: https://aur.archlinux.org/packages/lunawp

    11
    InitialsDiceBearhttps://github.com/dicebear/dicebearhttps://creativecommons.org/publicdomain/zero/1.0/„Initials” (https://github.com/dicebear/dicebear) by „DiceBear”, licensed under „CC0 1.0” (https://creativecommons.org/publicdomain/zero/1.0/)NO
    nodeluna @programming.dev

    https://github.com/nodeluna

    Posts 6
    Comments 12