본문 바로가기

Useful command

Useful command

반응형

1. compile cpp file that includes opencv library path using g++

$ g++ test.cpp -o test `pkg-config --cflags --libs opencv`


2. build cpp file using bazel

~tensorflow) $ bazel build tensorflow/project/...


3. remove folder command (ubuntu)

$ sudo rm -r foldername


4. data type change python

a = np.zeros(10) # float

a_ = a.astype('int8') # int8


5. python sqrt function

import math

a = math.sqrt(4)

print(a)

-> 2


6. python exp function

import math

a = math.exp(4)


7. #define function

#define MIN(X,Y) (X < Y) > X : Y

#define MAX(X,Y) (X > Y) > X : Y


8. python numpy array size

a = np.empty(10,12)

b = a.shape()

print(b(0)) -> 10


9. binary2decimal - decimal2binary in python

a = bin(4)[2:] # string type
print(a) # 100 is printed
b = int(a, 2)
print(b) # 4 is printed


10. binary2decimal - decimal2binary with fixed length in python


a = bin(4)[2:].zfill(5) # {str} '00100'
b = int(a,2)
print(b) # 4


11. check file exist in python

os.path.isfile(path_to_file)



12. my D drive address (ubuntu)

/media/dooseop/64D4183AD41810C2/


13. image flip left right (python)


image_out = np.fliplr(image_in)


14. random number generator

np.random.rand(1) # from 0 to 1



15. number 2 string in python

b = 1.25

c = str(b)


16. get_variable setting for trainable or untrainable

tf.get_variable("a", a, trainable=False)

tf.get_variable("a", a, trainable=True)


17. kill process in ubuntu

$ ps -ef

$ kill -9 pid_number



18. copy files in python

from shutil import copyfile

copyfile(src, dst)


19. rename folder or directory (ubuntu)

mv /home/user/oldname /home/user/newname


20. check existance of file

for i in range(0, len(filenames)):
if (os.path.isfile(filenames[i]) == False):
print('following file does not exist : ' + filenames[i])















'Useful command' 카테고리의 다른 글

TMUX 명령어/Command 모음  (1) 2023.03.20
nvidia-docker  (0) 2018.04.03
nvidia docker commands  (0) 2017.08.16