Skip to content

Instantly share code, notes, and snippets.

View thomaslee's full-sized avatar
👾

Tom Lee thomaslee

👾
View GitHub Profile
use os;
task_b some_func {
os.sleep(5); # give task_a time to die.
some_func();
}
task_a {
#
# Compile some_module.chimp, return a module object.
#include <iostream>
#include <vector>
#include <map>
#include <functional>
class some_arg_t {
public:
some_arg_t(const char *name) : name_(name) {};
const char *name() const { return name_.c_str(); }
tom@laptop:~/Source/chimp$ g++ -o foo foo.cc
foo.cc: In function ‘int main(int, char**)’:
foo.cc:36:32: error: no match for ‘operator=’ in ‘f.std::map<_Key, _Tp, _Compare, _Alloc>::operator[]<std::basic_string<char>, std::unary_function<const some_arg_t&, int>, std::less<std::basic_string<char> >, std::allocator<std::pair<const std::basic_string<char>, std::unary_function<const some_arg_t&, int> > > >((* & std::basic_string<char>(((const char*)"a"), (*(const std::allocator<char>*)(& std::allocator<char>()))))) = std::ptr_fun<some_arg_t, int>(do_a)’
foo.cc:36:32: note: candidate is:
In file included from /usr/include/c++/4.7/string:50:0,
from /usr/include/c++/4.7/bits/locale_classes.h:42,
from /usr/include/c++/4.7/bits/ios_base.h:43,
from /usr/include/c++/4.7/ios:43,
from /usr/include/c++/4.7/ostream:40,
from /usr/include/c++/4.7/iostream:40,
@thomaslee
thomaslee / fn_ptrs.cc
Created January 15, 2013 07:50
Unary function pointers in C++ for Dan W
#include <iostream>
#include <map>
#include <functional>
class some_arg_t {
public:
some_arg_t(const char *name) : name_(name) {};
const char *name() const { return name_.c_str(); }
@thomaslee
thomaslee / chimp_gc.h
Created October 14, 2012 01:50
Pin a GC value to the machine stack.
#define CHIMP_GC_MAKE_STACK_ROOT(p) \
(*((ChimpRef **)alloca(sizeof(ChimpRef *)))) = (p)
/* http://github.com/thomaslee/chimp */
@thomaslee
thomaslee / gist:2580882
Created May 2, 2012 22:00
git-stashrebase
#!/bin/bash
set -ex
git stash
trap "git stash pop" EXIT TERM
git rebase "$@"
@thomaslee
thomaslee / gist:1631383
Created January 18, 2012 06:06
Generating & Publishing a GPG Key
1. Generate key pair and revocation certificate.
$ gpg --gen-key
$ gpg --output revoke.asc --gen-revoke <key-id>
2. Export ASCII copy of the key (often useful!)
$ gpg --export --armor <key-id> >pubkey.asc
3. Set new keyserver (default is busted on Linux Mint 12 -- others too?): e.g. hkp://stinkfoot.org
@thomaslee
thomaslee / gist:1631057
Created January 18, 2012 05:00
Building Debian Packages
Notes from here: http://www.webupd8.org/2010/01/how-to-create-deb-package-ubuntu-debian.html
This assumes you're using autotools to build your project.
1. sudo apt-get install build-essential autoconf automake autotools-dev dh-make debhelper devscripts fakeroot xutils lintian pbuilder
2. We want a source folder with the pattern: <package>-<version>
$ cd ginvoke
$ git archive --format=tar --prefix=ginvoke-$(date +'%Y%m%d')/ master | tar xvf - -C ..
@thomaslee
thomaslee / aout.c
Created December 18, 2011 05:33
"Hello World" in cue -- a (throwaway) experiment in compiler geekery
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <memory.h>
typedef struct _Module {
const char *name;
} Module;