Skip to content

Instantly share code, notes, and snippets.

@diegogslomp
diegogslomp / telnet.sh
Last active January 31, 2016 00:50
Telnet script using expect
#!/usr/bin/expect #Where the script should be run from.
# Copied from http://osix.net/modules/article/?id=30
#If it all goes pear shaped the script will timeout after 20 seconds.
set timeout 20
#First argument is assigned to the variable name
set name [lindex $argv 0]
#Second argument is assigned to the variable user
set user [lindex $argv 1]
#Third argument is assigned to the variable password
@diegogslomp
diegogslomp / jsonview.sh
Created December 14, 2015 17:50
Simple bash script to pretty-print json files with json.tool python module
#!/bin/bash
set -e
if [[ "$#" -eq 1 ]] && [[ -r "$1" ]]; then
while IFS='' read -r line || [[ -n "$line" ]]; do
echo "$line" | python -m json.tool
done < "$1"
else
echo "jsonview.sh"
echo "Usage: jsonview.sh <jsonfile>"
fi
@diegogslomp
diegogslomp / routers.py
Last active August 27, 2018 14:40
Router to integrate django with postgres database schemas
class AbstractRouter(object):
"""
A router to control all database operations on models in the
application.
"""
def __init__(self, app, schema):
self.app = app
self.schema = schema
def db_for_read(self, model, **hints):
@diegogslomp
diegogslomp / qtsixa-dependences-install.sh
Created June 8, 2016 12:19
Dependences to install qtsixa sixad ubuntu 16.04
#!/bin/bash
sudo apt-get install build-essential pyqt4-dev-tools libusb-dev libjack-dev libbluetooth-dev python-dbus
# add "#include <unistd.h>" to shared.h
# vim sixad/shared.h
# make
# sudo make install
@diegogslomp
diegogslomp / print-ocs-not-installed.sh
Created September 25, 2016 14:53
Script to filter mac from OCS exported file and prints OFFICESCAN exported file without mac matched lines
#!/bin/bash
# Script to filter mac from OCS exported file and prints
# OFFICESCAN exported file without mac matched lines
# Need csvkit installed: pip install csvkit
set -e
OFFICESCAN="OfficeScan agent listing.csv"
OCS="export.csv"
@diegogslomp
diegogslomp / pyscript.py
Created December 9, 2016 14:43 — forked from nhoffman/pyscript.py
Python script template
#!/usr/bin/env python
"""A simple python script template.
"""
from __future__ import print_function
import os
import sys
import argparse
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Ask Switches
Usage:
ask-switches.py <csvfile> [-u <user>] [-p <password>] [-o <output_file>]
ask-switches.py -h | --help
Identify enabled|disabled vlan authorization and disabled radius fe*.* ports
Arguments:
<csvfile> NetSight auto export csv file
#!/bin/bash
# system_page - A script to produce an system information HTML file
##### Constants
TITLE="System Information for $HOSTNAME"
RIGHT_NOW=$(date +"%x %r %Z")
TIME_STAMP="Updated on $RIGHT_NOW by $USER"
@diegogslomp
diegogslomp / ldap-diff.sh
Created May 4, 2017 18:55
Check differences between ldap master and slave(s) searches
#!/bin/bash
#Check differences between ldap master and slave(s) searches.
#Change the `LDAPMASTER` and `BASEDN` variables suitting to your environment.
#Tested on CentOS.
LDAPMASTER="ldapmaster_ip"
LDAPSLAVES=$(host ldap | gawk -F' ' '{print $4}')
BASEDN="ou=Users,dc=DomainComponent,dc=DistinguishedName"
ARGS="(&(uid=${1}))"
#!/usr/bin/env bash
# Bash3 Boilerplate. Copyright (c) 2014, kvz.io
set -o errexit
set -o pipefail
set -o nounset
# set -o xtrace
# Set magic variables for current file & dir
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"