Skip to content

Instantly share code, notes, and snippets.

View justincjahn's full-sized avatar

Justin Jahn justincjahn

View GitHub Profile
@justincjahn
justincjahn / gist:2223d4e916428507ea42
Created August 29, 2014 23:18
jQuery OAuth2 Bearer Login
$(function () {
$('#login').submit(function (e) {
e.preventDefault();
var formData = {
'grant_type': 'password',
'username': $('#username').val(),
'password': $('#password').val(),
'client_id': 'unknown',
'client_secret': 'unknown'
@justincjahn
justincjahn / gist:784decc3ec337ceafe94
Created June 20, 2014 18:33
Export SCSM Incidents including analyst and affected user names.
Import-Module SMLets
$IRClass = Get-SCSMClass -Name System.WorkItem.Incident
$ASClass = Get-SCSMRelationshipClass -Name System.WorkItemAssignedToUser$
$AFClass = Get-SCSMRelationshipClass -Name System.WorkItemAffectedUser$
$IR = Get-SCSMObject -Class $IRClass | Select -Property `
@{Label="Queue";Expression={$_.TierQueue.displayname}}, `
Id, `
Title, `
@justincjahn
justincjahn / WebDav.cs
Last active March 23, 2018 20:55
A simple WebDAV client class.
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Text;
using System.Xml;
namespace JahnDigital.Net.WebDAV
{
/// <summary>
@justincjahn
justincjahn / ParseCSV.cs
Last active October 14, 2018 12:22
Quick & Dirty CSV Parsing
/// <summary>
/// Parse a single line in CSV format.
///
/// This method uses a character looping in lieu of String.Split for performance. You could
/// squeeze more performance out of it by using .NET 4 MemoryMappedFiles for large reads and
/// possibly pointer arithmatic instead of native C# looping. Using LinkedList may also help
/// for really large lines.
/// </summary>
/// <param name="line">The line to parse.</param>
/// <param name="delimiter">The delimiter that separates each value. Usually a comma.</param>
@justincjahn
justincjahn / TechnicLauncher
Last active December 19, 2015 00:29
OSX Technic Launcher App
#!/bin/bash
#
# TechnicLauncher
# Launches the TechnicLauncher.jar using Java 6.
# Get the current script directory.
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Set the Java version to 1.6 otherwise Minecraft will crash when launched with Technic
export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/
@justincjahn
justincjahn / Microsoft.PowerShell_profile.ps1
Created April 27, 2013 00:16
Github for Windows PowerShell profile.
# Dot source the GitHub for Windows shell variables
. (Join-Path $env:USERPROFILE "AppData\Local\GitHub\shell.ps1")
# Load posh-git module from current directory
Import-Module (Join-Path $env:github_posh_git "posh-git.psm1")
# Set up a simple prompt, adding the git prompt parts inside git repos
function prompt {
$realLASTEXITCODE = $LASTEXITCODE
@justincjahn
justincjahn / gist:3649783
Last active October 10, 2015 06:47
List Active Directory Users and Groups
Get-ADUser -Filter * -Properties MemberOf | select @{n="Username";e={$_.Name}},@{n="SID";e={$_.SID}},@{n="Security Groups";e={($_.MemberOf | Where-Object {($_ | get-adgroup).GroupCategory -eq "Security"} | Foreach-Object { ($_ | get-adgroup).Name}) -join "; "}},@{n="Distribution Groups";e={($_.MemberOf | Where-Object {($_ | get-adgroup).GroupCategory -eq "Distribution"} | Foreach-Object { ($_ | get-adgroup).Name}) -join "; "}} | Export-Csv -NoTypeInformation C:\Users\jjahn\Documents\users.csv
@justincjahn
justincjahn / hpLabel.pl
Created July 26, 2012 23:09
Change LCD screen on an HP printer.
#!/usr/bin/env perl
use strict;
use IO::Socket;
#
# Check to see if an element is in a given array.
#
# @param string $strNeedle The string to search for.
# @param array @arrHaystack The array to look in. Defaults to @ARGV.
@justincjahn
justincjahn / generateNat.pl
Created July 26, 2012 23:08
FortiGate: Generate NAT configuration from given parameters.
#!/usr/bin/env perl -w
use strict;
use Getopt::Long;
use Pod::Usage;
# Configuration
my %config = (
'name' => undef,
'externalIp' => undef,
@justincjahn
justincjahn / README.md
Created July 26, 2012 22:55
Address validation using Google Maps

Google Maps Address Verification

The HTML and accompanying scripts in this project demonstrate how to present users with a "did you mean..." style address validation mechanism that helps to ensure accurate addresses for sites that need said information.

Google Maps API Key

The script will need your own API key to function, my key has been redacted.