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
(setq gnus-select-method '(nntp "news.gmane.org"))
;; (setq gnus-select-method '(nntp "news.gwene.org"))
(setq user-full-name "Sajith Sasidharan"
user-mail-address "sajith@hcoop.net")
(setq auth-sources '((:source "~/.authinfo.gpg")))
(setq mml-secure-openpgp-signers '("0x0C6DA6A29D5F02BA")
#include <cstdlib>
// Run this with:
// for c in `seq 0 256`; do ./return $c ; echo $?; done
int main(int argc, char *argv[])
{
if (argc > 1)
return strtol(argv[1], 0, 10);
;; This does not work!
(setq user-mail-address "sajith@hcoop.net"
user-full-name "Sajith Sasidharan")
;; (setq gnus-ignored-newsgroups "")
;; (setq starttls-gnutls-program "/usr/local/bin/gnutls-cli")
(setq gnus-select-method '(nnnil ""))
#include <cassert>
#include <iostream>
#include <set>
#include <stdexcept>
#include <net/if.h>
#include <errno.h>
#include <string.h>
std::set<std::string> getInterfaceNames()
// This code is straight from getifaddrs(3) manpage.
#ifndef _GNU_SOURCE
#define _GNU_SOURCE /* To get defns of NI_MAXSERV and NI_MAXHOST */
#endif
#include <arpa/inet.h>
#include <sys/socket.h>
#include <netdb.h>
#include <ifaddrs.h>
@sajith
sajith / mounts.cc
Last active February 24, 2017 23:29
#include <iostream>
#include <cassert>
#include <stdexcept>
#include <unistd.h>
#include "mounts.h"
static const char* const _PATH_PROC_MOUNTINFO = "/proc/self/mountinfo";
static const char* const _PATH_PROC_MOUNTS = "/proc/mounts";
@sajith
sajith / mounts.h
Last active February 24, 2017 23:29
#ifndef BDE_UTILS_MOUNT_H
#define BDE_UTILS_MOUNT_H
#include <set>
#include <string>
#include <cassert>
#include <libmount/libmount.h>
namespace utils
#include <iostream>
#include <stdexcept>
#include <getopt.h>
#include "mounts.h"
// TODO: if a path is given, and nothing is mounted on it, find its
// parent.
// TODO: handle multiple inputs.
@sajith
sajith / Makefile
Last active February 24, 2017 23:30
URL = https://www.kernel.org/pub/linux/utils/util-linux/v2.27/util-linux-2.27.tar.xz
LIBPATH = /tmp/util-linux-install
CXXFLAGS += -Wall -ggdb -std=c++11
CPPFLAGS += -I$(LIBPATH)/include
LIBMOUNT := $(LIBPATH)/lib/libmount.a
LIBBLKID := $(LIBPATH)/lib/libblkid.a
PROGRAM = mounts-test
#include <iostream>
#include <cassert>
#include <getopt.h>
#include <unistd.h>
#include <libmount/libmount.h>
#define _PATH_PROC_MOUNTINFO "/proc/self/mountinfo"
#define _PATH_PROC_MOUNTS "/proc/mounts"