Skip to content

Instantly share code, notes, and snippets.

@aadennis
aadennis / get_shape1.r
Created June 16, 2023 15:07
Read a shape file using st_read
require("sf")
# local variables
shapefile_name <- "LSOA_2011_EW_BFC"
shape_location <- "C:/mapdata/lsoa/boundaries/demo"
columns <- "*"
local_tempdir <- "c:/temp"
# arrange
shapefile <- paste(shape_location, "/", shapefile_name, ".shp", sep = "")
@aadennis
aadennis / 4_postcodes_in_a_dataframe.R
Last active January 17, 2023 10:19
Adding observations to an existing dataframe
if (!require('PostcodesioR')) {
install.packages('PostcodesioR')
library('PostcodesioR')
}
postcodeSet.df <- postcode_lookup("EC1N 2HT")
mahSubset <- subset(postcodeSet.df, select=c(postcode, nhs_ha))
# demo 1 row...
str(mahSubset)
@aadennis
aadennis / ModWeightNotWorking.kt
Created December 18, 2022 10:49
Android Compose: weight modifier gives missing library. I don't know why.
package com.example.mahstaff
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
@aadennis
aadennis / SetGoogleDocsHeading.js
Last active February 26, 2022 15:40
Set Google Docs Heading
// reference:
// https://developers.google.com/apps-script/reference/document/body#getchildindexchild
// https://developers.google.com/apps-script/reference/document/body#getattributes
// https://stackoverflow.com/questions/8273047/javascript-function-similar-to-python-range
function log(message) {
//Logger.log(message)
}
function getTextLineFromBody(theBody, index) {
@aadennis
aadennis / DenoPostJson.ts
Created October 18, 2020 21:07
Rest-Post JSON via Deno
// Credit for the basics:
// https://github.com/oakserver/oak/blob/main/examples/routingServer.ts
// Setup: Install deno
// Usage: deno run -A ./DenoPost.ts
// Use e.g. Postman to POST the json payload to http://127.0.0.1:8000/book
// Use e.g. any browser to read the json in memory: http://127.0.0.1:8000/book
import {
bold,
cyan,
@aadennis
aadennis / F-Utilities.ps1
Created September 27, 2020 15:45
dependency for DockerUtilities.ps1
<#
Get the name of each function in the given PowerShell Script.
Assumptions:
1. the line starts with "function".
2. A line starting with "function" is not embedded in a comment block.
There is no error handling.
#>
function Get-FunctionsInScript($script) {
Get-Content $script | ForEach-Object {
$currentLine = $_
@aadennis
aadennis / run-container.ps1
Last active September 24, 2020 07:50
Run a container from an image. If there is no image argument passed, select from a known set. See comments.
$imageSet =
"mcr.microsoft.com/windows/servercore:ltsc2016",
"mcr.microsoft.com/windows/servercore:ltsc2019",
"mcr.microsoft.com/windows/servercore:10.0.14393.3808"
function Run-Container($volumeShare, $image) {
if ($image -eq $null) {
Write-Host "No image passed in. Select from the following..."
$index = 0
$imageSet | ForEach-Object {
@aadennis
aadennis / Get-WindowsInfo.ps1
Created September 23, 2020 07:40
Return Windows info, typically for confirming OS in a container
function Get-WindowsInfo() {
Write-Host "Hostname: $(& HOSTNAME.EXE)"
systeminfo /fo csv | ConvertFrom-Csv | Select-Object OS*, System*, Hotfix* | Format-List
write-host "Semantic file version..."
(Get-ItemProperty -Path C:\Windows\System32\hal.dll).VersionInfo.FileVersion
# Write-host "OS Caption..." - redundant
# (Get-WmiObject -Class win32_OperatingSystem).Caption
}
########################################## Dockerfile
#escape=`
ARG WINVER=ltsc2019
FROM mcr.microsoft.com/windows/servercore:$WINVER
WORKDIR c:\artifacts
RUN net user /add dennis
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
. $here/Utilities.ps1
#. "C:\Sandbox\docker\utilities\DockerUtilities.ps1"
function Remove-AllContainers {
$containers = $(docker ps -a) | Select-Object -Skip 1
$containers | ForEach-Object {
$containerId = $_.substring(0, 12)
Remove-Container $containerId
}