Skip to content

Instantly share code, notes, and snippets.

View spot62's full-sized avatar

SLPotapenko spot62

  • Ryazan
View GitHub Profile
#!/bin/bash
ESB_REQUESTS_LOG_PATH="/opt/esb/Runtime_ESBSE/container/log/*.request.log"
#HOSTS=(`cat ./requests/*.request.log | awk '{print $1}' | sort -n | uniq -c`)
#HOSTS=(`cat ./requests/2019_12_04.request.log | awk '{print $1}' | sort -n | uniq -c`)
# cat ${ESB_REQUESTS_LOG_PATH} | awk '$4 >= "25/May/2020:00:00:00"' | awk '{print $1}' | sort -n | uniq -c
HOSTS=(`cat ${ESB_REQUESTS_LOG_PATH} | awk '$4 >= "1/May/2023:00:00:00"' | awk '{print $1}' | sort -n | uniq -c`)
@spot62
spot62 / java_profiler.sh
Created July 31, 2019 08:45
Java threads profiler
#!/bin/bash
# https://habr.com/ru/post/153135/
#
PID=$(top -n1 | grep -m1 java | perl -pe 's/\e\[?.*?[\@-~] ?//g' | cut -f1 -d' ')
NID=$(printf '%x' $(top -n1 -H | grep -m1 java | perl -pe 's/\e\[?.*?[\@-~] ?//g' | cut -f1 -d' '))
jstack $PID | grep -A500 $NID | grep -m1 '^$' -B 500
@spot62
spot62 / byte_utils.cpp
Created April 23, 2019 08:40
Byte clamp
static unsigned char byte_clamp(int c)
{
unsigned char rc = { static_cast<unsigned char>(c), 255, 0 };
unsigned uc = static_cast<unsigned>(c);
// +1 if greater 255
// and +1 if bit of sign 1
return rc[!!(uc & ~0xff) + !!(uc & ~(~0u >> 1))];
}
@spot62
spot62 / gist:42e936ec418db6a48c138197ea16fa97
Last active September 12, 2018 15:03
inline http check as ping
ok=0; err=0; for ((;;)) do curl ${yourip} > /dev/null 2>&1 && { ((ok++)); err=0; echo -en "ok $ok\r"; } || { r=$?; ok=0; ((err++)); echo "error:$r $err"; } ; sleep 1; done
@spot62
spot62 / readbychunks.cpp
Last active June 8, 2018 21:21
Read a file by chunks
#include <iostream>
#include <fstream>
#include <vector>
char* filename = "test.bin";
size_t chunk_sz = (32*1024);
int main(void)
{
std::ifstream fin(filename, std::ifstream::ate | std::ifstream::binary);
@spot62
spot62 / gist:83a78e6cf348329254f12727e67cc390
Created January 21, 2018 19:12
Fedora openssl issue downgrade
dnf downgrade gcc --releasever=25 # mustbe not needed
dnf install compat-openssl10-devel --allowerasing
go get -u github.com/nsf/gocode
go get -u golang.org/x/tools/cmd/guru
go get -u github.com/rogpeppe/godef
and GOROOT
@spot62
spot62 / eclipse-install.sh
Last active March 2, 2017 14:14
Install Eclipse from repo
#!/bin/bash
sudo dnf install -y eclipse-{platform,pydev,cdt-sdk,egit,webtools-javaee}
sudo dnf install -y eclipse-dltk-{ruby,mylyn,rse,tests,sdk,tcl,itcl,xotcl}
sudo dnf install -y eclipse-color-theme
@spot62
spot62 / LambdaApp.java
Created February 15, 2017 18:26
Java8 Lambda
public static void main(String[] args) {
Operationable operation;
operation = (x,y)->x+y;
int result = operation.calculate(10, 20);
}
public class LambdaApp {
public static void main(String[] args) {
Operationable op = new Operationable(){
@spot62
spot62 / solution.java
Created February 15, 2017 16:15
Java MD5
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;
public class Solution {