Skip to content

Instantly share code, notes, and snippets.

Avatar
🤘

Chris Pahl sahib

🤘
View GitHub Profile
@sahib
sahib / pre-commit
Last active Aug 29, 2015
Pre commit hook for rmlint - put in .git/hooks/pre-commit and chmod +x it.
View pre-commit
#!/bin/sh
#
# Shamelessly stolen from:
# http://www.es.ele.tue.nl/sdf3/manuals/development/files/pre-commit
# 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".
View popover_menu.py
#!/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)
View list-disks.c
#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) {
g_printerr("MOUNTS:\n");
@sahib
sahib / app.css
Created Feb 9, 2015
Small & colorful indicator label for Gtk
View app.css
/* Support for colored labels.
* These are sometimes handy in order to highlight errors
* or mark some entries with "xx new items".
*/
#AppIndicatorLabelError,
#AppIndicatorLabelSuccess,
#AppIndicatorLabelWarning,
#AppIndicatorLabelTheme {
/* Animate changes so the label color gets faded in */
@sahib
sahib / get-n-fds.c
Created Feb 24, 2015
Find number of file descriptor per process (initially 3 usually)
View get-n-fds.c
int rm_fd_cache_get_fds_per_process(RmFdCache *self) {
g_assert(self);
int n = -1;
struct rlimit rl;
if(getrlimit(RLIMIT_NOFILE, &rl) == -1) {
return -1;
}
View moose_zeroconf.py
#!/usr/bin/env python
# encoding: utf-8
from gi.repository import Moose
from gi.repository import GLib
import sys
def zeroconf_state_changed(browser):
View glyr_opt_dlcallback.rb
require './glyros.so'
q = Glyros::GlyrQuery.new
Glyros::glyr_query_init(q)
Glyros::glyr_opt_artist(q,"Equilibrium")
Glyros::glyr_opt_type(q,Glyros::GLYR_GET_ARTIST_PHOTOS)
Glyros::glyr_opt_number(q,5)
my_proc = Proc.new do |cache,query|
Glyros::glyr_cache_print cache
View glyr_dbtest.rb
require './glyros.so'
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
View glyr_providertest.rb
require './glyros.so'
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 = GlyrQuery.new
glyr_query_init(q)
glyr_opt_artist(q,"Equilibrium")
View glyr_reqs.rb
require './glyros.so'
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"