Skip to content

Instantly share code, notes, and snippets.

View nacx's full-sized avatar

Ignasi Barrera nacx

View GitHub Profile
@nacx
nacx / qos-opendpi.sh
Created December 8, 2010 11:47
Basic QoS with iproute2 and OpenDPI Netfilter wrapper
#!/bin/bash
# Basic QoS script that uses OpenDPI (http://www.opendpi.org/)
# Netfilter wrapper to identify packets by the protocol.
#
# This script enqueues packets in three queues, each one
# with a different priority:
#
# The first queue has the higher priority and gets the TCP SYN
# packets, ACKs, ICMPs and packets with Minimize-Delay TOS.
@nacx
nacx / gist:755969
Created December 27, 2010 08:40
Redis database management daemon
We couldn’t find that file to show.
@nacx
nacx / hiredis.h
Created December 30, 2010 15:37
Modified hiredis.h to support C++ builds
/*
* Copyright (c) 2009-2010, Salvatore Sanfilippo <antirez at gmail dot com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
@nacx
nacx / SpringInjectionExample.java
Created January 14, 2011 09:08
Spring injection by name example
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.util.Assert;
public abstract class InjectableProperty implements InitializingBean, ApplicationContextAware
{
private String beanName;
@nacx
nacx / Simple NexentaStor information retrieval
Created March 10, 2011 15:38
Simple NexentaStor information retrieval python script
#!/usr/bin/env python
import sys
import NZA
def print_volumes_by_pool(pool):
volumes = NZA.nms.zvol.get_names_by_prop('volume_name', pool, '')
for volume in volumes:
name = NZA.nms.zvol.get_child_prop(volume, 'name')
size = NZA.nms.zvol.get_child_prop(volume, 'size')
@nacx
nacx / Iptables NAT
Created March 23, 2011 16:37
An example iptables script to configure a routing machine
#!/bin/bash
echo "Generando reglas iptables..."
# Borramos las reglas de las cadenas y los contadores
iptables -F
iptables -X
iptables -Z
iptables -t nat -F
# Establecemos las políticas por defecto
@nacx
nacx / Iptables Ban
Created March 30, 2011 10:45
Simple chain to ban ip addresses
#!/bin/bash
BANFILE='/root/banned'
iptables -N BANNED
if [ -f ${BANFILE} ]; then
for IP in `sort -ru ${BANFILE}`; do
iptables -A BANNED -s ${IP} -j DROP
done
fi
@nacx
nacx / Personal firewall
Created April 1, 2011 12:23
Iptables firewall for a personal computer
#!/bin/bash
#
# This is an example iptables script to configure
# a firewall for a personal machine.
#
# It filters bad packets and bans the desired IP
# addresses, and allows remote connections to a
# controlled set of ports.
#
@nacx
nacx / OpenEntityManagerInterceptor.java
Created April 5, 2011 10:24
OpenEntityManagerInterceptor to be used outside the web request scope
/**
* Abiquo community edition
* cloud management application for hybrid clouds
* Copyright (C) 2008-2010 - Abiquo Holdings S.L.
*
* This application is free software; you can redistribute it and/or
* modify it under the terms of the GNU LESSER GENERAL PUBLIC
* LICENSE as published by the Free Software Foundation under
* version 3 of the License
*
@nacx
nacx / WinkResourceParser.java
Created May 10, 2011 07:19
Wink Resource Parser
package com.abiquo;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.util.HashSet;
import java.util.Set;