Skip to content

Instantly share code, notes, and snippets.

View codebrainz's full-sized avatar

Matthew Brush codebrainz

View GitHub Profile
@codebrainz
codebrainz / gist:5660538
Created May 28, 2013 04:30
Read a file into a C character array. Keep in mind the file may very well contain `nul` bytes in it.
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
int main(int argc, char *argv[])
{
FILE *fp;
long size;
char *buf;
@codebrainz
codebrainz / test-results.md
Last active December 22, 2015 23:08
Some measurements made to test various optimization times in part of Geany's completion code.

Test Results

Code was instrumented to call autocomplete_doc_word() 10,000 times in a row. Each test was run on the same file, the syntax.text file containing Markdown specification, with no filetype set in Geany, and trying to auto-complete same 3 words. The test was run 3 times for each variation of the optimizations.

Original Geany Code Runs

  1. 5.382154 seconds
  2. 5.455590 seconds
@codebrainz
codebrainz / gist:7047610
Last active December 25, 2015 22:09
Add test harness for Geany's core code
diff --git a/.gitignore b/.gitignore
index 51cdd7b..678a68f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -103,3 +103,5 @@ Makefile.in
#-----------------------------------------------------------------------
/tests/**/*.trs
/tests/**/*.log
+/tests/*.log
+/src/test*.log
using Gtk;
namespace Geany
{
public class Object : GLib.Object
{
// Document signals
public signal void document_new(Document doc);
public signal void document_open(Document doc);
/*
* geanyobject.c - this file is part of Geany, a fast and lightweight IDE
*
* Copyright 2007-2012 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* Copyright 2007-2012 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
*
* This program 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.
@codebrainz
codebrainz / gist:7403171
Created November 10, 2013 20:03
Another geanyobject.vala since the previous gist doesn't work.
using Gtk;
namespace Geany
{
public class Object : GLib.Object
{
// Document signals
public signal void document_new(Document doc);
public signal void document_open(Document doc);
@codebrainz
codebrainz / Makefile
Created January 18, 2014 20:56
Geany plugin to toggle long line marker between off and line mode using keybinding or menu item.
#!/usr/bin/env make
llt_cflags = $(CFLAGS) -g -Wall -Werror $(shell pkg-config --cflags geany)
llt_ldflags = $(LDFLAGS) $(shell pkg-config --libs geany)
all: llt.so
llt.so: plugin.o
$(CC) -shared $(llt_cflags) -o $@ $^ $(llt_ldflags)
@codebrainz
codebrainz / gist:8621904
Last active December 14, 2018 08:06
fontconfig settings
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<!--
Disable "faked bold" done when font doesn't have bold style
-->
<match target="font">
<test name="spacing" compare="eq">
#include <stdlib.h>
int main()
{
return 0;
}
Index: tagmanager/python.c
===================================================================
--- tagmanager/python.c (revision 5850)
+++ tagmanager/python.c (working copy)
@@ -478,6 +478,9 @@
for (; *cp; cp++)
{
+ if (*cp == '#')
+ break;