Skip to content

Instantly share code, notes, and snippets.

@jmlvanre
jmlvanre / systemd-verify.cc
Created September 23, 2015 23:32
systemd-verify
// clang++-3.6 -std=c++11 verify.cc -overify-systemd; ./verify-systemd
#include <sstream>
#include <stdexcept>
#include <string>
#include <string.h>
#include <stdio.h>
@jmlvanre
jmlvanre / systemd.md
Last active August 29, 2015 14:24
Understanding Cgroup Migration on SystemD

#Make the following files:

Note: depending on your system you may need to modify the following variables SYSTEMD_LIB_DIR and GROUP_DIR

bad-cgroup-demo.service

[Unit]
Description=Systemd bad cgroup demo

[Service]
@jmlvanre
jmlvanre / mesos-ssl.md
Last active August 29, 2015 14:23
Mesos SSL
layout
documentation

#Configuration There is currently only one implementation of the libprocess socket interface that supports SSL. This implementation uses libevent. Specifically it relies on the libevent-openssl library that wraps openssl.

After build Mesos 0.23.0 from source, assuming you have installed the required Dependencies, you can modify your configure line to enable SSL as follows:

@jmlvanre
jmlvanre / lambda_style.md
Last active August 29, 2015 14:19
lambda style
auto lambda = [] () { return true };

auto lambda = [] () {
  ...;
};

socket.send([] () {
  ...;
@jmlvanre
jmlvanre / mesos_c++_upgrade.md
Last active August 29, 2015 14:18
Mesos C++ Upgrade

Focus:

As the full c++11 feature set is rather extensive, we want to start the upgrade to c++11 with 3 main areas of focus:

  1. Lambdas
  2. Unrestricted Unions
  3. Move semantics

Lambdas:

  • Definition:
@jmlvanre
jmlvanre / gcc_4_7_features.md
Last active August 29, 2015 14:18
New GCC Features 4.4 => 4.7
  • Range-based For Loop:
    • We can now write for loops as such:
    std::map<K, V> data;
    for (const std::pair<K, V>& pair : data) {}
    for (const auto& pair : data) {}
  • Explicit Virtual Override:
    • We can now introduce a safety measure on virtual function override so that if the base prototype changes, our program will no longer compile until the override definition has been changed to match. This is a great safety measure in a growing code base.
@jmlvanre
jmlvanre / const_ref_to_temporary.md
Last active September 26, 2020 00:20
[Proposal] Const Reference to Temporary style-guide

Proposal:

We modify the style guide to disallow constant references to temporaries as a whole. This means disallowing both Case 1 and Case 2 below.

Background:

  • Case 1: Constant references to simple expression temporaries do extend the lifetime of the temporary till end of function scope:
    • a) Temporary returned by function:
    // See full example below.

T f(const char* s) { return T(s); }

@jmlvanre
jmlvanre / template_storage
Created January 29, 2015 00:01
Templatized storage without forward declaration of types
#include <unordered_set>
/* Templatized storage without forward declaration of types. */
class TC {
public:
template<typename T>
class TM {
public:
virtual ~TM() { C->Part(this); }
protected:
class IP {
enum family {
INET,
INET6
};
virtual ~IP() {}
inline family getFamily() const {
return _family;
}
virtual setSockAddrIn(sockaddr_in& data) const = 0;
class StreamImpl : public std::enable_shared_from_this {
  public:
  virtual ~StreamImpl() {}
  virtual Future<size_t> write(const std::string& data) = 0;
  private:
  std::shared_ptr<StreamImpl> self;
};

class SocketImpl : public StreamImpl {