Skip to content

Instantly share code, notes, and snippets.

View chergert's full-sized avatar
💭
I'm on GitLab https://gitlab.gnome.org/chergert

Christian Hergert chergert

💭
I'm on GitLab https://gitlab.gnome.org/chergert
View GitHub Profile
@chergert
chergert / gtktextview+gtkpixecache.patch
Created August 15, 2013 08:02
Use GtkPixelCache inside of GtkTextView. This still doesn't feel interactive enough for me. There needs to be some tweaks on the size of the area to pre-render. Likely in the half-page or so on each boundary.
testdiff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 3aa1047..1dff1e2 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -53,6 +53,7 @@
#include "gtkcssstylepropertyprivate.h"
#include "gtkbubblewindowprivate.h"
#include "gtktoolbar.h"
+#include "gtkpixelcacheprivate.h"
@chergert
chergert / queue.h
Last active July 20, 2022 14:43
A thread-safe blocking LIFO or FIFO queue with maximum backlog.
#include <limits.h>
#include <pthread.h>
#include <stdlib.h>
typedef struct _queue_t queue_t;
typedef struct _queue_node_t queue_node_t;
struct _queue_node_t
@chergert
chergert / g-interval-source.c
Last active December 19, 2015 10:49
A GSource backed by timerfd. I'm not sure this is even useful, just a prototype.
/* g-interval-source.c
*
* Copyright (C) 2013 Christian Hergert <christian@hergert.me>
*
* This file is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This file is distributed in the hope that it will be useful,
@chergert
chergert / bson-encoder.c
Last active December 18, 2015 13:59
GObject <-> BSON encoder Transparently convert GObjects to and from BSON using libbson.
/*
* Copyright 2013 Christian Hergert <christian@hergert.me>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
/*
* Copyright 2013 10gen Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
/* gcc iobomb.c -o libiobomb.so -shared -fPIC -lpthread */
#include <assert.h>
#include <dlfcn.h>
#include <errno.h>
#include <fcntl.h>
#include <pthread.h>
#include <unistd.h>
@chergert
chergert / gist:5062236
Last active December 14, 2015 09:08
builder design
Things that need to be written
==============================
GbProject // A project container. Can be saved/loaded to/from disk.
GbProjectItem // Base class, for items in a project.
GbProjectFile // A file that can exist in a project.
GbProjectTarget // A target within a project, like a library/program.
GbProjectDependency // Base class, handles success/failure cases.
GbProjectDependencyFramework // Depends on availability of a gnome framework.
@chergert
chergert / touchy.py
Created December 20, 2012 09:42
basic touch test using gtk and touch events
#!/usr/bin/env python
import cairo
from gi.repository import Gdk
from gi.repository import Gtk
colors = ['a40000', '75507b', '8ae234', '729fcf', 'f57900',
'c4a000', 'ce5c00', 'eeeeec', '4e9a06', '204a87']
def next_idx(seq):
@chergert
chergert / main.c
Created November 15, 2012 22:25
A URL router N-ary tree that can extract parameters from URL
#include "url-router.h"
static void
user_cb (UrlRouter *router,
SoupServer *server,
SoupMessage *message,
const gchar *path,
GHashTable *params,
GHashTable *query,
SoupClientContext *client,
@chergert
chergert / asserts.md
Created November 14, 2012 00:30
when to use g_assert and when to use g_return_*if_fail()

When to use g_assert* and when to use g_return* macros

Do use g_assert() when:

  • The function is static inside your implementation
  • If the precondition fails the entire module you have is in an inconsistent state

Do use g_return_{,val_}if_fail() when:

  • For pre-conditions and post-conditions.