Skip to content

Instantly share code, notes, and snippets.

@srkirkland
srkirkland / .gitattributes
Created June 18, 2012 21:17
basic gitattributes file, with auto LF normalization
# Auto detect text files and perform LF normalization
* text=auto
# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union
@srkirkland
srkirkland / drupalUploadMedia.js
Created August 2, 2022 20:45
Example of uploading an audio file to drupal via JSONAPI
import fetch from "node-fetch";
// env vars
const apiUser = "apiuser";
const apiPass = "pass";
const baseUrl = "https://example.org/jsonapi";
const auth = "Basic " + Buffer.from(`${apiUser}:${apiPass}`).toString("base64");
/* This snippet:
@srkirkland
srkirkland / download.sh
Created April 5, 2022 18:22
download files from remote (box) FTP matching pattern
wget -m -nd --ftp-user=srkirkland@ucdavis.edu "ftp://ftp.box.com/file*.jpg" --ask-password
@srkirkland
srkirkland / shibboleth2.xml
Created August 5, 2011 17:14
shibboleth config file
<SPConfig xmlns="urn:mace:shibboleth:2.0:native:sp:config"
xmlns:conf="urn:mace:shibboleth:2.0:native:sp:config"
xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"
clockSkew="180">
<!--
The InProcess section contains settings affecting web server modules.
Required for IIS, but can be removed when using other web servers.
@srkirkland
srkirkland / README
Created January 31, 2022 19:03
SSH dotnet
Just an example of running an ssh command on a remote server.
PK file needs to come from somewhere -- I think ideally Secret Vault but also base64 encoded secret would be a good choice.
Library used is https://www.nuget.org/packages/SSH.NET
@srkirkland
srkirkland / deploy.ps1
Created September 10, 2012 22:18
TeamCity CI Deploy Azure PowerShell Script
#Modified and simplified version of https://www.windowsazure.com/en-us/develop/net/common-tasks/continuous-delivery/
$subscription = "[Your Subscription Name]"
$service = "[Your Azure Service Name]"
$slot = "staging" #staging or production
$package = "[ProjectName]\bin\[BuildConfigName]\app.publish\[ProjectName].cspkg"
$configuration = "[ProjectName]\bin\[BuildConfigName]\app.publish\ServiceConfiguration.Cloud.cscfg"
$timeStampFormat = "g"
$deploymentLabel = "ContinuousDeploy to $service v%build.number%"
Write-Output "Running Azure Imports"
@srkirkland
srkirkland / csv_to_point_feature.py
Last active November 4, 2020 23:32
convert and merge csv in arcgis
import arcpy
import pandas as pd
import os
import re
homepath=r"C:\Users\postit\Downloads\testing"
output_path = os.path.join(homepath,"features")
arcpy.env.workspace = output_path
if not os.path.exists(output_path):
@srkirkland
srkirkland / cachesingeton.cs
Created April 22, 2013 18:37
Singleton for creating a cache factory for Azure Caching. Creates the DataCacheFactory only once and stores it in CacheFactory.Instance. Can then get a desired DataCache by calling CacheFactory.Instance.GetCache("CacheName");
public static class CacheFactory
{
/// <summary>
/// This is a thread-safe, lazy singleton. See http://www.yoda.arachsys.com/csharp/singleton.html
/// for more details about its implementation.
/// </summary>
public static DataCacheFactory Instance
{
get { return Nested.CacheFactory; }
}
@srkirkland
srkirkland / startup.cs
Created July 1, 2020 19:19
return 403 instead of redirect for API
.AddCookie(cookies =>
{
cookies.Events.OnRedirectToAccessDenied = ctx =>
{
if (ctx.Request.Path.StartsWithSegments("/api"))
{
ctx.Response.StatusCode = (int)HttpStatusCode.Forbidden;
return Task.CompletedTask;
}
return cookies.Events.OnRedirectToAccessDenied(ctx);
@srkirkland
srkirkland / web.config.xml
Created September 25, 2013 19:21
web.config static content and caching sections
<!-- GZip static file content. Overrides the server default which only compresses static files over 2700 bytes -->
<httpCompression directory="%SystemDrive%\websites\_compressed" minFileSizeForComp="1024">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
<staticTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/javascript" enabled="true" />
<add mimeType="application/json" enabled="true" />
<add mimeType="*/*" enabled="false" />
</staticTypes>