Skip to content

Instantly share code, notes, and snippets.

@acmorrow
acmorrow / gist:db74587167e0e83d8ebfde702228c9cb
Created May 5, 2021 03:22
Repro for _concat not forwarding for_signature to generators
import atexit
calls = 0
signature_calls = 0
def some_generator(target, source, env, for_signature):
global calls, signature_calls
calls += 1
if for_signature:
signature_calls += 1
/usr/bin/time /opt/mongodbtoolchain/v3/bin/python3 buildscripts/scons.py --dbg=on --opt=on --link-model=dynamic --implicit-cache --cache --experimental-visibility-support=on --install-action=hardlink --build-tools=next --disable-warnings-as-errors --modules= --build-dir=$(pwd)/build/toolpy37 --cache-dir=$(pwd)/cache -j300 install-unittests --debug=time 2>&1 | tee toolpy37.cleanbuild.log
/usr/bin/time python3.8 buildscripts/scons.py --dbg=on --opt=on --link-model=dynamic --implicit-cache --cache --experimental-visibility-support=on --install-action=hardlink --build-tools=next --disable-warnings-as-errors --modules= --build-dir=$(pwd)/build/syspy38 --cache-dir=$(pwd)/cache -j300 install-unittests --debug=time 2>&1 | tee syspy38.cleanbuild.log
\rm -rf build/toolpy37/cached build/toolpy37/install
/usr/bin/time /opt/mongodbtoolchain/v3/bin/python3 buildscripts/scons.py --dbg=on --opt=on --link-model=dynamic --implicit-cache --cache --experimental-visibility-support=on --install-acti
@acmorrow
acmorrow / canary.cpp
Created October 18, 2016 20:39
Manual stack canary
namespace {
class Canary {
public:
static constexpr size_t kSize = 1024;
explicit Canary(volatile unsigned char* const t) noexcept : _t(t) {
::memset(const_cast<unsigned char*>(_t), kBits, kSize);
_verify();
@acmorrow
acmorrow / magic
Created August 12, 2014 20:36
unique_ptr example for using void*
#ifndef LIBFOO_H_INCLUDED
#define LIBFOO_H_INCLUDED
#pragma once
#include "libfoo_export.h"
#if defined(__cplusplus)
#define LIBFOO_NOEXCEPT noexcept
OS X:
mkdir SKUNKWORKS
cd SKUNKWORKS
git clone https://github.com/acmorrow/mongo
cd mongo
git checkout sw-cmake
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug -G Ninja
@acmorrow
acmorrow / mmsx.js
Created September 20, 2013 18:15
Expanded update benchmark
var numDatabases = 3;
var numDocumentsPerCollection = 5;
var collections = [];
for ( var i=0; i<numDatabases; i++ ) {
collections.push( db.getSisterDB("mms" + i).things );
}
var base = { a : 0, h : {}, z : 0 };
// In C++11, one constructor can call another, so we don't need to rewrite
// the initializer list again() and again() and again() and again()...
struct Thing {
Thing(std::string name, Color color)
: name_(std::move(name))
, color_(color) {}
Thing(std::string name)
: Thing(name, Color::Green) {}
// In C++03, we need to resort to tricks or funky
// base classes to control whether classes are copyable:
class Foo : public boost::noncopyable{};
class Bar {
private:
Bar(const Bar&); // Not implemented
Bar& operator=(const Bar&); // Not implemented
};
// In C++11, we can ask for the size of a type for which we don't have an instance:
class Tcp6Socket {
public:
struct SockAddr { ... };
};
char buf[1024];
static_assert(sizeof(buf) >= sizeof(Tcp6Socket::SockAddr));
// Can't do that in C++03, but it works in C++11
// C++11 offers a built-in "owning" pointer which allows transfer of ownership
// and manages lifetime but disallows copying. There is no runtime overhead for its use:
std::unique_ptr<socket> connect_to(const std::string& host, int port) {
/// ...
return new socket(fd);
}
{
auto connected = connect_to("www.10gen.com", 80);