Skip to content

Instantly share code, notes, and snippets.

@o11c
o11c / p.cpp
Created September 24, 2013 19:30
#include <cstdio>
template<class T>
class Pointer
{
T *v;
public:
Pointer(T *t) : v(t) {}
__attribute__((used))
T *operator ->()
@o11c
o11c / gist:6889953
Last active December 25, 2015 00:48
$ apt-cache show weston | grep Depends: | sed 's/Depends: //;s/, */\n/g' | while read pkg version; do echo $pkg $version; apt-cache policy $pkg | grep Installed; echo; done
libegl1-mesa (>= 8.0-2)
Installed: 9.1.6-2+b1
libegl1-mesa-drivers (>= 8.0-2)
Installed: 9.1.6-2+b1
libgles2-mesa (>= 8.0-2)
Installed: 9.1.6-2+b1
@o11c
o11c / test.c
Created October 12, 2013 09:48
A method of detecting whether, for a single target, LLVM supports its AsmParser
//#define current_target X86
#define current_target bogus
#define __STDC_LIMIT_MACROS
#define __STDC_CONSTANT_MACROS
#include "llvm-c/Target.h"
#include <stdbool.h>
#define JOIN2(a, b) a ## b
#define JOIN(a, b) JOIN2(a, b)
@o11c
o11c / tmwa-finger
Created October 17, 2013 20:32
This is a script to check if a TMW server is alive. By default, it checks the main server, but it takes 2 optional arguments: the hostname and the port. You can finger the login server and the char server, but not the map server. For example, $ tmwa-finger caliban.homeip.net $ tmwa-finger server.themanaworld.org 6902 $ tmwa-finger server.themana…
#!/bin/bash -e
SERVER=${1:-server.themanaworld.org}
PORT=${2:-6901}
die() {
echo "$1" >&2
exit 1
}
readbyte() {
local byte REPLY
@o11c
o11c / error.cpp
Created November 2, 2013 20:23
What __attribute__((error)) should accept (neither clang nor gcc generates any call even at -O0).
__attribute__((error("don't call me")))
void dont_call_me();
inline
void wrapper()
{
dont_call_me();
}
void conditional()
@o11c
o11c / gist:7377520
Last active December 27, 2015 19:29
gem errors for github-pages
$ gem install github-pages --user
Building native extensions. This could take a while...
ERROR: Error installing github-pages:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from extconf.rb:1:in `<main>'
@o11c
o11c / not verbose
Last active December 27, 2015 23:39
Errors compiling Rust 0.8 docs
$ make docs
cfg: build triple x86_64-unknown-linux-gnu
cfg: host triples x86_64-unknown-linux-gnu
cfg: target triples x86_64-unknown-linux-gnu
cfg: enabling more debugging (CFG_ENABLE_DEBUG)
cfg: host for x86_64-unknown-linux-gnu is x86_64
cfg: os for x86_64-unknown-linux-gnu is unknown-linux-gnu
cfg: using gcc
cfg: no llnextgen found, omitting grammar-verification
version-info: doc/version_info.html
From 494e6ef67565f7358b415d015018fad6357484e7 Mon Sep 17 00:00:00 2001
From: Ben Longbons <b.r.longbons@gmail.com>
Date: Sat, 16 Nov 2013 00:52:54 -0800
Subject: [PATCH] Allow different attachment policy for pointer and reference
---
include/clang/Format/Format.h | 6 +++++-
lib/Format/Format.cpp | 23 +++++++++++++++++------
lib/Format/TokenAnnotator.cpp | 6 +++---
3 files changed, 25 insertions(+), 10 deletions(-)
@o11c
o11c / model.cpp
Created November 27, 2013 01:10
Compiler fail
#include <memory>
#include <vector>
struct Model
{
virtual ~Model() {}
};
struct PositionedModel : public Model
{
// amd64
typedef unsigned long size_t;
void *tor_realloc(void *, size_t);
typedef struct smartlist_t {
/** @{ */
/** <b>list</b> has enough capacity to store exactly <b>capacity</b> elements
* before it needs to be resized. Only the first <b>num_used</b> (\<=
* capacity) elements point to valid data.