Skip to content

Instantly share code, notes, and snippets.

View JCotton1123's full-sized avatar

Jesse Cotton JCotton1123

View GitHub Profile
@JCotton1123
JCotton1123 / ldap_search_time.rb
Created August 26, 2015 04:06
ScoutApp LDAP Search Time plugin
class LDAPSearchTime < Scout::Plugin
OPTIONS=<<-EOS
uri:
default: ldapi:///
name: URI
authmech:
default: EXTERNAL
name: Auth Mechanism
username:
name: Username
#!/usr/bin/env ruby
require 'rubygems'
require 'net/http'
require 'uri'
require 'json'
require 'pry'
class User
attr_accessor :login
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite
@JCotton1123
JCotton1123 / apache-log-to-delim.py
Created July 15, 2014 19:04
Parse an apache log into a pipe-delimited file
from __future__ import print_function
import sys
import re
parts = [
r'(?P<host>\S+)', # host %h
r'\S+', # indent %l (unused)
r'(?P<user>\S+)', # user %u
r'\[(?P<time>.+)\]', # time %t
r'"(?P<request>.+)"', # request "%r"
@JCotton1123
JCotton1123 / parse-mac-trap.sh
Created August 17, 2014 07:03
Parse snmp mac notification trap
#!/bin/sh
LOG_FILE=/var/log/snmp/mactrap.log
read host
read ip
ip=`echo $ip | cut -d"[" -f2 | cut -d"]" -f1`
while read oid value
@JCotton1123
JCotton1123 / questions2answers-setup.sh
Last active August 29, 2015 14:05
Setup Questions2Answers
# Install common
yum install -y git wget curl
# Install apache, php, mysql
yum install -y httpd mod_ssl mod_php
yum install -y php php-mysql php-pdo
yum install -y mysql mysql-server
# Addnl php req's
yum install -y php-gd php-mbstring
@JCotton1123
JCotton1123 / media-wiki-to-github-wiki.php
Created August 27, 2014 20:41
Media Wiki to Github Wiki
<?php
/**
Export the pages from a Media Wiki instance into a directory for
import into a Github Wiki.
## Procedure
1) Set the database credentials in this file
2) Create the repository and wiki if not done already. Make sure
to specify the home page is marked down using the Media Wiki format.
@JCotton1123
JCotton1123 / gist:7da304f8ad7b6497075a
Last active August 29, 2015 14:06
course material

Basics

  • Markdown (its becoming ubiquitous)
  • Basic system concepts
    • What is an Operating System and what does it provide?
    • Kernel vs user-land
  • Basic networking concepts
    • Stack (TCP/IP)
  • Layers
@JCotton1123
JCotton1123 / gist:367b293581b063919078
Last active August 29, 2015 14:06
mdadm rebuild array
mdadm --manage /dev/md1 --fail /dev/sdd1
mdadm --manage /dev/md1 --remove /dev/sdd1
sfdisk -d /dev/sdc | sfdisk /dev/sdd
mdadm --manage /dev/md1 --add /dev/sdd1
watch 'cat /proc/mdstat | grep -A 2 "md1"'
@JCotton1123
JCotton1123 / gist:e07b74c3e903239a1de5
Created October 4, 2014 02:10
Setup site-to-site OpenVPN
yum install -y openvpn
Within /etc/sysctl.conf:
net.ipv4.ip_forward = 1
net.ipv4.conf.default.rp_filter = 0
Add to /etc/sysconfig/iptables:
-A INPUT -m conntrack --ctstate NEW -m udp -p udp --dport 1194 -j ACCEPT