Posts

Showing posts from August, 2026

Updating the Tapeless Camera

Image
  Found a nice little JVC GY HD100 at a Radio Rally which will become the base of the next Tapeless Hack. This cam at least is HD (only 720p) But has Firewire, So I need to get the nNovia working with that first. Then if that works, will look to upgrade the nNovia to SSD.

Python - Dataclasses

Image
  Dataclass Python dataclasses are a new feature introduced in Python 3.7 that allows users to define classes that are primarily used to store data. They are similar to namedtuples, but with some additional features that make them more powerful and flexible. NamedTuple typing.NamedTuple was introduced in Python 3.6 in the typing module and supercede the collections.namedtuple. They allow users to define a class with named fields. NamedTuples are immutable.They are useful for creating simple, immutable data objects. Pydantic Pydantic is a third-party library that provides data validation and settings management using Python type annotations. It is built on top of Python's type hints, which makes it easy to define the structure of your data. Pydantic is designed to be fast and to consume minimal resources, making it suitable for use in large projects. Comparison Python dataclasses are more powerful than namedtuples because they allow for mutable objects, inheritance, and defau...

Go - Interface 101

Image
  package main import ( "fmt" ) // A 'class' struct for keeping Deployment data type Deployment struct { Platform string Service string } // A method that acts on Deployment data func (d Deployment) String() string { return fmt.Sprintf("Deployment: %s - %s", d.Platform, d.Service) } // An interface for things that have a String function type StringifiableObject interface { String() string } // A function that can show StringifiableObjects func show(s StringifiableObject) { fmt.Println(s.String()) } func main() { // Create Deployment which has a String method d := Deployment{ Platform: "Eschaton", Service: "alpha", } // Show the Deployment, which is a StringifiableObject show(d) }

Go - Tests - Fizzbuzz

Image
  Using FizzBuzz as an example. main_test.go package main import "testing" import "github.com/stretchr/testify/assert" func Test_run(t *testing.T) { fb := run(1,15) assert.Equal(t, "1,2,Fizz,4,Buzz,Fizz,7,8,Fizz,Buzz,11,Fizz,13,14,FizzBuzz", fb) } main.go package main import "fmt" import "strconv" import "strings" func main() { fmt.Println("FizzBuzz Test") } func run(N int, M int) string { out := []string{} for i := N; i<=M; i++ { out = append(out, fizzbuzz(i)) } return strings.Join(out, ",") } func fizzbuzz(n int) string { switch { case (n % 3 == 0) && (n % 5 ==0): return "FizzBuzz" case n % 3 == 0: return "Fizz" case n % 5 == 0: return "Buzz" default: return strconv.Itoa(n) } } go.mod module fizz go 1.18 require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect ...

Go - Hello World!

Image
  mkdir hello cd hello go mod init hello hello.go package main import "fmt" func main() { fmt.Println("Hello, world") } go run hello.go.

Go - Project Layout

Image
  Core cmd/ Main applications for this project. The directory name for each application should match the name of the executable eg. /cmd/custard internal/ Private application and library code. Enforced by the go compiler. pkg/ Library code that is ok to be used by external applications. api/ OpenAPI/Swagger specs, JSON schema files, protocol definition files. vendor/ Application dependencies managed manually or by go mod vendor. web/ Webapp specific components configs/ Config file templates or default config. Build and CI related init/ System init scripts scripts/ General build, install, analysis scripts build/ Packaging and CI scripts and configs deployments/ test/ docs/ tools/ examples/ third-party/

Docker - exporting & importing images

Image
  Export all images docker save -o stack.tar $(docker images --format "{{.Repository}}:{{.Tag}}") Export images from docker compose docker save $(docker compose convert --images) | gzip > stack.tgz Load the stack docker load -i stack.tar Some extra sysadmin tasks Truncate the logs sudo sh - c "truncate - s 0 /var/lib/docker/containers/ **/*-json.log"   Kill all images - use at your peril. docker images -a docker rmi $(docker images | awk "NR>0 {print$3}")  

Beef Goulash with Dumplings

  Beef Goulash with Dumplings 10 minutes 2 hours, 15 minutes Serves 4 to 6 Goulash 2 Tbsp olive oil 2 large onions, thinly sliced (about 4 cups sliced onions) 1 Tbsp sugar 3 garlic cloves, minced (about 1 Tbsp) 1 Tbsp caraway seeds, toasted and ground 1 1/2 tablespoons sweet Hungarian paprika 1 teaspoon spicy Hungarian paprika 2 Tbsp minced fresh marjoram or oregano (or 1 Tbsp of dried) 1 teaspoon minced fresh thyme (or 1/2 teaspoon dried) 1 bay leaf 3 Tbsp tomato paste 2 Tbsp balsamic vinegar 4 cups chicken stock 2 1/2 pounds chuck roast, cut into 2-inch cubes (trimmed of excess fat) 1 teaspoon kosher salt 1/4 teaspoon freshly ground black pepper Dumplings 2 cups cake flour 2 teaspoons baking powder 1 teaspoon salt 3/4 cup milk 2 Tbsp melted butter METHOD 1 Cook the onions, add garlic and caraway: Heat olive oil in a large sauté pan on medium high heat. Add the onions, sprinkle with sugar, and cook, stirring often, until the onions are browned and caramelized, about 20 m...

Chilli Con Carnage

Image
  Chilli Con Carnage Light the fire - 1 log, some kindling & some small log pieces 1tbsp Sesame oil, 1tbsp Olive oil in the pan 1/2 Kg mincemeat into the pan.. When it starts cooking, add spices.. 2 tsp Chinese 5 spice 1 tsp turmeric 2 tsp mixed herbs 1 tsp paprika 3 OXO Cubes 6 small dried chillis, crumbled in. Cook mincemeat over the high heat of the fire until nearly done. Add sauces. 2 tins chopped tomatos - mutti polpa 2 tins red kidney beans Simmer over the fire as the heat dies down.

Ansible Variable Precedence

Image
Ansible Variable precedence command line values (for example,  u my_user , these are not variables) role defaults (defined in role/defaults/main.yml) inventory file or script group vars inventory group_vars/all playbook group_vars/all inventory group_vars/* playbook group_vars/* inventory file or script host vars inventory host_vars/* playbook host_vars/* host facts / cached set_facts play vars play vars_prompt play vars_files role vars (defined in role/vars/main.yml) block vars (only for tasks in block) task vars (only for the task) include_vars set_facts / registered vars role (and include_role) params include params extra vars (for example,  e "user=my_user" )(always win precedence) credit:   https://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html