Skip to content

Instantly share code, notes, and snippets.

View justincjahn's full-sized avatar

Justin Jahn justincjahn

View GitHub Profile
@justincjahn
justincjahn / removeLine.sh
Created May 4, 2011 15:20
Script to remove lines using sed.
#!/usr/bin/env bash
#
# Very simple shell script that removes a line from a file
# using sed.
#
# Usage: removeline 13 /path/to/file
#
nParams=$#
@justincjahn
justincjahn / gist:956166
Created May 4, 2011 22:21
Colorful Command Prompt
### ALIASES ###
alias ls="ls -GF"
### END ALIASES ###
## COLORS ##
DULL=0
BRIGHT=1
FG_BLACK=30
FG_RED=31
@justincjahn
justincjahn / parseurl.pl
Created May 5, 2011 17:32
URL Parsing Regex
#!/usr/bin/env perl
use strict;
# Breakdown
# ([^?:]+):?([0-9]+)?\??([^#]+)?(#.*)?
# ([^?:]+) Matches the file path.
# :?([0-9]+)? Matches the port number (optional).
# \??([^#]+)? Matches the query string minus the ? (optional).
# (#.*)? Matches the anchor (optional).
@justincjahn
justincjahn / backup.sh
Created July 15, 2011 20:35
Simple Incremental Backups using rsync.
#!/bin/bash
unset PATH
#
# VARIABLES
#
BACKUP_DIR='/path/to/backup/location' # The backup directory
SOURCE_LOC=('/path/to/backup1' '/path/to/files/to/backup') # The source backup
SOURCE_DIR=('backup1' 'backup2') # The directory name in backup for SOURCE_LOC
EXCLUDE=() # Directories to exclude
@justincjahn
justincjahn / Scram.js
Created October 19, 2011 19:43
SCRAM-SHA256-JSON
Scram = {
// summary: An implementation of th SCRAM-SHA256-JSON authentication protocol
// for use with the Storm Content Management Framework.
// author: Justin "4sak3n 0ne" Jahn
// copyright: (c) 2010 4sak3n Design (http://www.4sk.us/)
// license: http://www.opensource.org/licenses/bsd-license.php New BSD License
// The cryptographic libraries to be utilized by this method.
crypto: {
base: 'http://crypto-js.googlecode.com/files/',
@justincjahn
justincjahn / README.md
Created October 28, 2011 22:13
Using pam_access.so with Winbind

This file outlines the process of configuring Active Directory authentication and authorization utilizing several different technologies. It is tailored to a Red Hat environment, but the concept is the same with other distros.

Winbind

The process of linking Linux with Winbind has become increasingly straightforward, but there are some redundant pieces involved.

Installing Dependencies

We need to make sure winbind and friends are installed so there are no issues

@justincjahn
justincjahn / vimdb.sh
Created November 29, 2011 01:03
Simple script that edits a bind zone file, updates the SOA line, commits to etckeeper, and restarts BIND.
#!/usr/bin/env bash
# The file we will be editing
FILE=/etc/bind/domain.tld
DOMAIN=domain.tld
# A path to the BIND init script
BIND=/etc/init.d/bind9
ETCKEEP=/usr/sbin/etckeeper
SUDO=/usr/bin/sudo
@justincjahn
justincjahn / adlogin.aspx
Created February 2, 2012 23:45
AD Authentication
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Text.RegularExpressions" %>
<%@ Import Namespace="System.DirectoryServices" %>
<%@ Import Namespace="System.Web" %>
<%@ Page Language="C#" %>
<script language="c#" runat="server">
// Constants
const string AD_SERVER = "10.0.0.0";
const string AD_DOMAIN = "AD";
@justincjahn
justincjahn / serialconsole.applescript
Created April 3, 2012 18:51
GUI for serial connections.
tell me
# Focus the windows we are about to make
activate
#
# Ask the user what device they would like to use.
#
set strSerialDevices to (do shell script "ls /dev/tty.*")
set listDevices to (paragraphs of strSerialDevices) as list
set strDevice to (choose from list listDevices with prompt "Select Device:")
@justincjahn
justincjahn / dhcpSync.ps1
Created April 4, 2012 07:44
Poor man's DHCP sync.
<#
.SYNOPSIS
Safely restores DHCP Server scopes using the specified directory.
.DESCRIPTION
Performs a backup of the currently running DHCP Server to the given
directory. Pulls a reference backup from another location locally
and performs a restore operation.
Version: 0.0.1