Skip to content

Instantly share code, notes, and snippets.

View sahib's full-sized avatar
🤘

Chris Pahl sahib

🤘
View GitHub Profile
@sahib
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.
#!/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".
#!/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) {
g_printerr("MOUNTS:\n");
@sahib
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".
*/
#AppIndicatorLabelError,
#AppIndicatorLabelSuccess,
#AppIndicatorLabelWarning,
#AppIndicatorLabelTheme {
/* Animate changes so the label color gets faded in */
@sahib
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) {
g_assert(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
sahib / glyr_opt_dlcallback.rb
Created September 20, 2011 13:22
glyr_opt_dlcallback
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
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
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")
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"