Show full content
Open ubuntu Settings-> Keyboard shortcuts

Click on + at the bottom to add custom shortcut and use command ‘flameshot gui’ with key combination of your choice :

Open ubuntu Settings-> Keyboard shortcuts

Click on + at the bottom to add custom shortcut and use command ‘flameshot gui’ with key combination of your choice :

aws ec2 describe-instances --query "Reservations[].Instances[].{PublicIP:PublicIpAddress,Name:Tags[?Key=='Name']|[0].Value,Status:State.Name}" --query "Reservations[].Instances[].{PrivateIpAddress:PrivateIpAddress,Name:Tags[?Key=='Name']|[0].Value,Status:State.Name}" --output table
A very lightweight and powerful tool to loadtest any http endpoints is k6.
It allows you to run basic javascripts in parallel for any duration. You can tweak the number of parallel threads and the duration.
Checkout https://k6.io/unit-testing-for-performance/ for more details
I tested the performance of camunda , for start, fetchAndLock and complete APIs using the following scripts:
Start BPMN Process:
import http from 'k6/http';
const url = 'http://localhost:8080/engine-rest/process-definition/key/sample-parallel/start';
export default function () {
let data = {
"variables": {
"deposit": {"value":"vendor1","type":"String"},
"amount":{"value":"100","type":"Long"},
"tax":{"value":"123","type":"Long"}
}
};
// Using a JSON string as body
let res = http.post(url, JSON.stringify(data), {
headers: { 'Content-Type': 'application/json' },
});
}
Run the above script with 20 virtual users ( concurrent) for 30 s
k6 run --vus 20 --duration 30s start.jsFetchAndLock and Complete
import http from 'k6/http';
import { check, fail } from 'k6';
const url = 'http://localhost:8080/engine-rest/external-task/fetchAndLock';
const maxTasks=1
// here the name of the topic is as per topic name in BPMN
export default function () {
let data = {
"workerId":"aWorkerId1",
"maxTasks":maxTasks,
"usePriority":false,
"topics":
[{"topicName": "par-task2",
"lockDuration": 10000
}]
}
;
// Using a JSON string as body
let res = http.post(url, JSON.stringify(data), {
headers: { 'Content-Type': 'application/json' },
});
check(res, {
'body size is more than 2 bytes': (r) => r.body.length >= 5,
'received full set as per maxTasks': (r) => r.json().length == maxTasks,
});
const arr=res.json().length;
if(arr>0){
let complete= {
"workerId": "aWorkerId1",
"variables":
{"status": {"value": "done with task1"}
}
}
let externalTaskId= res.json()[0].id;
let completeUrl= 'http://localhost:8080/engine-rest/external-task/'+externalTaskId+'/complete';
let completeRespo = http.post(completeUrl, JSON.stringify(complete), {
headers: { 'Content-Type': 'application/json' },
});
}
Run the above script with 20 virtual users ( concurrent) for 60 s
k6 run --vus 20 --duration 60s fal.js
Retry all messages from a Dead letter queue :
curl -XGET --user admin:admin --header "Origin: http://localhost" http://localhost:8161/api/jolokia/exec/org.apache.activemq:brokerName=localhost,destinationName=ActiveMQ.DLQ,destinationType=Queue,type=Broker/retryMessages
Send a message to a queue
curl -u admin:admin -d "body={'a': 'b'}" -d "MessageProperyName=value" http://activemq.local:8161/api/message/VirtualTopic.Event.Application.important.event
If you want to find and print the top 10 largest files names (not directories) in a particular directory and its sub directories
$ find . -printf '%s %p\n'|sort -nr|head
To restrict the search to the present directory use “-maxdepth 1” with find.
$ find . -maxdepth 1 -printf '%s %p\n'|sort -nr|head
And to print the top 10 largest “files and directories”:
$ du -a . | sort -nr | head
Use "head -n X" instead of the only "head" above to print the top X largest files (in all the above examples)
Further , if you wish to find all files that are greater than 1 GB, use the following:
du -h -t 1G
ActiveMQ provides an easy to use api that can be used to produce or consume messages via commandline.
See ActiveMQ site for detailed post.
Simple command to post to a queue :
curl -XPOST -d "body=<<messagebody>>" http://admin:admin@activemqhost:8161/api/message?destination=queue://desiredQueue
Having been bitten by this bug multiple times, i am posting a small program that illustrates Thread Safety issues in using SimpleDateFormatter from java .
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
public class DateChecker {
static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
static DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
public static void main(String[] args) throws ParseException {
AtomicInteger mismatchCounterForSDF = new AtomicInteger(0);
AtomicInteger mismatchCounterForNewDF = new AtomicInteger(0);
Date oldest = new Date(0);
Date now = new Date();
Date future = new Date(new Date().getTime() + 1576800000000L);
Date[] dt = {oldest, now, future};
String[] dtString = {simpleDateFormat.format(oldest), simpleDateFormat.format(now), simpleDateFormat.format(future)};
ExecutorService executorService = Executors.newFixedThreadPool(10);
for (int i = 0; i < 10000; i++) {
final int j = i;
executorService.submit(() -> {
String threadName = Thread.currentThread().getName();
String formattedDate = simpleDateFormat.format(dt[j % 3]);
LocalDateTime utcdate = dt[j % 3].toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
String newFormattedDate = formatter.format(utcdate);
if (!(dtString[j % 3].equalsIgnoreCase(formattedDate))) {
System.out.println("Mismatch occured " + mismatchCounterForSDF.incrementAndGet() + ": actual date :" + dtString[j % 3] + " FormattedDate is : " + formattedDate);
}
if (!dtString[j % 3].equalsIgnoreCase(newFormattedDate)) {
System.out.println("NEW DF Mismatch occured " + mismatchCounterForNewDF.incrementAndGet() + ": actual date :" + dtString[j % 3] + " FormattedDate is : " + newFormattedDate);
}
}
);
}
executorService.shutdown();
try {
executorService.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
} catch (InterruptedException e) {}
System.out.println("Total mismatched for SimpleDateFormatter"+mismatchCounterForSDF.get());
System.out.println("Total mismatched for DateTimeFormatter"+mismatchCounterForNewDF.get());
}
}
Running the above will quick illustrate how using a global instance for SimpleDateFormatter can lead to incorrect date results:
Mismatch occured 2: actual date :2069-10-19T11:59:20.530Z FormattedDate is : 2069-10-01T05:30:00.000Z Mismatch occured 3: actual date :2019-11-01T11:59:20.530Z FormattedDate is : 2019-11-19T11:59:20.530Z Mismatch occured 1: actual date :2019-11-01T11:59:20.530Z FormattedDate is : 1970-01-01T05:30:00.000Z Mismatch occured 4: actual date :2069-10-19T11:59:20.530Z FormattedDate is : 2069-10-01T05:30:00.000Z Mismatch occured 5: actual date :1970-01-01T05:30:00.000Z FormattedDate is : 1970-01-01T11:59:20.530Z .... Total mismatched for SimpleDateFormatter2049 Total mismatched for DateTimeFormatter0
A shoutout to https://www.callicoder.com/java-simpledateformat-thread-safety-issues/
from whose program the above snippet evolved.
You can spool from hive similar to sqlplus using :
insert overwrite local directory '/some/local/folder' row format delimited fields terminated by ','
if hive is configured to generate compressed output, the hive output might be a .deflate file. you can decompress it as follows
cat 000000_0.deflate |perl -MCompress::Zlib -e 'undef $/; print uncompress(<>)'
The below command can be used for quick conversion of windows saved files to unix
perl -pi -e 's/\r\n/\n/g' input
This week I learnt Generics can be quite useful to retrofit a combination of interfaces .
e.g suppose your method wants to accept any Object that implements Cloneable and Runnable . you can do this via
public <T extends Cloneable & Runnable> void someMethod(T obj)
See the following video for this and much more
https://skillsmatter.com/skillscasts/7618-java-generics-past-present-and-future