Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / migrate.sql
Created April 18, 2019 22:06
use loop and declare variables to call procedure
BEGIN
FOR i IN (SELECT DUPPIDM as pidm FROM MIGRATEPIDMS) LOOP
declare
P_APPL_NO_OUT NUMBER;
term NUMBER;
num_apps NUMBER;
begin
select count(*) into num_apps from saradap where saradap_pidm = i.pidm;
@srkirkland
srkirkland / minst.ipynb
Created December 13, 2017 22:51
minst example for appdev presentation
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@srkirkland
srkirkland / failing.tsx
Created November 29, 2017 22:29
failing typescript stuff
Warning: setState(...): Can only update a mounted or mounting component. This usually means you called setState() on an unmounted component. This is a no-op.
Please check the code for the HelloWorld component.
@srkirkland
srkirkland / context.jsx
Created November 29, 2017 18:15
notes about how to enable context in TSX
// Main Type of the context
export interface ProviderContext {
name: String;
}
// Provider
export default class App extends React.Component<{}, {}> {
static childContextTypes = {
name: PropTypes.string
}
@srkirkland
srkirkland / authtokenfilter.cs
Created May 25, 2017 17:29
Token filter for securing APIs
using System;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Configuration;
using System.Web.Http;
using System.Web.Http.Controllers;
namespace GivingService.Attributes
{