Skip to content

Instantly share code, notes, and snippets.

View nsabine's full-sized avatar

Nick Sabine nsabine

View GitHub Profile
VMs:
- ose3-disconnected-installer
- 1 GB RAM
- 2 vCPU
- 15 GB HD, default partitioning
- "private" virtual network (internal and host only routing)
- static IP
- RHEL 7.1 minimal server
- ose3-disconnected-master
- 8 GB RAM
code {
white-space: pre-wrap !important;
/* text-indent: -20px; */
/* padding-left: 30px; */
}
.markdown-body {
width: 100% !important;
}

Keybase proof

I hereby claim:

  • I am nsabine on github.
  • I am nicksabine (https://keybase.io/nicksabine) on keybase.
  • I have a public key whose fingerprint is 0731 859F B8E8 C479 964C 4CE3 9BBB BFFE 5A5B 69AF

To claim this, I am signing this object:

@nsabine
nsabine / add_user.sh
Created September 17, 2013 19:51
Shell script to add a user to LDAP. Based on OpenLDAP and RFC 2307 memberuid group attributes.
#!/bin/bash
#
# add_user.sh: Add user to LDAP
# Author: Nick Sabine
#
# Defaults
LDAP_BASE="dc=ORG,dc=local"
LDAP_ACCOUNTS_DN="ou=people,${LDAP_BASE}"
LDAP_USER_GROUP="cn=user_group,ou=groups,${LDAP_BASE}"
#!/bin/bash
declare -a DISKS=($(fdisk -l | grep 'dev' | awk '{if ($3 > 1000) print $2}' | sed s/.$//))
declare -a INUSE=($(mount | awk '{if ($1 ~ '/dev/') print $1}'))
declare -a UNUSED=(`comm -23 <(echo ${DISKS[@]} | sed 's/ /\n/g' | sort -u) <(echo ${INUSE[@]} | sed 's/ /\n/g'| sort -u)`)
echo "All Disks larger than 1000 GB:"
for i in ${!DISKS[@]}
do
echo "$i=${DISKS[$i]}"
@nsabine
nsabine / create_spanned_drive.ps1
Created August 7, 2013 19:09
Create a spanned volume in windows from AWS ephemeral disks.
$disks = (wmic diskdrive list brief | measure-object -line | select -ExpandProperty Lines)-2
1..$disks | ForEach-Object -Begin {$a = $null} -Process { $a += $("select disk "+$_+[char][int](13)+[char][int](10)) ; $a += "online disk noerr "+[char][int](13)+[char][int](10) ; $a += "clean "+[char][int](13)+[char][int](10) ; $a += "attributes disk clear readonly noerr "+[char][int](13)+[char][int](10) ; $a += "convert dynamic noerr "+[char][int](13)+[char][int](10) ;} -End { $a += "exit"+[char][int](13)+[char][int](10) ; $a | Set-Content c:\diskpart1.txt -Encoding ASCII }
$a = "create volume stripe disk=1"
2..$disks | ForEach-Object -Process {$a += ","+$_}
$a += [char][int](13)+[char][int](10)
$a += "format fs=ntfs label=scratch quick"+[char][int](13)+[char][int](10)
$a += "assign letter=z"+[char][int](13)+[char][int](10)
$a += "exit"+[char][int](13)+[char][int](10)
@nsabine
nsabine / todos.py
Last active December 18, 2015 10:09 — forked from MosheBerman/Toodles.py
import os
import keyword
import sys
# key phrase to look for
needle = 'todo'
# file extensions to be searched for todo statements
extensions_to_include = ('.py', '.c', '.m', '.h', '.txt')
@nsabine
nsabine / simple_database.py
Created May 6, 2013 20:31
Read and write simple data to a sqlite database
import sqlite3
db_filename = "test.db"
def create_schema(conn):
schema = """
drop table if exists word;
create table word (
id integer primary key autoincrement not null,
w text
@nsabine
nsabine / random_generator.py
Last active December 17, 2015 01:19
Generators for random integers or words
import random
def random_int(num: int = 1, min: int = 1, max: int = 100) -> [int]:
"""Return a list of random integers."""
ints = []
for i in xrange(num):
ints.append(random.randint(min,max))
return ints
def random_word(num: int = 1) -> [str]:
@nsabine
nsabine / duplicate_uids.py
Last active December 16, 2015 19:09
Find duplicate user ids on a system by parsing the /etc/passwd file
#!/usr/bin/env python
from collections import defaultdict
# Initialize dictionary of user ids
uids = defaultdict(list)
# loop through password file, building dictionary of uid:[list of usernames]
with open("/etc/passwd") as passwd_file:
for line in passwd_file: