A little expository C++ project for choosing raffle winners at C++ meetup events.
It fetches the names of all the event's RSVP members and randomly chooses a winner.
The winner is selected only from members that RSVPed "yes" for the event.
It does not take into account any +N
guests, or non-RSVP attendees.
The code is designed to fit on a single slide (excluding HTTP/JSON libs).
Interesting C++ features used by the code include:
filesystem::path
;std::string_literals
;std::mt19937
andstd::random_device
;- Ranges TS-ish usage, showing both
view
s andaction
s; - Networking TS-ish usage for fetching data
> meetup_raffle <meetup.com API key> <Group URL Name> [More Group URL Names]
If the chosen member is not present (despite the RSVP), type more
Enter ⏎ for another randomly chosen name.
- Use git to clone and update the submodules;
- Use CMake to build, providing it with the proper Boost paths;
- Do a short talk reviewing/auditing the application C++ code;
- Run at your event to choose the raffle winner!
- Boost.Beast from Boost: Access the Meetup REST API.
- nlohmann::json: For JSON processing
- Ranges-v3-VS2015: Because Ranges.
Ranges is a git submodules, Beast ships with Boost and needs to be supplied externally and the single JSON file json.hpp
is already in. When Ranges are adopted into C++, they will no longer be needed as separate dependencies.
The code is far from perfect and can surely be improved for both exposition and clarity.
Contributions and pull requests will be gladly accepted:
- Support for non-MSVC/Windows builds.
- Allow event selection based on date, when there are more than one (currently chooses the first event).
- Any suggestions, remarks, ideas - please open and issue and/or make a PR.
🎫
Finally, if you used this in a raffle, please let me know.
It will make me very happy!
🎫
- Ben Deane presented a snippet from this code at his "Best Presentation" award winning CppNow 2018 presentation: "Easy to Use, Hard to Misuse: Declarative Style in C++"