Skip to content

Instantly share code, notes, and snippets.

The best way to use this tool is to hook apt's use of dpkg to run it before doing any package installs.

In your apt.conf, put this:

DPkg::Pre-Install-Pkgs {"xargs -rL1 bash /path/to/stripdeb.sh 2>&1 | logger -t stripdeb"}

Then, a demo:

% sudo apt-get install mysql-server-5.1

@aktau
aktau / gist:5330470
Last active December 15, 2015 22:09 — forked from Kerrick/gist:2716568
#!/bin/bash
# set -e
set -u
AKBREW_CELLAR="/usr/local/aktau"
CURRENT_USER=$(whoami)
# create AKBREW_CELLAR if it does not exist
@aktau
aktau / waitpidTimeout.c
Last active December 16, 2015 09:19
waitpidTimeout
/**
* Wait (block) a maximum amount of time before forcefully killing a child (worker) and returning
*
* NOTE: this could interact badly if SIGCHLD is handled by a signal handler, such is the case
* with this particular codebase. The reason is that the wait() might not be triggered anymore
* because the PID in question was already waited on in the signal handler.
*/
static void ctlWaitPidTimeout(pid_t worker_pid, useconds_t usec) {
TRACE("ctlWaitPidTimeout: waiting on %lu\n", (unsigned long) worker_pid);
@aktau
aktau / gcc-compare.sh
Last active December 16, 2015 15:49
GCC check capabilities of platform and compare side-by-side:
# source: http://forums.gentoo.org/viewtopic-p-6242890.html
# diff --side-by-side <(gcc -Q --help=target -march=atom) <(gcc -Q --help=target -march=native)
# core2 and atom seem to be quite similar in capabilities, through probably
# not in tuning
-O2 \
-march=core2 \
-funswitch-loops \
@aktau
aktau / atomic_buffer_store.c
Created April 26, 2013 12:56
A useless data structure?
/**
* atomic_array.c
*
* Not a general purpose container, this just serves as a circular buffer
* for void poiners with O(1) lookup but with better constants
* than a hash-table and thread safe for insertion and deletion.
*
* This can be used as a data structure to share between threads, as a kind
* of shared pointer. Both threads keep a key into the table, they can retrieve,
* insert and delete a void pointer atomically.
@aktau
aktau / debian-preseeded-iso.sh
Last active November 16, 2019 05:53
Create a preseeded (debian) hybrid ISO which can be burned to CD and dd'ed to a USB stick, don't forget to apt-get install xorriso isolinux
#!/bin/bash
set -e
set -u
# hat-tips:
# - http://codeghar.wordpress.com/2011/12/14/automated-customized-debian-installation-using-preseed/
# - the gist
@aktau
aktau / log-to-chrome.php
Last active December 17, 2015 04:19
Logging to chrome (with extension, unfortunately)
<?php
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use Monolog\Handler\FirePHPHandler;
use Monolog\Handler\ChromePHPHandler;
class SomeClass {
private $log;
$this->log = new Logger('aktau ->');
@aktau
aktau / timeLogConsole.js
Created May 10, 2013 10:05
Prepend time logging to console, supports multiple arguments
function takeOverConsole(){
var console = window.console;
if (!console) return;
function intercept(method){
var original = console[method];
console[method] = function(){
// do sneaky stuff
var now = new Date();
var currentDate = [ '[' + now.toUTCString() + '/' + now.getUTCMilliseconds() + '] ' ];
var args = Array.prototype.slice.call(arguments);
@aktau
aktau / ps-signalmask.sh
Created May 12, 2013 11:46
inspect the signal set of every thread in a process (including the main thread) TODO: decode the
#!/bin/bash
set -e
set -u
pid=$1
# SigQ number of signals queued/max. number for queue
# SigPnd bitmap of pending signals for the thread
# ShdPnd bitmap of shared pending signals for the process
@aktau
aktau / grub2-set-default-1.sh
Last active December 17, 2015 06:19
useful shell scripts
#!/bin/sh
set -e
set -u
# find menu entries
grep ^menuentry /boot/grub/grub.cfg| cut -d "'" -f2
# adjust it
sudo sed -i 's/^\(GRUB_DEFAULT\)\(.*\)/\1="Debian GNU\/Linux, with Linux 3.2.0-4-amd64"/' /etc/default/grub