Skip to content

Instantly share code, notes, and snippets.

View easternnl's full-sized avatar

easternnl easternnl

View GitHub Profile
@easternnl
easternnl / datetimestamp2epoch.groovy
Created July 9, 2020 14:27
Convert datetimestamp to epoch in Groovy
import java.time.*
db2time = '2020-07-09 14:19:10.966'
epoch = Date.parse("yyyy-MM-dd HH:mm:ss.SSS", db2time)
log.info("" + epoch.getTime())
return epoch.getTime()
@easternnl
easternnl / filelist2json.py
Created June 19, 2020 13:03
Python file list convert to JSON with MTime included (and other properties if needed)
import os, json
class FileItem(dict):
def __init__(self, name):
dict.__init__(self, name=name)
dict.__init__(self, mtime=os.path.getmtime(name)) # get the modify time
my_objects = []
for root, dirs, files in os.walk("./JMeterReplaceAllVariabelesInVar/", topdown=False):
@easternnl
easternnl / README.md
Created April 10, 2020 10:19
Howto in crease LVM partition

Resize LVM partitions

lvextend -L+5G /dev/mapper/vg_sys-lv_opt
xfs_growfs /dev/mapper/vg_sys-lv_opt
resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
@easternnl
easternnl / logging_setup.py
Created March 31, 2020 04:17
Python logging to file and to console - as in https://stackoverflow.com/a/46098711
import logging
# remove '%(created)f' to avoid logging the timestamp in epoch
logging.basicConfig(level='INFO',
format='%(asctime)s %(created)f %(message)s',
handlers=[
logging.FileHandler(datetime.now().strftime(testrun + ".log")),
logging.StreamHandler()
])
@easternnl
easternnl / thread1.cmd
Created March 10, 2020 09:01
Python threading with subprocess
@echo off
echo This is %0
timeout 3
@easternnl
easternnl / filter_with_python.py
Created March 10, 2020 06:12
Python Filter Example
with open('testrun_20200310_065041_read.jtl') as fp:
#lines = fp.readlines()
#messages = filter(lambda item : "MessageReader" in item , lines )
messages = list(filter(lambda item : "MessageReader" in item , fp.readlines() ))
print(messages)
print(len(messages))
@easternnl
easternnl / yaml-python-test-example.py
Created March 6, 2020 09:48
YAML with Python Example
import sys
from ruamel.yaml import YAML
yaml = YAML()
# read from disk:
#with open("test2.yml") as stream:
# code = yaml.load(stream)
# read from code:
@easternnl
easternnl / datetime.sql
Created March 2, 2020 08:21
SQLite DateTime table with min and max
WITH RECURSIVE dates(datetime) AS (
VALUES('2015-10-03 08:00:00')
UNION ALL
SELECT datetime(datetime, '+1 second')
FROM dates
WHERE datetime < '2015-10-03 10:00'
)
SELECT datetime FROM dates;
@easternnl
easternnl / listproperties.groovy
Created December 17, 2019 06:18
List & Setup JMeter / Java System Properties from within the script
// list all properties to the log.info, but can also use println
log.info ( System.properties.collect({it}).join(' \n'))
// list a single propertie in the log
log.info ("javax.net.ssl.trustStore: " + System.getProperty("javax.net.ssl.trustStore"))
@easternnl
easternnl / timeout.pl
Created November 15, 2019 09:10
A timeout/pause function which will display how long the user needs to wait before the script continues
#!/usr/bin/perl
$| = 1; # flush everything directly to the output buffer
timeout(10);
sub timeout
{
my $wait = shift;
for (my $i=$wait; $i > -1; $i--)