Skip to content

Instantly share code, notes, and snippets.

View sahib's full-sized avatar

Chris Pahl sahib

View GitHub Profile
sahib / pre-commit
Last active August 29, 2015 14:05
Pre commit hook for rmlint - put in .git/hooks/pre-commit and chmod +x it.
# Shamelessly stolen from:
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
# To enable this hook, rename this file to "pre-commit".
#!/usr/bin/env python
# encoding: utf-8
from gi.repository import Gtk, GLib, Gio
import sys
class MainWindow(Gtk.ApplicationWindow):
def __init__(self, app):
Gtk.Window.__init__(self, title="Welcome to Gylfeed", application=app)
#include <gio/gunixmounts.h>
#include <glib.h>
/* Compile with:
gcc list-disks.c $(pkg-config --libs --cflags gio-unix-2.0) -std=c11 -ggdb3 -W -Wall
int main(void) {
sahib / app.css
Created February 9, 2015 11:21
Small & colorful indicator label for Gtk
/* Support for colored labels.
* These are sometimes handy in order to highlight errors
* or mark some entries with "xx new items".
#AppIndicatorLabelTheme {
/* Animate changes so the label color gets faded in */
sahib / get-n-fds.c
Created February 24, 2015 19:30
Find number of file descriptor per process (initially 3 usually)
int rm_fd_cache_get_fds_per_process(RmFdCache *self) {
int n = -1;
struct rlimit rl;
if(getrlimit(RLIMIT_NOFILE, &rl) == -1) {
return -1;
#!/usr/bin/env python
# encoding: utf-8
from gi.repository import Moose
from gi.repository import GLib
import sys
def zeroconf_state_changed(browser):
sahib / glyr_opt_dlcallback.rb
Created September 20, 2011 13:22
require './'
q =
my_proc = do |cache,query|
Glyros::glyr_cache_print cache
require './'
include Glyros
# Brief example on how to use glyr_db_foreach() and the require macros
# Sorry if this looks like Ruby. It's acutally ruby-flavoured C :-)
# A filled DB is required, read to use example:
# $ glyrc artistphotos -a "Bring me the horizon" -n 10 -c /tmp
# Gets the 'requirements' for a certain fetcher by it's type
require './'
include Glyros
# Simple example on how to directly call a certain
# provider's get_url() and parser() function.
# We need a query (as usual)
q =
require './'
include Glyros
# Simple example on how to use glyr_info_get
# and the require macros appear here too.
def req_to_string reqs, required, optional
return "required" if (reqs & required) != 0
return "optional" if (reqs & optional) != 0
return "not needed"