This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <set> | |
| #include <string> | |
| template<typename... Args> | |
| class T { | |
| public: | |
| T(Args... args) : lst({args...}) { | |
| for (auto const & it : lst) { | |
| std::cout << it << std::endl; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <set> | |
| #include <string> | |
| template<typename... Args> | |
| class T { | |
| public: | |
| T(Args... args) { | |
| std::set<std::string> lst{args...}; | |
| // Or: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace utils | |
| { | |
| class TimeSeriesDB { | |
| public: | |
| TimeSeriesDB(std::string const &host, | |
| int port, | |
| std::string const &db, | |
| std::string const &username="", | |
| std::string const &password="") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| template<typename T, typename... Args> | |
| T add(Args... params); | |
| template<class T> T add(T a) | |
| { | |
| return a; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdlib.h> | |
| #include <string.h> | |
| int main(int argc, char **argv) | |
| { | |
| char tmpl[12]; | |
| strncpy(tmpl, "tmpXXXXXX", 12); | |
| return mkstemp(tmpl); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <unistd.h> | |
| #include <time.h> | |
| std::string ts() | |
| { | |
| auto t = time(nullptr); | |
| auto t2 = localtime(&t); | |
| if (t2 == nullptr) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <gio/gio.h> | |
| // launch using "dbus-launch" | |
| int main(int argc, char **argv) | |
| { | |
| GError *error = 0; | |
| auto conn = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <cstring> | |
| #include <cstdlib> | |
| #include <sys/param.h> | |
| int main(int argc, char **argv) | |
| { | |
| const char * const tmplt = "/tmp/mkdtemp-test-XXXXXX"; | |
| char buffer[MAXPATHLEN] = {0}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <fstream> | |
| #include <cstring> | |
| #include <unistd.h> | |
| #include <time.h> | |
| std::string ts() | |
| { | |
| auto t = time(nullptr); | |
| auto t2 = localtime(&t); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <libgen.h> | |
| #include <unistd.h> | |
| // Given "/foo/bar/baz", go all the way up to "/" | |
| int main(int argc, char *argv[]) | |
| { | |
| auto p = "."; |