Skip to content

Instantly share code, notes, and snippets.

View sajith's full-sized avatar
😼
Why would I want to set a status on GitHub?

Sajith Sasidharan sajith

😼
Why would I want to set a status on GitHub?
View GitHub Profile
#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;
#include <iostream>
#include <set>
#include <string>
template<typename... Args>
class T {
public:
T(Args... args) {
std::set<std::string> lst{args...};
// Or:
namespace utils
{
class TimeSeriesDB {
public:
TimeSeriesDB(std::string const &host,
int port,
std::string const &db,
std::string const &username="",
std::string const &password="")
#include <iostream>
template<typename T, typename... Args>
T add(Args... params);
template<class T> T add(T a)
{
return a;
}
#include <stdlib.h>
#include <string.h>
int main(int argc, char **argv)
{
char tmpl[12];
strncpy(tmpl, "tmpXXXXXX", 12);
return mkstemp(tmpl);
}
#include <iostream>
#include <unistd.h>
#include <time.h>
std::string ts()
{
auto t = time(nullptr);
auto t2 = localtime(&t);
if (t2 == nullptr)
#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);
#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};
#include <iostream>
#include <fstream>
#include <cstring>
#include <unistd.h>
#include <time.h>
std::string ts()
{
auto t = time(nullptr);
auto t2 = localtime(&t);
#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 = ".";