Skip to content

Instantly share code, notes, and snippets.

View hgn's full-sized avatar

Hagen Paul Pfeifer hgn

View GitHub Profile
#!/usr/bin/env perl
$aosd_path = "aosd_cat";
@aosd_args = ();
push(@aosd_args, "--shadow-offset=1");
push(@aosd_args, "--back-color=black");
push(@aosd_args, "--back-opacity=255");
push(@aosd_args, "--position=4");
push(@aosd_args, "--padding=0");
@hgn
hgn / gist:5035117
Created February 26, 2013 01:51 — forked from dmatveev/gist:2295597
#include <glib.h>
#include <gio/gio.h>
#include <string.h>
static GMainLoop *gMainLoop = NULL;
char *
decode (GFileMonitorEvent ev)
{
char *fmt = g_malloc0 (1024);
@hgn
hgn / gist:5076654
Last active December 14, 2015 11:08
Gtk3 CSS for MenuItems
/* COMPILE WITH: gcc -Wall -o icon3 `pkg-config --cflags --libs gtk+-3.0` a.c */
#include <gtk/gtk.h>
#include <string.h>
static void cb_left_click(GtkStatusIcon * icon, gpointer data)
{
static GtkWidget *window = NULL;
if (window == NULL) {
@hgn
hgn / gist:5082143
Created March 4, 2013 13:13
Read Proc
#include <stdio.h>
// how to read and print various things in /proc
/////////////////////////////////
// how to read /proc/*/stat
/////////////////////////////////
struct statStuff {
int pid; // %d
@hgn
hgn / gist:5094180
Created March 5, 2013 20:54
Parse /proc/interrupts
#!/usr/bin/perl
#
# Interrupt top
#
# Show the interrupts per second/per IRQ per CPU
# Parse /proc/interrupts file for data
#
# CPU0 CPU1
# 0: 3025267376 3026744388 IO-APIC-edge timer
@hgn
hgn / gist:5094337
Created March 5, 2013 21:14
cputree - parse /sys CPU tree
/*
* Copyright (C) 2006, Intel Corporation
* Copyright (C) 2012, Neil Horman <[email protected]>
*
* This file is part of irqbalance
*
* This program file 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; version 2 of the License.
*
@hgn
hgn / gist:5094345
Created March 5, 2013 21:15
Parse /proc/interrupts
/*
* Copyright (C) 2006, Intel Corporation
* Copyright (C) 2012, Neil Horman <[email protected]>
*
* This file is part of irqbalance
*
* This program file 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; version 2 of the License.
*
#!/bin/sh
# aptitude install bridge-utils
if1=eth0
if2=eth1
ifconfig $if1 down
ifconfig $if2 down
ifconfig $if1 0.0.0.0 up
@hgn
hgn / captcp-constantly-graph
Created January 24, 2014 09:52
captcp-constantly-graph
#!/usr/bin/env python
# remember to edit /etc/sudoers file and grant tcpdump without
# password access to work in a scripting environment. sudo visudo
# username ALL=NOPASSWD:ALL,/sbin/tcpdump,/usr/bin/kill
import os
import signal
import subprocess
#define N 1024
int mul1[N][N];
int mul2[N][N];
int res[N][N];
void calculate(void)
{
int i, j, k;