Skip to content

Instantly share code, notes, and snippets.

View johnbartholomew's full-sized avatar

John Bartholomew johnbartholomew

View GitHub Profile
@johnbartholomew
johnbartholomew / backtrace.txt
Created June 28, 2014 19:30
Pioneer crash information for serialisation crash
Charon:
height fractal: HillsCraters2
colour fractal: Rock
seed: 2191294907
*** Error in `/home/dv/src/pioneer/src/pioneer': double free or corruption (!prev): 0x0000000002ac5d20 ***
Program received signal SIGABRT, Aborted.
0x00007ffff5bb3f79 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56 ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
@johnbartholomew
johnbartholomew / gist:9497219
Created March 11, 2014 23:25
Inserting a breakable call
/* Another option which is more reasonable if you're willing to recompile is to insert a call to a trap function
* could be __builtin_trap() for GCC, or DebugBreak/__debugbreak for MSVC, or your own function like this: /
static void PoorMansBreakpoint() {
printf(""); /* stick a breakpoint on this line */
}
int fugbug(int a, int b) {
return (a + b < 10)
? 8
@johnbartholomew
johnbartholomew / check.c
Created March 11, 2014 22:38
GNU C supports using compound statements as expressions.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, char **argv) {
if (argc < 2) {
fprintf(stderr, "usage: check x|y\n");
return 1;
}
@johnbartholomew
johnbartholomew / fontconfig-example.c
Created February 24, 2014 22:01
Using FontConfig to pick a default font.
/* WARNING -- THE CODE IN THIS FILE DOESN'T DO ANY ERROR HANDLING! */
static const char *TXDI_DEFAULT_FAMILY_NAMES[] = {
"monospace",
"sans",
"serif"
};
TXD_API TxdFont *txd_opendefaultfont(int family, int style, float height, float slant, float outline) {
FcPattern *pat, *match;
@johnbartholomew
johnbartholomew / no-init-list.cpp
Created January 21, 2014 23:14
Testing nested initializer-lists without initializer-list constructors.
/* Compiles and works with recent GCC and Clang in C++11 mode.
* $ g++ --version
* g++ (GCC) 4.8.2 20131219 (prerelease)
*
* $ clang++ --version
* clang version 3.4 (tags/RELEASE_34/final)
*/
#include <vector>
#include <iostream>
@johnbartholomew
johnbartholomew / match-time.sh
Last active January 2, 2016 23:49
bad regex! no cookie!
#!/bin/sh
a5=aaaaa
a27="$a5$a5$a5$a5$a5"aa
aq5='a?a?a?a?a?'
aq27="$aq5$aq5$aq5$aq5$aq5"'a?a?'
pattern="$aq27$a27"
input="$a27"
#include "nfa.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void) {
Nfa *nfa;
NfaBuilder builder;
nfa_builder_init(&builder);
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
static const char MESSAGE[] = "Hello, world!\n";
int main(void) {
char fname[64];
int fd;

I'm not trying to precisely match the behaviour of an existing glob syntax unless that behaviour really seems like the most obvious/easiest-to-use syntax. However, I do want globs to feel familiar to use.

I'll say that '**' matches anything, and '*' matches anything except directory separators. Without thinking too hard, how do you expect the following globs to behave?

  1. *.c
  2. **.c
  3. **/*.c