Skip to content

Instantly share code, notes, and snippets.

bparker06 /
Created Jul 31, 2017 — forked from anonymous/
Show the AST of a translation unit with libclang and python
# inspired by
import sys
import clang.cindex
def verbose(*args, **kwargs):
'''filter predicate for show_ast: show all'''
return True
def no_system_includes(cursor, level):
'''filter predicate for show_ast: filter out verbose stuff from system include files'''
bparker06 / gist:015fa0c99665ed325ca94811b0b7fdb1
Created Sep 11, 2017 — forked from samhocevar/gist:00eec26d9e9988d080ac
Configure sshd on MSYS2 and run it as a Windows service
View gist:015fa0c99665ed325ca94811b0b7fdb1
# — configure sshd on MSYS2 and run it as a Windows service
# Please report issues and/or improvements to Sam Hocevar <>
# Prerequisites:
# — MSYS2 itself:
# — admin tools: pacman -S openssh cygrunsrv mingw-w64-x86_64-editrights
bparker06 / vector.c
Created Oct 2, 2017
Simple vector-implementation in C
View vector.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "vector.h"
void vector_init(vector *v)
v->data = NULL;
v->size = 0;
bparker06 /
Created Jan 7, 2018 — forked from fracting/
Guide to use MSYS2 on Wine
Steps to use MSYS2, pacman and makepkg in Wine

Compile and Install Wine

  1. IMPORTANT Install lastest Wine-Staging. Wine Staging provides pre-build package for a couple of distributions every two weeks. However, until last update of this wiki, new wine-staging package is not ready yet, so early testers should compile wine-staging by themselves.

Install MSYS2

  1. Backup or remove your old wineprefix:
bparker06 / test.c
Created Jan 7, 2018 — forked from nad2000/test.c
Basic examples to show how to embed and extend Python in C including: creation of module in C with functions handling and building Python objects; importing and calling python functions from C.
View test.c
/* Example of embedding Python in another program */
// to compile run:
// gcc -o test $(python-config --cflags) test.c $(python-config --ldflags) && ./test
#include "Python.h"
void initxyzzy(void); /* Forward */
main(int argc, char **argv)
bparker06 / lfsr.c
Created Feb 9, 2018 — forked from rcc/lfsr.c
C LFSR Library
View lfsr.c
* lfsr.c - lfsr library
* Copyright (C) 2009 Robert C. Curtis
* lfsr.c is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
bparker06 / gmake-patsubst.c
Created Apr 4, 2018 — forked from gromnitsky/gmake-patsubst.c
An extract of patsubst function from GNU Make
View gmake-patsubst.c
An extract of patsubst function from GNU Make 4.2.90
$ cc gmake-patsubst.c -o gmake-patsubst
$ ./gmake-patsubst %.c %.o 'foo.c bar.c'
foo.o bar.o
#include <stdio.h>
bparker06 / memcpy.c
Created May 30, 2018 — forked from nicky-zs/memcpy.c
One way to solve the glibc compatibility problem. In my case, when building a program with libthrift.a on linux with glibc version 2.15, ld always links memcpy@GLIBC_2.14 which cannot be found on systems with glibc version < 2.14. So, use this file to define a symbol __wrap_memcpy and use -Wl,--wrap=memcpy to tell ld using this symbol when meeti…
View memcpy.c
#include <string.h>
void *__memcpy_glibc_2_2_5(void *, const void *, size_t);
asm(".symver __memcpy_glibc_2_2_5, memcpy@GLIBC_2.2.5");
void *__wrap_memcpy(void *dest, const void *src, size_t n)
return __memcpy_glibc_2_2_5(dest, src, n);
bparker06 / to_string
Created Jul 10, 2018 — forked from shanehsu/to_string
C++ to_string alternative
View to_string
#include <sstream>
template <typename T>
std::string to_string(const T& value) {
std::stringstream ss;
ss << value;
return ss.str();
int i = 0;
bparker06 /
Created Jul 11, 2018 — forked from Grokzen/
Symmetrical ManyToMany Filter Horizontal in Django Admin
# Based on post from:
# Only reposting to avoid loosing it.
When adding a many-to-many (m2m) relationship in Django, you can use a nice filter-style multiple select widget to manage entries. However, Django only lets you edit the m2m relationship this way on the forward model. The only built-in method in Django to edit the reverse relationship in the admin is through an InlineModelAdmin.
Below is an example of how to create a filtered multiple select for the reverse relationship, so that editing entries is as easy as in the forward direction.
### pizza/ ###
You can’t perform that action at this time.