Skip to content

Instantly share code, notes, and snippets.

View sarguru's full-sized avatar

Sarguru Nathan sarguru

View GitHub Profile
@sarguru
sarguru / deepofix-ldapgroup.pl
Created November 5, 2011 17:51
Add members to ldap group, create if the group does not exist in deepOfix Mailserver
#!/usr/bin/env perl
use Net::LDAP;
$ldap = Net::LDAP->new("localhost", timeout=>30) or die "failed";
$msg = $ldap->bind("uid=easypush,ou=People, dc=$ARGV[3],dc=$ARGV[4]", password=>$ARGV[5]);
print $msg->code;
@sarguru
sarguru / gist:1799404
Created February 11, 2012 13:24
RT Reminder mail
#!/usr/bin/env perl
#
# This script outputs all reminders that are due within the next e.g. 2 days
# and mails the result to the corresponding owners. christian <ch AT westend.com>
#####
# FING - UdelaR
# Modifed by Mario A. del Riego <delriego AT fing DOT edu DOT uy>
# Added tainting checks
# Fixed an old variable dont defined
# Changed mail format (ticket id added)
@sarguru
sarguru / test.rb
Created March 13, 2012 20:48
trying out popen4
require 'open4'
tests = $stdin.readlines
pid,stdin,cstdout,stderr = open4::popen4 'a/really/odd/program'
stdin.puts tests
cstdout.puts "i need to put this to fd1"
@sarguru
sarguru / deepofix-usersmod.pl
Created April 12, 2012 10:53
Modify deepofix users from old schema to new schema
#!/usr/bin/env perl
use Net::LDAP;
open (BASEDN,"/var/qmail/control/ldapbasedn") || die "couldn't open
file \n";
$basedn = <BASEDN>;
chomp($basedn);
@sarguru
sarguru / init.pp
Created June 22, 2012 05:08
the main class
class qmail {
$domain = hiera('domain')
$basedn = hiera('basedn')
$deepofix_password = hiera('deepofix_password')
$cluster = hiera('mail_cluster')
$concurrency = hiera('smtpd_concurrency')
$maxrcpt = hiera('maxrcpt')
$qmail_queue = hiera('qmail_queue')
$smtp_port = hiera('smtp_port')
@sarguru
sarguru / qmail-queue.js
Created July 5, 2012 09:50
qmail-queue.js
// Queue to qmail-queue
var childproc = require('child_process');
var netBinding = require('net');
//var netBinding = process.binding('net');
var fs = require('fs');
var path = require('path');
exports.register = function () {
this.queue_exec = this.config.get('qmail-queue.path') || '/var/qmail/bin/qmail-queue';
@sarguru
sarguru / sinatra.rb
Created July 11, 2012 09:15
sample-sintra-gitlabhook
require 'rubygems' if RUBY_VERSION < '1.9'
require 'sinatra';
require 'json';
require 'mail';
get '/' do
'Minimal Sinatra Hello World!'
end
post "/gitlab" do
@sarguru
sarguru / xml.pl
Created July 12, 2012 10:35
xmlparser with perl
use strict;
use XML::Simple;
use Data::Dumper;
my $mylog = XMLin('mylog.xml');
my @comparray;
my @unitarray;
my $counter =0;
@sarguru
sarguru / xml_hash.pl
Created July 16, 2012 05:50
xml hash
use XML::Simple;
use Data::Dumper;
sub trim($)
{
my $string = shift;
$string =~ s/^\s+//;
$string =~ s/\s+$//;
return $string;
}
@sarguru
sarguru / ticket.pl
Created August 3, 2012 15:17
hubot-rt
#!/usr/bin/env perl
use Error qw(:try);
use RT::Client::REST;
my $id = $ARGV[0];
my $rt = RT::Client::REST->new(
server => 'http://RTURL',
timeout => 30,
);