Skip to content

Instantly share code, notes, and snippets.

@simonmcconnell
simonmcconnell / notify_on_ping.ps1
Created March 28, 2024 01:19
notify me when a device is online
$ip =
$topic =
$delay = 30
while ($true) {
$pingResult = Test-Connection -ComputerName $ip -Count 1 -Quiet
if ($pingResult) {
Write-Host "done"
Invoke-RestMethod `
-Method 'Post' `
@simonmcconnell
simonmcconnell / surface_liveview_form_attribute.ex
Last active June 1, 2022 04:46
use the HTML form attribute
defmodule MyWeb.FormsComponent do
use Surface.Component
alias Surface.Components.Context
alias Surface.Components.Form.{Field, Label, TextInput}
def render(assigns) do
~F"""
<Context get={form: form}>
<Field name={:thing}>
<Label text="Thing" form={form} />
@simonmcconnell
simonmcconnell / wx_include.ex
Last active January 4, 2022 02:12
extract wxWidgets constants from Erlang include file for use in Elixir
defmodule WxInclude do
@moduledoc """
Creates functions for all the `wx` constants in `wx/include/wx.hrl`.
Function names match the constants except for the key codes, which we prepend `wx` onto, such that `WXK_NONE` becomes `wxWXK_NONE()`
## Usage
defmodule MyApp.Ui do
use Bitwise, only_operators: true
@simonmcconnell
simonmcconnell / di1.fs
Created June 18, 2020 10:38
F# dependency injection using partial application (one way to do it)
// from: https://www.reddit.com/r/fsharp/comments/haqfid/im_a_c_enthusiast_please_sell_me_f_in_what_areas/
// I tend to use the following convention when ordering function parameters:
let fooFactory (dep1,dep2,...) (arg1,arg2,...) (this:Bar) =
//Then use it like:
let fooer = fooFactory (dep1,dep2,...)
let bar = new Bar()
@simonmcconnell
simonmcconnell / sampledata.csv
Last active April 16, 2020 01:09
sample data for plotly
DATE TIME A B C
10/04/2020 8:00:00 AM 120 1.42 1.13
10/04/2020 8:00:10 AM 119 1.41 1.14
10/04/2020 8:00:20 AM 118.4 1.41 1.14
10/04/2020 8:00:30 AM 117.6 1.41 1.14
10/04/2020 8:00:40 AM 116.9 1.41 1.14
10/04/2020 8:00:50 AM 116 1.41 1.14
10/04/2020 8:01:00 AM 115.2 1.402 1.132
10/04/2020 8:01:10 AM 114.5 1.4 1.13
10/04/2020 8:01:20 AM 113.7 1.4 1.13
@simonmcconnell
simonmcconnell / AkkaNetRemoteMsg.fs
Last active February 28, 2020 22:16
Akka.NET remote messaging discriminated unions
// done using Akka.Net v1.4 pre-release
// will send messages back and forth forever
// paket.dependencies
// ------------------
//
// source https://api.nuget.org/v3/index.json
//
// storage: none
// framework: netcoreapp3.1, netstandard2.0, netstandard2.1
@simonmcconnell
simonmcconnell / kill citect.bat
Last active April 28, 2019 04:45
log users off terminal server
@echoStopping the Citect Runtimest . . .
@echo ----
@echo --
@echo ------
@taskkill /F /IM Citect32.exe
timeout /t 5
@echo --
@taskkill /F /IM Citect32.exe
timeout /t 5
@echo --
# it was discovered that Citect was not updating all the projects when running
# "Update project and all included projects"
# TODO: add logging
import win32api
import time
import win32com.client
from pywintypes import com_error
@simonmcconnell
simonmcconnell / pcm_import.py
Created July 9, 2018 00:57
Import projects into Proficy Change Management
# import projects into PCM that were backed up to <PROJECT>_<VER>.ZIP
# from the getAllVersions.vb Scheduler script
# can also rename projects on the way
# useful when migrating from VSS to SVN
import sys
from pathlib import Path
from shutil import make_archive, unpack_archive, copy2
import re
from xml.etree.ElementTree import ParseError, parse
@simonmcconnell
simonmcconnell / getAllVersions.vb
Created July 9, 2018 00:56
Backup all versions of selected projects in Proficy Change Management
'*********************************************************************************
' Product Module : Scheduler Scripts
' Script Name : getAllVersions.vb
' Function : Backup each version of a Machine Edition project and its history
' file. Designed to be used in conjunction with proficy_import.py
' script when migrating from VSS to SVN.
' retreives <projectname>_<version>.zip and <projectname>_history.xml
' for all projects selected in a manually triggered Scheduler Event.
'
' Change BackupFolder to the location of the project backup files.