Skip to content

Instantly share code, notes, and snippets.

@gcmurphy
gcmurphy / gist:3892059
Created October 15, 2012 11:41
Create a .desktop file for Sublime Text 2

In Gnome 3 in order to pin an application to the panel as a 'favorite' you need to have a .desktop file.

To do this for Sublime Text 2 you simply need to:

  1. Run gnome-desktop-item-edit to create a template like so: sudo gnome-desktop-item-edit --create /usr/share/applications/sublime_text.desktop

  2. You will get a dialog to configure a new application launcher. Most of which required you to point things at where you have unpacked Sublime Text 2. For the command you need to specify $SUBLIME_HOME/sublime_text and for the icon you can pick on of the in $SUBLIME_HOME/Icons.

@gcmurphy
gcmurphy / who.c
Created November 1, 2012 05:17
who
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <utmpx.h>
int main(void)
{
struct timeval last_hour;
struct timeval last_login;
struct utmpx *entry = NULL;
@gcmurphy
gcmurphy / macro.c
Created November 5, 2012 07:03
Macro example of unfolding a for loop for certain values.
// for loop unravelled using macro expansion
// in case i ever want to enter the obsfucated c
// contest '-)
#define X0(h, s, n) (T[(h) ^ (int)(s+n)[0]])
#define X1(h, s, n) X0((X0(h, s, n)), s, n-1 )
#define X2(h, s, n) X1((X1(h, s, n)), s, n-2 )
#define X3(h, s, n) X2((X2(h, s, n)), s, n-4 )
#define X4(h, s, n) X3((X3(h, s, n)), s, n-8 )
#define X5(h, s, n) X4((X4(h, s, n)), s, n-16 )
#define X6(h, s, n) X5((X5(h, s, n)), s, n-32 )
@gcmurphy
gcmurphy / checksec_demo.sh
Created November 28, 2012 08:07
Usage of checksec
# Check a file:
checksec a.out
# Check an entire directory:
checksec dir/*
# Check a running process:
checksec /proc/$(pgrep firefox)/exe
#Check all running processes :
@gcmurphy
gcmurphy / epoll.go
Created November 30, 2012 06:08
Basic epoll usage using Go
package main
import (
"fmt"
"os"
"syscall"
)
const (
MaxEpollEvents = 32
@gcmurphy
gcmurphy / actor.go
Created December 12, 2012 05:25
Rough attempt to implement Actor in Go based on Gevent tutorial example here: http://sdiehl.github.com/gevent-tutorial/#actors
package main
import (
"time"
)
type Action func(interface{})
type Actor struct {
Inbox chan interface{}
@gcmurphy
gcmurphy / goto.c
Last active December 11, 2015 01:28
goto example for blog post
void example()
{
A *a;
B *b = NULL;
a = a_new();
if (! a){
goto end;
}
void example()
{
A *a;
B *b;
a = a_new();
if (a){
b = b_new(a);
if (b){
use_b(b);
void example()
{
A *a;
B *b;
a = a_new();
if (!a){
puts("bye");
return;
}
@gcmurphy
gcmurphy / defer.c
Last active December 11, 2015 01:29
void example()
{
A *a;
B *b;
defer_start();
defer(puts, "bye");
a = a_new();
if (! a){