Skip to content

Instantly share code, notes, and snippets.

Avatar

Jesse Cotton JCotton1123

View GitHub Profile
@JCotton1123
JCotton1123 / ldap_search_time.rb
Created Aug 26, 2015
ScoutApp LDAP Search Time plugin
View ldap_search_time.rb
class LDAPSearchTime < Scout::Plugin
OPTIONS=<<-EOS
uri:
default: ldapi:///
name: URI
authmech:
default: EXTERNAL
name: Auth Mechanism
username:
name: Username
View authorized_keys_command.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'net/http'
require 'uri'
require 'json'
require 'pry'
class User
attr_accessor :login
View mysql2sqlite.sh
#!/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 Jul 15, 2014
Parse an apache log into a pipe-delimited file
View apache-log-to-delim.py
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 Aug 17, 2014
Parse snmp mac notification trap
View parse-mac-trap.sh
#!/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 Aug 29, 2015
Setup Questions2Answers
View questions2answers-setup.sh
# 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
View media-wiki-to-github-wiki.php
<?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.
View gist:7da304f8ad7b6497075a

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 / imap-sync-gmail.sh
Last active Aug 29, 2015
Sync mail to gmail
View imap-sync-gmail.sh
#!/usr/local/bin/bash
#Remember to set
#export MAIL_SYNC_SRC=
user1=$1
user2=$2
passwd_file=$3
imapsync --host1 $MAIL_SYNC_SRC --user1 "$user1" --passfile1 "$passwd_file" --ssl1 --port1 993\
View gist:367b293581b063919078
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"'