Skip to content

Instantly share code, notes, and snippets.

@bsenduran
bsenduran / bash_aliases
Created October 28, 2021 10:06
switching between java versions
alias j8='export JAVA_HOME=/home/installs/java/jdk1.8.0_291; export PATH=$JAVA_HOME/bin:$PATH'
alias j11='export JAVA_HOME=/home/installs/java/jdk-11.0.12; export PATH=$JAVA_HOME/bin:$PATH'
#! /bin/bash
for i in $(seq 1 408)
do
f=seg-$i-v1-a1.ts
# echo $f
wget "<URL>/$f"
cat $f >> all.ts
rm $f
done
@bsenduran
bsenduran / top-consumers.sh
Last active December 20, 2017 04:41
Analyze the thread usage of a java application and prints the top CPU consuming threads
#!/bin/bash
if [ "$#" -ne 2 ]; then
echo "usage: sh top-consumers.sh <pid> <number-of-consumers>"
exit
fi
lowerBound=$(expr "$2" + 1)
jstack -l $1 > top-consumers_thread_dump.txt &
#!/bin/bash
if [ "$#" -ne 3 ]; then
echo "usage: sh thread-analyze.sh <pid> <number-of-dumps> <interval>"
exit
fi
count=$2
for i in `seq 1 $count`;
do
jstack -l $1 > thread_dump_`date "+%F-%T"`.txt &
@bsenduran
bsenduran / Sierpinski.java
Created November 10, 2015 18:05
Sierpinski Triangle from Pascal Triangle
public class Sierpinski {
public static void main(String[] args) {
int no_of_row = 50;
int[][] tri = new int[no_of_row][no_of_row];
for (int i = 0; i < no_of_row; i++) {
for (int j = 0; j <= i; j++) {
if (j == 0 || j == i) {
tri[i][j] = 1;
}
mvn -Dmaven.surefire.debug test --> surefire test
mvn versions:set -DnewVersion=2.50.1-M1 --> manually set version
mvn versions:commit --> apply the changes
mvn versions:revert --> revert the changes
mvn -Dmaven.repo.local=$HOME/.my/other/repository clean install
mvn -Dtest=org.my.pkg.Hello#testGreet test
<%
var carbon = require('carbon');
var server = new carbon.server.Server();
var options = {system: true, domain: carbon.server.tenantDomain() , tenantId: carbon.server.tenantId()};
var dataStore = new carbon.registry.Registry(server, options);
var res;
var mycontent;
var path = "/_system/governance/sen/hello";
try {
res = dataStore.get(path);
$ echo "abc"
abc
$ echo "abc" | sed 's/b/z/'
azc
$ echo "abcb" | sed 's/b/z/'
azcb
$ echo "abcb" | sed 's/b/z/g'
*
When scp ing a file which has white spaces in its name have to escape twice,
because it's escaped locally and then on the remote end.
There are a couple of options you can do (in bash):
scp user@example.com:"'web/tmp/Master File 18 10 13.xls'" .
scp user@example.com:"web/tmp/Master\ File\ 18\ 10\ 13.xls" .
scp user@example.com:web/tmp/Master\\\ File\\\ 18\\\ 10\\\ 13.xls .
Get the md5sum for files in a directory
----------------------------------------
$ ls | xargs md5sum
If the file name contains white space, set the delimiter to new line (default delimiter is white space)
$ ls | xargs -d'\n' md5sum
Estimate the directories / files size
$ ls | xargs du -sh