Skip to content

Instantly share code, notes, and snippets.

Avatar

John Bartholomew johnbartholomew

View GitHub Profile
@johnbartholomew
johnbartholomew / backtrace.txt
Created Jun 28, 2014
Pioneer crash information for serialisation crash
View backtrace.txt
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 Mar 11, 2014
Inserting a breakable call
View gist:9497219
/* 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 Mar 11, 2014
GNU C supports using compound statements as expressions.
View check.c
#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 Feb 24, 2014
Using FontConfig to pick a default font.
View fontconfig-example.c
/* 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 Jan 21, 2014
Testing nested initializer-lists without initializer-list constructors.
View no-init-list.cpp
/* 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 Jan 2, 2016
bad regex! no cookie!
View match-time.sh
#!/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"
View nfa-example-1.c
#include "nfa.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void) {
Nfa *nfa;
NfaBuilder builder;
nfa_builder_init(&builder);
View test-mkstemp.c
#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;
View globbing-notes.md

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