Skip to content

Instantly share code, notes, and snippets.

View codebrainz's full-sized avatar

Matthew Brush codebrainz

View GitHub Profile
@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);
/*
* 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.
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 / 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
@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: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 / main.c
Created October 13, 2012 07:20
ASCII Characters
------------------------------------------------------------------------------
| Dec | Oct | Hex | Binary | Asc | Description |
------------------------------------------------------------------------------
| 0 | 0000 | 00 | 00000000 | NUL | Null char |
| 1 | 0001 | 01 | 00000001 | SOH | Start of Heading |
| 2 | 0002 | 02 | 00000010 | STX | Start of Text |
| 3 | 0003 | 03 | 00000011 | ETX | End of Text |
| 4 | 0004 | 04 | 00000100 | EOT | End of Transmission |
| 5 | 0005 | 05 | 00000101 | ENQ | Enquiry |
| 6 | 0006 | 06 | 00000110 | ACK | Acknowledgment |
@codebrainz
codebrainz / tabsort.c
Last active October 26, 2021 23:55
Automatically Sort Geany's Document Tabs
#include <geanyplugin.h>
GeanyData *geany_data;
GeanyPlugin *geany_plugin;
GeanyFunctions *geany_functions;
PLUGIN_VERSION_CHECK(211);
PLUGIN_SET_INFO("Tab Sort",
"Automatically keeps document tabs sorted",
@codebrainz
codebrainz / c99.l
Created June 14, 2012 23:49
C99 Lex/Flex & YACC/Bison Grammars
D [0-9]
L [a-zA-Z_]
H [a-fA-F0-9]
E ([Ee][+-]?{D}+)
P ([Pp][+-]?{D}+)
FS (f|F|l|L)
IS ((u|U)|(u|U)?(l|L|ll|LL)|(l|L|ll|LL)(u|U))
%{
#include <stdio.h>
@codebrainz
codebrainz / gist:2353163
Last active November 11, 2015 02:40
Add some more open source license to Geany
diff --git a/data/geany.glade b/data/geany.glade
index 3c04578..184cce0 100644
--- a/data/geany.glade
+++ b/data/geany.glade
@@ -269,6 +269,26 @@
</object>
</child>
<child>
+ <object class="GtkMenuItem" id="insert_apache2_notice1">
+ <property name="use_action_appearance">False</property>