Skip to content

Instantly share code, notes, and snippets.

@robshep
robshep / KairosDBEmbeddedContextInit.java
Last active April 20, 2020 09:24
Pooling HTTP Connection for KairosDB
package com.example;
import java.util.HashMap;
import java.util.Map;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ApplicationListener;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.event.ContextClosedEvent;
import org.springframework.core.env.MapPropertySource;
@robshep
robshep / README.md
Last active April 17, 2020 10:47
Linux Shell Power Snippets

Snippets for the shell (mostly bash)

Fetch a URL when you don't have wget or curl (e.g in an alpine docker container)

# drop in a function
fetch() { (echo -ne "GET $2 HTTP/1.0\r\nHost: $1\n\r\n"; sleep 5) | \
           openssl s_client -connect $1:443 -quiet -msgfile /dev/null | \
           perl -pe 'BEGIN { while (<>) { last if $_ eq "\r\n"; } }';
}
@robshep
robshep / .screenrc
Created April 15, 2020 17:48
screen RC
startup_message off
term screen-256color
bind ',' prev
bind '.' next
screen -t t2 /bin/false
screen -t t1 bash
select 0
kill
@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)';