Skip to content

Instantly share code, notes, and snippets.

View codebrainz's full-sized avatar

Matthew Brush codebrainz

View GitHub Profile
^C
Program received signal SIGINT, Interrupt.
0x00007ffff744e8dd in poll () at ../sysdeps/unix/syscall-template.S:81
81 ../sysdeps/unix/syscall-template.S: No such file or directory.
(gdb) bt
#0 0x00007ffff744e8dd in poll () at ../sysdeps/unix/syscall-template.S:81
#1 0x00007ffff2398bd2 in ?? () from /usr/lib/x86_64-linux-gnu/libxcb.so.1
#2 0x00007ffff239a4df in ?? () from /usr/lib/x86_64-linux-gnu/libxcb.so.1
#3 0x00007ffff239a5f1 in xcb_wait_for_reply ()
from /usr/lib/x86_64-linux-gnu/libxcb.so.1
@codebrainz
codebrainz / win32-unicode.patch
Last active December 13, 2015 23:10
Make Geany agnostic to Win32 API text encoding
diff --git a/src/win32.c b/src/win32.c
index 34b7d93..f5ffc9a 100644
--- a/src/win32.c
+++ b/src/win32.c
@@ -32,6 +32,10 @@
/* Needed for SHGFP_TYPE */
#define _WIN32_IE 0x0500
+#ifndef UNICODE
+# define UNICODE
@codebrainz
codebrainz / libsig.h
Last active February 10, 2022 08:08
Trivial C++ signal/callback mechanism
/*
* libsig.h - Trivial signal/callback library.
*
* Copyright (c) 2015 Matthew Brush <[email protected]>
* You can use this code under the MIT license as described here:
* https://opensource.org/licenses/MIT
*
* To create a signal, declare member variables of type
* `libsig::signal<...>` in your class. The template parameter is the
* argument types that will be passed to the callback functions.
@codebrainz
codebrainz / lex.py
Last active March 20, 2021 20:56
Simple tokenizing in Python
#!/usr/bin/env python3
import re
from collections import namedtuple
class Tokenizer:
Token = namedtuple('Token', 'name text span')
def __init__(self, tokens):
@codebrainz
codebrainz / license.txt
Last active March 27, 2025 10:35
MJPEG Player in JavaScript
Copyright 2015 Matthew Brush
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
@codebrainz
codebrainz / newwin_dynamic.patch
Created July 28, 2015 01:03
Fix "Open in New Window" feature
diff --git a/src/utils.c b/src/utils.c
index c5edd5a..37ae12a 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -2154,30 +2154,35 @@ const gchar *utils_resource_dir(GeanyResourceDirType type)
void utils_start_new_geany_instance(const gchar *doc_path)
{
- const gchar *const *argv;
const gchar *command = is_osx_bundle() ? "open" : "geany";
@codebrainz
codebrainz / main.c
Created June 23, 2015 02:48
List include files using libclang
#include <stdio.h>
#include <stdlib.h>
#include <clang-c/Index.h>
enum CXChildVisitResult
onVisitCursor(CXCursor cursor, CXCursor parent, CXClientData client_data)
{
if (clang_getCursorKind(cursor) == CXCursor_InclusionDirective) {
CXFile file = clang_getIncludedFile(cursor);
AC_DEFUN([AX_POSIX], [
AC_MSG_CHECKING([for POSIX 2008 support])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#define _POSIX_C_SOURCE 200809L
#include <unistd.h>
# if !defined(_POSIX_VERSION) || _POSIX_VERSION < 200809L
# error "Not POSIX 2008"
#endif
int main() { return 0; }
])], [
@codebrainz
codebrainz / gist:95681f9d30937359f6f5
Last active August 29, 2015 14:16
Make "hunting for Scintilla" a little more robust
diff --git a/src/document.c b/src/document.c
index 8a57d93..edaed0d 100644
--- a/src/document.c
+++ b/src/document.c
@@ -226,16 +226,8 @@ GeanyDocument *document_find_by_filename(const gchar *utf8_filename)
/* returns the document which has sci, or NULL. */
GeanyDocument *document_find_by_sci(ScintillaObject *sci)
{
- guint i;
-
@codebrainz
codebrainz / gist:8587a1ddc8e020a71fef
Last active January 11, 2022 16:25
Simple assembly parser in Bison
%{
#include "stdinc.h"
#include "parser.h"
#include "tokens.h"
#include "lexer.h"
static void parser_error(YYLTYPE *locp, struct Parser* par, const char *message);
#define parser_lex(a,b,c) parser_lex(a,b,(c)->scanner)