Sunday, February 4, 2024

Checking wifi signal stregnth in ubuntu

 Use command: watch -n1 iwconfig

Then check for "Link Quality"


Example Output:

br-162f0698aa15  no wireless extensions.

enp0s31f6  no wireless extensions.

lo        no wireless extensions.

veth7f181fd  no wireless extensions.

enx482ae3bc4b7c  no wireless extensions.

docker0   no wireless extensions.

wlp61s0   IEEE 802.11  ESSID:"******"
          Mode:Managed  Frequency:5.28 GHz  Access Point: **:**:**:**:**:**
          Bit Rate=866.7 Mb/s   Tx-Power=22 dBm
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Power Management:on
          Link Quality=51/70  Signal level=-59 dBm
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:126   Missed beacon

Sunday, January 28, 2024

Ubuntu: Convert multiple images to video

Use command: ffmpeg

 example:  

ffmpeg -framerate 10 -pattern_type glob -i '*.JPG'  output4.mp4


where  '*.JPG'  means it will take all files iwth extension JPG from current directory 

"-framerate 10" mean 10 images will be shown per second


 

Monday, February 27, 2023

SpelParseException: EL1041E for maxAttemptsExpression

 SpelParseException: EL1041E  for maxAttemptsExpression  means expression is missing { or }


