Skip to content

Instantly share code, notes, and snippets.

View RogerGee's full-sized avatar

Roger Gee RogerGee

  • Tulsa, OK USA
  • 14:05 (UTC -05:00)
View GitHub Profile
@RogerGee
RogerGee / dynarray_ensure_size.c
Created April 29, 2019 23:35
Generic dynamic resize routine
void dynarray_ensure_size(size_t num,size_t* pcap,void** buf,size_t szof)
{
void* newbuf;
size_t newsz;
size_t cap = *pcap;
if (cap == 0) {
if (16 > num) {
*pcap = cap = 16;
}
@RogerGee
RogerGee / build-package
Created August 5, 2016 01:05
A shell script to create Debian packages (works on symlinks)
#!/bin/bash
# This script builds a DEBIAN package. I use it as a replacement for
# dpkg-deb because dpkg-deb doesn't follow symlinks.
# make 'tar' follow symlinks
export TAR_OPTIONS=-h
# get a temporary directory
TMPDIR="$TEMPDIR"
if [ -z $TMPDIR ];
@RogerGee
RogerGee / unpacker.py
Last active March 22, 2016 22:51
A git post-receive hook to deploy from git repositories
#!/usr/bin/env python
# unpacker.py
# Author: Roger Gee <rpg11a@acu.edu>
# this script unpacks the lastest commit(s) on master and scans them
# for syncing; the script checks a file called '.unpack' which
# contains key/value pairs describing how to unpack the repository or
# any others into the filesystem; symlink this script as
# hooks/post-receive in the bare repository on your remote
@RogerGee
RogerGee / dpkgdeps
Last active March 23, 2018 13:39
Debian Package Dependency Reducer (python2)
#!/usr/bin/env python
import re
import sys
import subprocess
# This program reduces dependency lists down to their top-level
# dependencies. It works by building a dependency tree obtained by
# repeated invocations of 'apt-cache depends'. It was developed for
# finding dependency list for Debian package (.deb files) control
# files.
@RogerGee
RogerGee / restrict-command.c
Last active March 10, 2021 22:25
Runs a command in a restricted context (e.g. no network access, limited memory, chroot)
/* restrict-command.c - must run as setuid program */
#define _GNU_SOURCE
#include <stdlib.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <error.h>
#include <getopt.h>
#include <sys/wait.h>
@RogerGee
RogerGee / Launch
Created January 27, 2015 19:09
Background process launching program
Launch by Roger Gee
@RogerGee
RogerGee / Knapsack
Last active August 29, 2015 14:14
Knapsack Implementation
Knapsack Implementation
by Roger gee
24 January 2015