Skip to content

Instantly share code, notes, and snippets.

@robshep
robshep / TestHashCode.java
Created March 30, 2020 11:21
Check out some operations to see if hashCode is used in the implementation: After reading https://vladmihalcea.com/the-best-way-to-implement-equals-hashcode-and-tostring-with-jpa-and-hibernate/
package com.example;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.HashSet;
import java.util.Set;
import org.junit.jupiter.api.Test;
public class TestHashCode
@robshep
robshep / Clock.java
Last active February 24, 2020 10:24
A test-adjustable fixable clock, with system default - overridden in tests - spring, spring-boot, java
// src/main/java/net/_95point2/clock/Clock.java
package net._95point2.clock;
import java.time.LocalDateTime;
public interface Clock
{
public long millis();
public LocalDateTime now();
@robshep
robshep / YugaByteDBDockeredStackManager.java
Created February 20, 2020 22:31
Attempt to load a yugabyte cluster in TestContainer
/**
* <dependency>
<groupId>com.yugabyte</groupId>
<artifactId>jdbc-yugabytedb</artifactId>
<version>42.2.7-yb-3</version>
</dependency>
*/
package net.thingping.yb.core.cfg;
import java.util.ArrayList;
@robshep
robshep / init-backup.sh
Created January 17, 2020 17:19
Prepare a backup configuration for a dataset, using borg within a docker-compose environment, using Rsync.net as an SSH repository
#!/bin/bash
DIR="backup"
if [ $# -ne 3 ]
then
echo ""
echo " usage: ./init.sh <app> <rsync.net user_id> <rsync.net host>"
echo " <app> is a single word, no spaces, lower case application or backup set ID"
@robshep
robshep / scsi_notes.md
Created January 15, 2020 16:37
SCSI scanning

SCSI notes

According to docs, adding a HDD in vmware requires a reboot to pick up the new disk.

Here's how to scan the SCSI bus to detect it.

  1. Use lsscsi to find the SCSI host ID

    $ which lsscsi > /dev/null || apt install -y lsscsi $ lsscsi

@robshep
robshep / local_ips
Created December 16, 2019 15:31
Find a list of IP addresses from local hardware only interfaces
#!/usr/bin/env python3
import os
import re
for dev in os.listdir('/sys/class/net'):
if os.path.isdir('/sys/class/net/' + dev + '/device'):
try:
print(re.search(' ([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})', os.popen('ip -br a show dev ' + dev).read()).groups()[0])
except:
@robshep
robshep / index.js
Created September 9, 2019 17:01
Convert RGBA on white to RGB
// taken from here and made to work
//
var debug = false;
//var rgbaColor = 'rgba(1,12,123,0.33)';
var rgbaColor = 'rgba(247, 224, 153, 0.247)';
// var rgbaColor = '#999';
// var rgbaColor = 'rgb(30, 20, 200)';
<html>
<body>
<h1 id="h">Hi 3</h1>
<script src="https://code.jquery.com/jquery-3.4.1.slim.js"></script>
<script>
function enterFullscreen() {
var element = document.documentElement;
@robshep
robshep / test_celery_mongo.py
Last active July 7, 2022 14:05
Quick test of Celery with MongoDB broker using mongo in docker
"""
Self-contained test for a simple Celery task interaction using an ephemeral MongoDB broker.
* MongoDB is created using docker with a temporary directory for storage.
* Celery broker is designated with the above containers random host-port.
* Celery worker is created using python Multi-process and managed.
* Triggers a distributed task
* Stops celery workers
* Stops mongodb container
* Removes temp directory.
@robshep
robshep / box_in_pipe.scad
Last active April 26, 2019 14:46
box in pipe
OD = 106; // outer diameter
PLATE_TH = 2; // base plate thickness
RING_TH = 5; // ring thickness
RING_DEPTH = 12; // depth of outer fixing ring
BOX_W = 35; // width of supplied enclosure
BOX_L = 50; // length of supplied enclosure
BOX_D = 12; // height of box grab. (20mm deep box)