Skip to content

Instantly share code, notes, and snippets.

@hgdeoro
hgdeoro / 10modprobetun
Created December 21, 2011 19:59
/system/etc/init.d/10modprobetun
#!/system/bin/sh
#
# load the 'tun' module
modprobe tun
@hgdeoro
hgdeoro / smtpcli.py
Created November 4, 2011 21:11
Simple Python SMTP client
#
# Minimal SMTP client
# Supports setting of TO, FROM, SUBJECT
# (multiple TOs must be separated by commas)
# Reads body from stdin
#
import smtplib
import os
import sys
@hgdeoro
hgdeoro / conversor_fastq_a_fasta.py
Created October 21, 2011 23:49
Conversor de FASTQ a FASTA
#
# Primero le decimos a Python (el lenguaje de programacion) que queremos usar 'SeqIO',
# que es un modulo de Biopython.
#
from Bio import SeqIO
#
# El modulo 'SeqIO' posee muchas funciones, una de ellas es convert(), usada para
# convertir un archivo de un formato a otro. La funcion devuelve la cantidad de registros
@hgdeoro
hgdeoro / munin_squid_fd.p
Created September 15, 2011 20:09
Munin plugin for monitoring Squid use of file descriptors
#!/usr/bin/python
import os
import re
import sys
from subprocess import Popen, PIPE
def main():
output = Popen(["squidclient", "mgr:info"], stdout=PIPE).communicate()[0]
@hgdeoro
hgdeoro / exim.conf
Created September 7, 2011 20:13
Config. de Exim para NO realizar envios SMTP y guardar todos los emails recibidos
primary_hostname = some.name.example.com
acl_smtp_rcpt = acl_check_rcpt
acl_smtp_data = acl_check_data
never_users = root
# host_lookup = *
# rfc1413_hosts = *
@hgdeoro
hgdeoro / munin-node
Created September 7, 2011 18:03
Ejemplo de /etc/init.d/munin-node para CentOS 5.6
#!/bin/sh
#
# munin-node Start de Munin node
#
# chkconfig: 2345 55 25
# description: Starts and stops the Munin node daemon
#
source /opt/munin/munin-node-settings
# +-> export PERL5LIB=/opt/perl-munin/lib/perl5/5.8.8:/opt/perl-munin/lib/perl5/site_perl/5.8.8:/opt/munin/usr/lib/perl5/site_perl/5.8.8
@hgdeoro
hgdeoro / ThreadStress.java
Created August 25, 2011 21:24
ThreadStress
public class ThreadStress {
public static class SomeRunnable implements Runnable {
public long num = 0;
long time;
public SomeRunnable(int time) {
this.time = time;
}
@hgdeoro
hgdeoro / forward_apache.py
Created August 20, 2011 15:46
TCP forwarder to Apache on localhost
import eventlet
def closed_callback():
print "called back"
def forward(source, dest, cb = lambda: None):
while True:
d = source.recv(8096)
if d == '':
cb()
@hgdeoro
hgdeoro / JvmCrasher.java
Created August 2, 2011 12:35
Simple java class to crash the JVM (works with Sun/Oracle JVM)
import java.io.IOException;
import java.net.ServerSocket;
import sun.dc.pr.PathDasher;
public class JvmCrasher {
public static void log(String msg) {
try {
Runtime.getRuntime().exec(new String[] { "/usr/bin/logger", "-t", "TestCaidaJvm", msg }).waitFor();
@hgdeoro
hgdeoro / libvirt_xml_vendor_product.xml
Created July 1, 2011 16:26
USB+KVM using vendor id + product id
<hostdev mode='subsystem' type='usb' managed='no'>
<source>
<vendor id='0x0930'/>
<product id='0x6545'/>
</source>
</hostdev>