This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
Split csv files with or without header rows, multiline columns with newlines ok. | |
#> | |
param ( | |
[string]$in, | |
[string]$outdir = [System.IO.Path]::GetDirectoryName($in), | |
[int]$count = 1000, | |
[string]$delimiter = ',', | |
[string[]]$header = @() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
Sync a directory to remote server in FTP mode | |
Peter Tyrrell | |
#> | |
param( | |
[Parameter(Mandatory = $false, Position = 0)] | |
[string]$logsrc = "", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
1. Leaf | |
Given a text file of TIF/TIFF filenames, create DZI (Deep Zoom Image) tiles from TIFs | |
and create a mirror directory structure for DZI file outputs. | |
* Handles filenames with entry separators | |
* Ignores TIF older than its DZI mirror unless -force param is used | |
* Requires libvips (https://libvips.github.io/libvips/) | |
.\tif2dzi.ps1 -in c:\dev\abc\extract\extracted\tifs\abc-tifs-1.txt ` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
Peter Tyrrell, Andornot | |
Replaces old sql server name with new in textbase binary *.cbs file. | |
Note: Uses PowerShell Core syntax. See comments for Windows PowerShell. | |
Note: Server names of different lengths corrupt the file. | |
#> | |
param ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
Modifies regedit to tell all versions of .NET to use strongest available TLS. Global setting. | |
Requires admin privileges. | |
Peter Tyrrell | |
#> | |
# check for admin | |
if (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { | |
Write-Warning ("You do not have admin privileges. Re-run this script as an administrator.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
Sync a local to remote directory in SFTP mode | |
#> | |
param( | |
[Parameter(Mandatory = $false, Position = 0)] | |
[string]$logsrc = "", | |
[Parameter(Mandatory = $true, Position = 1)] | |
[string]$hostname, | |
[Parameter(Mandatory = $true, Position = 2)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void Application_Start() | |
{ | |
// various setup bits here... | |
Config.Current.Pipeline.AuthorizeImage += | |
delegate (IHttpModule sender, HttpContext context, IUrlAuthorizationEventArgs e) | |
{ | |
// only restrict ~/media | |
if (!e.VirtualPath.StartsWith(VirtualPathUtility.ToAbsolute("~/media"))) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Web.Http; | |
using System.Web.Mvc; | |
using System.Web.Routing; | |
using Andi.MVC.Core; | |
using Andi.MVC.Core.Infrastructure.Globalization; | |
namespace Andi.MVC.Web | |
{ | |
public class MvcApplication : System.Web.HttpApplication | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MediaApiController : ApiController | |
{ | |
public HttpResponseMessage Get(string filepath) | |
{ | |
var path = HostingEnvironment.MapPath($"~/media/{filepath}") ?? string.Empty; | |
var mediaType = MediaTypeHeaderValue.Parse(MimeMapping.GetMimeMapping(filepath)); | |
FileStream stream; | |
try |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
Logging functions. | |
#> | |
function logError([string]$logsrc, [string]$msg) { | |
if ([String]::IsNullOrWhiteSpace($logsrc)) { | |
write-log -msg $msg -level "ERROR" | |
} | |
elseif (@(".txt", ".log").Contains([System.IO.Path]::GetExtension($logsrc)) -eq $true) { | |
write-log -msg $msg -level "ERROR" -file $logsrc |
NewerOlder