Skip to content

Instantly share code, notes, and snippets.

@d-tux
d-tux / update-blocklist.sh
Created January 15, 2016 09:12
ipset blocklist updater
#!/bin/bash
# Adapted from http://www.linuxjournal.com/content/server-hardening?page=0,2
PATH=$PATH:/sbin
WD=`pwd`
TMP_DIR=$WD/tmp
IP_TMP=$TMP_DIR/ip.temp
IP_BLOCKLIST=$WD/ip-blocklist.conf
IP_BLOCKLIST_TMP=$TMP_DIR/ip-blocklist.temp
list="nigerian russian lacnic exploited-servers"
@d-tux
d-tux / docker-volumes.py
Created December 30, 2015 14:54
Searches and removes dangling docker volumes
#!/usr/bin/env python
"""
Largely based on https://github.com/docker/docker/issues/6354#issuecomment-60817733
All credit goes to https://github.com/adamhadani
"""
import logging
import os
import os.path
import sys
import argparse
package main
import (
"encoding/json"
"log"
"net/http"
"strings"
"time"
)
@d-tux
d-tux / Dockerfile
Created July 16, 2015 19:57
Builds fw4spl in a docker container
FROM debian
MAINTAINER Denis Wernert <deniswernert@gmail.com>
# Might want to bust cache here if looking to upgrade the distribution
RUN apt-get update && apt-get upgrade -y
# Install build dependencies
RUN apt-get install -y mercurial \
make \
gcc \
@d-tux
d-tux / Dockerfile
Created February 6, 2015 14:54
Dockerfile to compile SOFA
FROM base/arch
RUN pacman -Sy reflector --noconfirm --noprogressbar
RUN reflector -c FR -f 3 > /etc/pacman.d/mirrorlist
RUN pacman -Syu --noconfirm --noprogressbar && pacman-db-upgrade && pacman -Scc --noconfirm
RUN pacman --noconfirm --noprogressbar -S git gcc cmake make
RUN pacman -S glut glew qt4 --noconfirm --noprogressbar
RUN git clone git://scm.gforge.inria.fr/sofa/sofa.git
RUN cd sofa && cmake . && cmake .
RUN cd sofa && make
@d-tux
d-tux / get-image-size.js
Created February 6, 2015 14:52
Finds the "real" size on an image.
function getImageSize(img) {
var i = $('<img/>')
.css('visibility', 'hidden')
.attr('src', $(img).attr('src'))
.appendTo('body');
var r = {
width: i.width()
, height: i.height()
};
i.remove();
#include <libxml/tree.h>
#include <libxml/xpath.h>
#include <libxml/HTMLparser.h>
#include <stdio.h>
#define FILENAME "index.html"
inline static
void initialize()
{
#include <gtk/gtk.h>
static
void destroy(GtkWidget *widget, gpointer data)
{
gtk_main_quit() ;
} ;
static
gboolean delete_event(GtkWidget *widget, GdkEvent *event, gpointer data)
#include <libxml/tree.h>
#include <libxml/xpath.h>
#include <libxml/HTMLparser.h>
#include <stdio.h>
#define FILENAME "index.html"
inline static
void initialize()
{
@d-tux
d-tux / gist:58781
Created February 5, 2009 16:07
Reads Bind zone files
#!/usr/bin/ruby
def resolve_node(node)
return node if node[-1] == '.'[0]
return node unless $context.has_key? "ORIGIN"
return "#{node}.#{$context["ORIGIN"]}"
end
ARGS.each do |filename|
File.open filename, 'r' do |file|