Skip to content

Instantly share code, notes, and snippets.

@MAOliver
MAOliver / Export-ExcelToSQL.ps1
Last active November 9, 2016 18:16
Something I created to allow me to rapidly iterate on my data model in Excel and re-seed the database as I adjust it. Uses powershell and some assumptions on the format of the data to accomplish it.
Function Export-WorksheetToCSV
{
<#
.Synopsis
This cmdlet converts .xlsx files to .csv.
.Description
This cmdlet uses COM to open XLSX and then saves every tab as a separate CSV file. This only works if the
individual tab CAN be converted to CSV.
@MAOliver
MAOliver / New-SelfSignedCertificateEx.ps1
Created July 20, 2015 12:30
Powershell - Admin and Infrastructure Pieces
#####################################################################
# New-SelfSignedCertificateEx.ps1
# Version 1.0
#
# Creates self-signed certificate. This tool is a base replacement
# for deprecated makecert.exe
#
# Vadims Podans (c) 2013
# http://en-us.sysadmins.lv/
#####################################################################
SELECT
ja.job_id,
j.name AS job_name,
ja.start_execution_date,
ISNULL(last_executed_step_id,0)+1 AS current_executed_step_id,
Js.step_name
FROM msdb.dbo.sysjobactivity ja
LEFT JOIN msdb.dbo.sysjobhistory jh
ON ja.job_history_id = jh.instance_id
JOIN msdb.dbo.sysjobs j
@MAOliver
MAOliver / GetAssemblyVersions.ps1
Created June 15, 2015 04:15
AssemblyVersionsToJson
Get-ChildItem "." -Filter *.exe | Select-Object -Property VersionInfo | ConvertTo-Json > assemblyversions.json
@MAOliver
MAOliver / EntityDbLoader
Created June 15, 2015 04:09
Bulk load to sql server from JSON using EF
using System;
using System.IO;
using Newtonsoft.Json.Linq;
namespace JsonToEntity
{
public static class EntityDbLoader
{
public static int SaveJsonToDatabase<T>( this IDbContext dbContext, string jsonPath, Func<dynamic, T> mappingFunction, int? batchSize = 200 ) where T : class
{
@MAOliver
MAOliver / EncryptionService
Created May 11, 2015 02:52
Simple encryption rijndael encryption wrapper
/// <summary>
/// Adapted from:
/// http://www.codeproject.com/Articles/5719/Simple-encrypting-and-decrypting-data-in-C
/// </summary>
public class EncryptionService : IEncryptionService
{
private readonly string _password;
private readonly byte[] _salt;
public EncryptionService( string password, string salt )
@MAOliver
MAOliver / AbstractSoapProvider
Created September 27, 2012 13:35
JAX-RS / Jersey Implementation of a SOAP consumer / producer. This lets you annotate your methods with application/soap+xml for soap 1.2 or text/xml for soap 1.1 and use it just like any other media type. Original idea from http://aruld.info/soap-over-res
package com.mao.jaxb.util;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;