linux "ps" command example


"ps" command example
: If i use "ps" command, I can check working process.

$ ps [-option]
-a : enumerates all processes (total user)
-u : each process of user and usage time
-x: enumerates all processes without a controlling terminal
-l : enumerates the detailed information
-e: Display all processes statuses

Example)
 ps -aux


PID : process id
%CPU : cpu usage
%MEM : memory usage
VSZ : virtual memory usage
RSS : real memory usage
Stat : process status ( S : sleep, I : idle, T : stop, …)

Linux : search content (in file) / and search file or folder example


search content
$ grep -r "content" ./*
  ex) grep -r "LD_PRELOAD" ./*

search file or folder
$ find ./* -name "file or folder"
  ex) find ./* -name "library" or find ./* -name "*lib*"

android pdk make error : Android can only be built by versions 3.81 and 3.82.


This error is caused by an incorrect "make" version.

root@kiwon-VirtualBox:~/pdk/android-4.4.2_r1# make
build/core/main.mk:45: ********************************************************************************
build/core/main.mk:46: *  You are using version 4.1 of make.
build/core/main.mk:47: *  Android can only be built by versions 3.81 and 3.82.
build/core/main.mk:48: *  see https://source.android.com/source/download.html
build/core/main.mk:49: ********************************************************************************
build/core/main.mk:50: *** stopping.  Stop.

This error is caused by an incorrect "make" version.
So, Please add "make" version.

$make -v
GNU Make 4.1
.…

Please add "make" version 4.1 .
$ vi ./build/core/main.mk

 40 # Check for broken versions of make.


 41 # (Allow any version under Cygwin since we don't actually build the platform there.)

 42 ifeq (,$(findstring CYGWIN,$(shell uname -sm)))

 43 ifeq (0,$(shell expr $$(echo $(MAKE_VERSION) | sed "s/[^0-9\.].*//") = 3.81))

 44 ifeq (0,$(shell expr $$(echo $(MAKE_VERSION) | sed "s/[^0-9\.].*//") = 3.82))

 45 ifeq (0,$(shell expr $$(echo $(MAKE_VERSION) | sed "s/[^0-9\.].*//") = 4.1))

 46 $(warning ********************************************************************************)

 47 $(warning *  You are using version $(MAKE_VERSION) of make.)

 48 $(warning *  Android can only be built by versions 3.81 and 3.82.)

 49 $(warning *  see https://source.android.com/source/download.html)

 50 $(warning ********************************************************************************)

 51 $(error stopping)

 52 endif

 53 endif

 54 endif

 55 endif



Okay .

QT set background image example(QLable_setstylesheet, QPixmap)

QT set background image example(QLable_setstylesheet, QPixmap)
I had a problem about applying image.

This is problem :
My app is working on an embedded system. I have migrated the app from Qt 5.6 to Qt 5.9.3 and it became very slow. I have checked the output of the top command and realized that my app is causing a CPU utilization of 100%.
So, I have check my app and I have found a problem in this part of the code:
MainWidget::MainWidget(QWidget *parent)
    : QWidget(parent)
{
...

    QPixmap bg(BACK_IMG_PATH);
    bg.fill(Qt::transparent);
    QPalette p(palette());
    p.setBrush(QPalette::Background, bg);
    setAutoFillBackground(true);
    setPalette(p);
...
}
The problem is, that if I add the code for the background, my app becomes extremely slow. However, if I remove this code, my app is working as expected. This cannot be a solution though, cause I need the background.
This problem did not exist before the migration.
I have tried to solve this by reimplementing the paintEvent and using QPainter like this:
void MainWidget::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);
    painter.drawImage(QRectF(this->x(), this->y(), this->width(), this->height()), QImage("img/bg_1280_720.png"));
}
This result is slightly faster, but still not satisfactory (the cpu utilization is 50%).


How to solve this problem?

before:
#define BACK_IMG_PATH           "/img/bg_1280_720.png"
    QPixmap bg(BACK_IMG_PATH);
    bg.fill(Qt::transparent);
    QPalette p(palette());
    p.setBrush(QPalette::Background, bg);
    setAutoFillBackground(true);
    setPalette(p);


after:

#define BACK_IMG_PATH           "background-image:url(/img/bg_1280_720.png)"
    QLabel *labelBg = new QLabel(this);
    labelBg->setStyleSheet(BACK_IMG_PATH);
    labelBg->setGeometry(this->geometry());


Java Lotto / get random number example

This code was made in five minutes, so there are many weak point.

this code save that the number from 1 to 45 has been count N times.
finally, i will get 6 numbers.

import java.util.Random;

public class lottonamatja {
   public static void main(String[] args) {
      Random ranNum = new Random();    // random variable
      long[] cloneNum = new long[45]; 
      long[] num = new long[45];
      long[] lottoNum = new long[6];    // get real number(I wanted)
      long count = 1;
      long N = 100000000;
   
      for (long i = 0; i< N ; i++) {
         int tempRanNum = ranNum.nextInt(45)+1;    // random number of 1~45
         num[tempRanNum-1] += count;    // count of each number about N times
      }

//copy number
      cloneNum = num.clone();

// sorting count
      for (int i = 0; i < 45; i++) {
         for (int j = i + 1; j < 45; j++) {
            if (num[i] > num[j]) {
               long tmp = 0;
               tmp = num[i];
               num[i] = num[j];
               num[j] = tmp;
            }
         }
      }
   
// compare sorting number to original number ( this is real number(1~45), num[i] or cloneNum[j] is counting number)
      for (int i = 0 ; i < 6; i++) {
         for (int j = 0 ; j < 45; j++) {
            if (num[i] == cloneNum[j])
               lottoNum[i] = j+1;    // save result number 
         }
      }
   
// sorting about 6 number
      for (int i = 0; i < 6; i++) {
         for (int j = i + 1; j < 6; j++) {
            if (lottoNum[i] > lottoNum[j]) {
               long tmp = 0;
               tmp = lottoNum[i];
               lottoNum[i] = lottoNum[j];
               lottoNum[j] = tmp;
            }
         }
         System.out.print(lottoNum[i] + " ");    //i wanted to real number
      }
   }
}

RSS(Resident Set Size), VSS(Virtual Set Size)


RSS(Resident Set Size): Number of physical pages associated with the process(the size is calculated with duplicated shared memoy size, so, is calculated lager than the actual size)

VSS(Virtual Set Size): Size of virtual memory associated with the process


But, the amount of memory about the process is unknown exactly.


Why is the CPU utilization(%) for each process greater than the total CPU Time about "top"?


Why is the CPU utilization(%) for each process greater than the total CPU Time about "top"?

Two modes of "top" : solaris(irix mode off), irix(irix mode on)

Solaris mode: total cpu utilization(%) / total cpu count(number of core)
Irix mode: each cpu utilization(%) * total cpu count(number of core)

알뜰폰 삼성페이 교통카드 '한도 초과' 오류(등록 불가 오류) 해결방법

sk7mobile 알뜰폰 삼성페이 교통카드 등록 시, 한도 초과 문제 해결방법 skt usim 해킹 사건으로 인해 sk7mobile 알뜰폰을 사용하는 저도 usim을 바꾸고 나니 삼성페이 교통카드가 등록이 안되더라구요...  삼성페이 교통카드 기능 은...