eg: ${max.retry.attempts

Saturday, April 2, 2022

Eclipse maven update problem whike moving from older java to java17

 Errors encountered while doing maven update:


Could not get the value for parameter encoding for plugin execution default-resources

cannot resolve plugin org/apache/maven plugins maven-resources-plugin:3.1 0 


1. Close eclipse

2. Got to ~/.m2

3.  delete m2/repository/org/apache/maven

4. open eclipse 

5. update project again

(if  do not work delete whole .m2/repository)

Wednesday, March 9, 2022

Shopware 5 newsletter enable double opt fintionality

 https://docs.shopware.com/de/shopware-5-de/marketing-und-einkaufswelten/newsletter?utm_source=google&utm_medium=cpc&utm_campaign=nb-o04_nrt_dach_de_awareness_performance-max_lead-contact&utm_content=maxperformance&gclid=CjwKCAiAvaGRBhBlEiwAiY-yMGW-Pfxlq1TIHgN84Yrz6YgbG8-uAteR2Ex0A4Nfs0sSXWcrCst-ZRoCv5wQAvD_BwE 

Sunday, February 13, 2022

 Java 17 : Unrecognized VM option 'MaxPermSize=512m'

adjust your environment variable MAVEN_OPTS and remove  MaxPermSize 

Monday, April 20, 2020

Could not bind properties to 'JacksonProperties'

Spring boot 2 run time error:


Error creating bean with name 'spring.jackson-org.springframework.boot.autoconfigure.jackson.JacksonProperties': Could not bind properties to 'JacksonProperties' : prefix=spring.jackson, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'spring.jackson.deserialization' to java.util.Map<com.fasterxml.jackson.databind.DeserializationFeature, java.lang.Boolean>


Solution:

 At application property set
 spring.jackson.deserialization.fail-on-unknown-properties: true

Friday, February 7, 2020

run script at startup of ubuntu

Run script at startup (when you login). Following example add a small memory check script at the startup


  1.  cd  /usr/share/applications
  2. sudo gedit  memcheck.desktop
  3. [Desktop Entry]
    Name=memcheck
    Comment=memcheck  Tool
    Exec=/home/***/projects/mem_alert/memcheck.sh
    Terminal=true
    Type=Application
    Icon=someicon copied from existing .desktop files in same folder
  4. Open tweaks
  5. install genome tweak tool
  6. Click "startup applications"
  7. Click add, then select "memcheck" application from the list. If it do not appear then you have done some thing wrong.
  8. Now logout and login. The mem check script should run after user login


My memcheck.sh looks like:


#!/bin/bash
#Minimum available memory limit, MB
THRESHOLD=2000
#Check time interval, sec
INTERVAL=30
while :
do
    free=$(free -m|awk '/^Mem:/{print $4}')
    buffers=$(free -m|awk '/^Mem:/{print $6}')
    cached=$(free -m|awk '/^Mem:/{print $6}')
    available=$(free -m|awk '/^Mem:/{print $7}')
    message="Free $free""MB"", buffers $buffers""MB"", cached $cached""MB"", available $available""MB"""
    if [ $available -lt $THRESHOLD ]
        then
        notify-send "Memory is running out!" "$message"
    fi
    echo $message
    sleep $INTERVAL
done

Monday, May 20, 2019

Install openjdk 11 at ubuntu


  •  Download jdk11 from https://download.java.net/openjdk/jdk11/ri/openjdk-11+28_linux-x64_bin.tar.gz
  •  Extract to /usr/lib/jvm 
sudo tar xvf openjdk-11+28_linux-x64_bin.tar.gz --directory /usr/lib/jvm/
  • sudo update-alternatives --config java
  Selection    Path                                     Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/jdk-11/bin/java              3         auto mode
  1            /usr/lib/jvm/java-7-oracle/jre/bin/java   1         manual mode
* 2            /usr/lib/jvm/java-8-oracle/jre/bin/java   2         manual mode

  • Install java11 as 3 option
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-11/bin/java 3
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk-11/bin/javac 3
  • Set java11 as current java version 
sudo update-alternatives --config java and select 3
sudo update-alternatives --config javac and select 3

Wednesday, November 2, 2016

Kernel panic after ubuntu update

I recently did ubuntu update and then after reboot i got following screen related to kernel panic. The problem for me was that my /boot ran out of space.



Solution:

Restart your machine and go to grub loader
Select "Advanced options for Ubuntu"

Then you will be listed with list of kernels, select one of them and press enter [at least one of them should allow to you boot and login  into your ubuntu machine]

Then go to terminal and run:
 aptitude search ~ilinux-image
this should list all the kernel images u have in /boot

run
uname -a

to get ur current running kernel

run
sudo apt-get <image name>
for example: sudo apt-get autoremove linux-image-4.4.0-45-generic
to remove the image that you dont need

Saturday, June 11, 2016

Ambigious mapping

Scenario:  

Need to add a spring mvc project as dependency (scope test) to other spring mvc project.

Problem: 

Ambiguous mapping. Cannot map 'xyzController' method 

Reason: 

Both projects had web controller with request mapping annotation only at method level. As the rest of it when spring tries to map / , we have ambibious maping scenario where both the controllers quality for the mapping and this result in the exception.

Solution: 

Add Requestmapping annotation at the both controller (or one of them) so that spring can map urls distinctly


Monday, April 27, 2015

Generic enum converter

  public static Enum<?> toEnum(final Class<? extends Enum> classType, final Enum<?> enumObj) {  
     if (enumObj == null) {  
       return null;  
     } else {  
       return enumObj.valueOf(classType, enumObj + "");  
     }  
   }  

Usage:

  Test1 returnedEnum = (Test1) toEnum(Test1.class, Test2.HELLO_ENUM);  

Tuesday, February 3, 2015

Documenting Spring annotated rest interface via reflection  

1:   for (Method method : YourClass.class.getMethods()) {  
2:        // url  
3:        if (method.isAnnotationPresent(RequestMapping.class)) {  
4:          RequestMapping parms = method.getAnnotation(RequestMapping.class);  
5:          String[] val = parms.value();  
6:          RequestMethod[] methodType = parms.method();  
7:          for (int i = 0; i < val.length; i++) {  
8:            System.out.println(val[i] + "     METHOD TYPE:" + methodType[i]);  
9:          }  
10:          //parameter  
11:          Class<?>[] paramsTypes = method.getParameterTypes();  
12:          Annotation[][] annot = method.getParameterAnnotations();  
13:          for (int i = 0; i < annot.length; i++) {  
14:            if (annot[i].length > 0 && annot[i][0] instanceof RequestParam) {  
15:              RequestParam new_name = (RequestParam) annot[i][0];  
16:              System.out.println("Request: " + new_name.value() + " = " + paramsTypes[i]);  
17:            }  
18:          }  
19:          //return type  
20:          if (method.getReturnType().getCanonicalName().equals(List.class.getCanonicalName())) {  
21:            Type listType = method.getGenericReturnType();  
22:            if (listType instanceof ParameterizedType) {  
23:              Type elementType = ((ParameterizedType) listType).getActualTypeArguments()[0];  
24:              System.out.println("Response: [" + elementType + "]");  
25:            }  
26:          } else {  
27:            System.out.println("Response: " + method.getReturnType().getCanonicalName());  
28:          }  
29:        }  

Tuesday, September 9, 2014

Problem in getting post parameter in Spring MVC via REST request

@RequestMapping(value = "/api/login", method = RequestMethod.POST)
    public WelcomeMessage getHelloWorld(@RequestParam(value = "username") final String username, @RequestParam(value = "password") final String password) {
            // do some thing
    }


I was having the problem to get post parameter via REST request.  Adding the header "Content-Type:application/x-www-form-urlencoded" fixed the issue

Saturday, July 26, 2014

A* Algorithm optimality proof

This video from me describes the A* algorithm optimality proof. You can also see the slides from the link provided in description.

Thursday, March 27, 2014

java.lang.IllegalArgumentException: badly formated directory string

it is based on invalid format, try to give correct name structure for instance:

new X500Name("C=DE,O=Organiztion");

Sunday, February 23, 2014

Design patterns

Design pattern are solutions to a class of problem which is proven to be good. It's like following the big guys. The attached project contains easy to learn example for Factory, observer listener and strategy design patterns. This project will be updated with further patterns. Each if the downloadable  project is an eclipse project , you can simply import it in eclipse  if you wish.
Download all Project
Description of project via sample problems:

PROBLEM 1:
 Say you want to create people in a computer game. People can be of type enemy army, friendly army or civilians (Also further more addition in future should be also possible).  In this kind of problem you can  use Factory pattern to create these game people.

PROBLEM 2:
Say in same game scenario you want to create Aeroplanes with different capability. Say 5 aeroplanes with military capability and 1 civilian  (In future you should be also able to add more capabilities like speeds, payload types). In this kind of problem you can use Strategy pattern. You can create different capabilities and inject them in aeroplane.

PROBLEM 3:
Now say you have a game window. There are different buttons. You want to do different action in your Window class based to the location of the button clicked (Say button is developed by some other developer in his own way). In this problem you can use observer listener pattern.Window can be listener of button click event. Developer of the button should define a interface to add listeners.