View sftp-dir-to-remote.ps1
<# | |
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)] |
View Global.asax.cs
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"))) | |
{ |
View Global.asax.cs
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 | |
{ |
View MediaApiController.cs
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 |
View helper.logging.ps1
<# | |
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 |
View zipline.ps1
<# | |
Zip up textbase files in preparation for FTP sync to Andornot. | |
Peter Tyrrell, ptyrrell@andornot.com | |
-textbases c:\path\to\accessions.tba, c:\path\to\descriptions.tba | |
-out c:\path\to\destination | |
#> | |
param ( | |
[string[]] $textbases, |
View archive-project.ps1
param ( | |
[Parameter(Mandatory = $true)] | |
[string]$in, | |
[string]$out = "d:\dev-archive" | |
) | |
$extract_output_dir = "$in\extract\extracted\output\*" | |
remove-item $extract_output_dir -Recurse | |
Write-Host "Removed $extract_output_dir" |
View sitemap.ps1
<# | |
Create sitemap index with attendant sitemaps from a Solr query. | |
A new sitemap is created every 50,000 rows. | |
#> | |
param ( | |
[string]$ChangeFrequency = "weekly", | |
[string]$IndexBaseUrl = "http://andi.andornot.com/", | |
[string]$Logsrc = "Andi Solr Update", | |
[string]$OutDir = ".\", |
View optimize-pdf.ps1
<# | |
Downsample PDF and convert to gray if necessary. | |
Requires Ghostscript (gswin64c). | |
#> | |
param ( | |
[string]$indir, | |
[string]$outdir = $indir, | |
[string]$gs = "gswin64c", | |
[string]$dpi = "150" |
View logger.ps1
# all logging settins are here on top | |
$logFile = "log-$(gc env:computername).log" | |
$logLevel = "DEBUG" # ("DEBUG","INFO","WARN","ERROR","FATAL") | |
$logSize = 1mb # 30kb | |
$logCount = 10 | |
# end of settings | |
function Write-Log-Line ($line) { | |
Add-Content $logFile -Value $Line | |
Write-Host $Line |
NewerOlder