Skip to content

Instantly share code, notes, and snippets.

View blaxter's full-sized avatar

Jesús García Sáez blaxter

  • Zaragoza, Spain
View GitHub Profile
@blaxter
blaxter / _service.md
Created May 13, 2016 17:35 — forked from naholyr/_service.md
Sample /etc/init.d script

Sample service script for debianoids

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
@blaxter
blaxter / wcl.py
Created April 21, 2016 16:57
Warcraftlogs tool
#!/usr/bin/python
import requests
import lxml.html
import ConfigParser
import os
import sys
from collections import defaultdict
from itertools import groupby
class WarcraftLogs(object):
@blaxter
blaxter / ldb_reconnect.c
Created November 16, 2015 14:46
samba ldb reconnect
#include <stdio.h>
#include <unistd.h>
#include <stdbool.h>
#include <tevent.h>
#include <talloc.h>
#include <param.h>
#include <ldb.h>
#include <dcerpc.h>
#include <samba/session.h>
@blaxter
blaxter / ldap filter pretty print
Created March 23, 2015 16:47
ldap filter pretty print
#! perl -slw
use strict;
( my $input = do{ local $/; <DATA> } ) =~ tr[\n][]d;
my $tab = 0;
$input =~ s[([()])]{
$tab-- if $1 eq ')';
my $modified = "\n" . ( " " x $tab ) . $1;
$tab++ if $1 eq '(';
@blaxter
blaxter / less_log
Created February 5, 2015 16:27
less_log for openchage samba.log
#!/bin/bash
cat $1 | grep -v auth_check_password_send | grep -v imessaging | grep -v single_terminate | grep -v tstream_read_pdu_blob_recv | grep -v authsam_account_ok | grep -v sam_ignoredomain | grep -v ldb_request | grep -v ldb_wrap | grep -v logon_hours | grep -v housekeeping | grep -v stream_terminate_connection | less
#!/usr/bin/perl
# Copyright (C) 2014 Zentyal S.L.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2, as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@blaxter
blaxter / foo.sh
Created October 17, 2014 11:00
script with lock
lockfile=/var/tmp/mylock
if ( set -o noclobber; echo "$$" > "$lockfile") 2> /dev/null; then
trap 'rm -f "$lockfile"; exit $?' INT TERM EXIT
# do stuff here
# clean up after yourself, and release your trap
rm -f "$lockfile"
@blaxter
blaxter / send_emails.py
Created October 17, 2014 10:49
send mails
#!/usr/bin/env python
import smtplib
import argparse
parser = argparse.ArgumentParser(description='Send massive emails')
parser.add_argument('to_addr_list', metavar='TO', type=str, nargs='+',
help='List of addresses to send the emails')
parser.add_argument('--number', '-n', type=int, default=100,
help='Number of emails to send)')
parser.add_argument('--username', '-u', help='SMTP login')
@blaxter
blaxter / reprovision_openchangedb
Last active August 29, 2015 14:07
Reprovision openchangedb
mysqladmin --defaults-file=/etc/mysql/debian.cnf --force drop openchange create openchange && \
openchange_provision --openchangedb --openchangedb-uri=`cat /etc/samba/openchange.conf | grep mysql:// | head -n 1 | awk '{ print $3 }'` --firstorg="`/usr/share/zentyal/grep-redis openchange/state | cut -c 19- | ruby -rjson -e 'puts JSON.parse(ARGF.read)["Provision"]["organizationname"]'`"
@blaxter
blaxter / snif_unix_socket.sh
Created June 13, 2014 10:48
Snif unix socket
socat -v UNIX-LISTEN:/tmp/socat-listen UNIX-CONNECT:/path/to/real.socket