Skip to content

Instantly share code, notes, and snippets.

View goblinfactory's full-sized avatar
💭
g=c800:5

Alan Hemmings goblinfactory

💭
g=c800:5
View GitHub Profile
@goblinfactory
goblinfactory / generateFullText.cs
Last active September 19, 2023 13:47
Codegen to generate embedded (hard coded) index for full text search without stemming
// NOTE : code below generated by Bard. I have no idea if this works, i've not tested it.
// The entire pattern itself is uncomplicated, so just leaving this here as a starter and I'm
// sure most folk can finish what they need from this as a starter.
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
namespace CsvToTsSearch
@goblinfactory
goblinfactory / encrypt_values.sh.md
Created June 9, 2023 22:17
ChatGTP test - Write a bash script that will encrypt the values in a text file

I asked ChatGTP the following

write a bash script that will encrypt the values in text file 
with rows containing the following lines with the following format
KEY=VALUE

- script must run on OSX
- script must accept a password to use to encrypt the values
- no salt is required, favour simplicity, 
@goblinfactory
goblinfactory / how-to-run-elastic-on-azure.md
Last active December 22, 2022 14:39
how-to-run-elastic-on-azure.md courtesy of chat GPT (no warrantees provided)

Question to ChatGPT : how can run elasticsearch on Azure using containers, explained with sample code?

answer below

To run Elasticsearch on Azure using containers, you will need to create a container image that includes Elasticsearch and any dependencies it requires, and then push the image to a container registry such as the Azure Container Registry (ACR). You can then deploy the image to Azure using Azure Container Instances (ACI) or Azure Kubernetes Service (AKS).

Here is an example of how you can do this using Docker and the Azure CLI:

Create a Dockerfile for your Elasticsearch container image. This file should include instructions for installing Elasticsearch and any dependencies it requires. Here is an example Dockerfile that installs Elasticsearch on Ubuntu: Copy code

@goblinfactory
goblinfactory / controlc.go
Last active October 6, 2021 10:28
TestControlC tests how to will kick of main's defer as well as background goroutine cancel when user presses control+c
package controlc
import (
"context"
"fmt"
"math/rand"
"os"
"os/signal"
"sync"
"time"
@goblinfactory
goblinfactory / CSharpIdiomaticUsingTasks.cs
Last active September 21, 2021 19:14
Attempt at writing a C# equivalent to how GO routines are easily synchronised with channels and sync.Wait
using System;
using System.Collections.Concurrent;
using System.Threading;
using System.Threading.Tasks;
namespace Muxy
{
public static class CsharpIdiomaticUsingTasks
{
@goblinfactory
goblinfactory / muxy-idiomatic-waitgroup.go
Last active September 16, 2021 12:14
how to use WaitGroup and signals to safely synchronise goroutines as "idiomatic" as I can think of ..given what I know at the moment. (not much! loL!)
package muxyidiomatic
import (
"fmt"
"math/rand"
"sync"
"time"
)
func EvenOddWithWaitGroup() {
@goblinfactory
goblinfactory / muxy-idiomatic.go
Last active September 15, 2021 18:01
how to signal to two services to stop, and have each service signal back when stopped and efficient sychronisation without sleep
package muxy
import (
"fmt"
"time"
)
func Main() {
var stopEvens = make(chan struct{})
@goblinfactory
goblinfactory / even-odds.go
Last active September 15, 2021 17:19
using bool channels to signal a service to stop, and to signal when the service has stopped.
package muxy
import (
"fmt"
"time"
"github.com/goblinfactory/greeting/pkg/rnd"
)
func EvenOdd3() {
@goblinfactory
goblinfactory / dev-tests.ps1
Last active January 27, 2021 08:05
Start your azure function project, send test output and "functions" output to logfiles, run your dotnet flurl end to end tests, stop functions (less that 10 lines of code)
$Env:environment="dev"
$func = (get-command func).Source
$args = "start"
$dir = ".\{your-azure-function-project}\bin\Debug\netcoreapp3.1"
$proc = Start-Process -FilePath $func -WorkingDirectory $dir -ArgumentList $args -RedirectStandardOutput .\tests\{your-azure-function-project}.log
Start-Sleep -seconds 10
dotnet test {your-azure-function-project}.AcceptanceTests -v m --no-build > .\tests\{your-azure-function-project}-tests.log
$proc | kill
Write-Host "finished"
public void MembershipTests()
{
// need to do this in parallel for (n) users.
// ------------------------------------------
// given an empty database
// with no users in db
// and no active sessions
// when I register a user
// then the user is registered
// and the user has no active sessions