Skip to content

Instantly share code, notes, and snippets.

Jōshin Steven Dee mrdomino

Block or report user

Report or block mrdomino

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View iter.py
#!/usr/bin/env python
"""
Example demonstrating O(1)-space iteration over binary trees.
"""
class Node(object):
"""
A binary tree node with left-child, right-child, and parent pointers.
"""
View nonascii.c
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
static void
usage(const char* argv0)
{
fprintf(stderr,
"Usage: %s\n"
" Passes spans of non-ASCII characters from stdin to stdout, "
View run-synergy
#!/bin/sh
SERVER=stevens-mac-mini.local
SYNERGY_DIR="$HOME/.config/synergy"
function getpass {
cat "$SYNERGY_DIR/pass" | tr -d '\n' | md5sum | cut -d' ' -f1
}
@mrdomino
mrdomino / example.cc
Last active Aug 29, 2015
Registry sketch
View example.cc
#include <iomanip>
#include <iostream>
#include <utility>
#include "registry.h"
using std::cerr;
using std::cin;
using std::endl;
using std::ios_base;
View fib.c
#include <inttypes.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
uint64_t* fibs;
size_t fib_len;
int
expand_fibs(uint64_t x)
View elias_unary.c
#include <hammer/glue.h>
#include <hammer/hammer.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
HParser* parser;
HBenchmarkResults* results;
View resetter.h
#include <utility>
template <typename T, typename U = T>
class ScopedRestore {
public:
explicit ScopedRestore(T* it):
ref_(*it), old_val_(*it) {}
~ScopedRestore() noexcept(noexcept(this->ref_ = std::move(this->old_val_))) {
using std::move;
ref_ = move(old_val_);
View jrp.c++
#include <cstdlib>
#include <atomic>
#include <exception>
#include <iostream>
#include <memory>
#include <mutex>
#include <utility>
class JrpException : public ::std::exception {};
View c++.c++
#include <cstdio>
#include <future>
#include <map>
#include <memory>
#include <string>
void do_thing(std::string a); // forces a copy
void do_thing_ref(std::string& a); // no copy, can mutate a
void do_thing_ptr(std::string* a); // no copy, can obviously mutate a
View task_queue.c++
#include <cassert>
#include <future>
#include <list>
#include <queue>
#include <thread>
#include <vector>
class State {
public:
State(): started(false), pending_get_values(false), exiting(false) {}
You can’t perform that action at this time.