Child Education
Education Posted on 14 Jan, 2021 19:21:43- Comments(0) https://www.guivi.one/?p=126
- Share
Adding folder to Dll in Visual studio Win32 apps
C/C++ Programming, Visual Studio Posted on 08 Jan, 2021 22:19:01- Go to project properties (Alt+F7)
- Under Debugging, look to the right
- There’s an Environment field.
- Add your relative path there (relative to vcproj folder) i.e. ..\some-framework\lib by appending
PATH=%PATH%;$(ProjectDir)\some-framework\lib
or prepending to the pathPATH=C:\some-framework\lib;%PATH%
- Hit F5 (debug) again and it should work.
- Comments(0) https://www.guivi.one/?p=124
- Share
Check last upgrade date of Debian base distros
Linux Posted on 05 Jan, 2021 22:25:02#!/bin/bash
#####################################################################
# BRIEF DESCRIPTION
# This script looks for the keyword 'upgrade' in the log files
# then it compares the date of all occurrences of the key word and
# and prints to shell the most recent date.
#####################################################################
# Check numer of availabe log dpkg files
mapfile -t files < <(ls /var/log/dpkg.log*)
# Debug print
# echo ${#files[@]}
# Iterate over all log files found
for ((i=0; i <${#files[@]}; i++))
do
# Debug print
# echo ${files[i]}
# grep a log file for upgrades store in an array.
mapfile -t lines < <(grep upgrade ${files[i]})
# Debug print
# echo ${#lines[@]}
# Store the number of lines on the last grep file
leng=${#lines[@]}
# loop through each line in thearray
for ((j=0; j<leng;j++)) do
# If length of $STRING is larger than one compare the new $DATE with the $STRING
# If the date is more resent store the new date in $STRING
if [ -n $STRING ]
then
DATE=${lines[j]:0:10}
# echo $DATE
if [[ "$STRING" < "$DATE" ]];
then
STRING="$DATE"
fi
else
# Initialize the $STRING
DATE=${lines[j]:0:10}
STRING="$DATE"
fi
done
done
# Output the most recent upgrade date of the system if any was found.
if [[ -n $STRING ]]
then
echo "$STRING"
fi
- Comments(0) https://www.guivi.one/?p=116
- Share
GUI Libraries For C++
C/C++ Programming Posted on 30 Dec, 2020 09:55:02Qt
Sciter
wxWidgets
GTK+
gtkmm
CEGUI
Dear ImGui
Noesis GUI
Juce
Fox Toolkit
MiniGUI
Nuklear
NanoGUI
LittlevGL
neoGFX
morda
U++
dlib
nana
GWork
libui
Agar
FLTK
IUP
Boost.UI
LCUI
GLUI
TGUI
ivtools
GuiLite
Ultralight
Chromium Embedded Framework
CopperSpice
FlatUI
SFGUI
Lgi
Verdigris
- Comments(0) https://www.guivi.one/?p=81
- Share
TCP Server in C++ for Linux and Windows
Uncategorised Posted on 14 Dec, 2020 08:54:26#if defined(__WIN32)
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0600
#endif
#include <winsock2,h>
#include <ws2tcpip.h>
#pragma comment (lib, "ws2_32.lib")
#else
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <unistd.h>
#include <errno.h>
#endif
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#if defined(_WIN32)
#define ISVALIDSOCKET(s) ((s) != INVALIV_SOCKET)
#define CLOSESOCKET(s) closesocket(s)
#define GETSOCKETERRNO()(WSAGetLastError())
#else
#define ISVALIDSOCKET(s) ((s) >= 0)
#define CLOSESOCKET(s) close(s)
#define GETSOCKETERRNO()(errno)
#define SOCKET int
#endif
#if defined(_WIN32)
#include <conio.h>
#endif
int main(int argc, char* argv[])
{
#if defined(_WIN32)
WSADATA d;
if (WSAStartup(MAKEWORD( 2, 2), &d)){
fprintf(stderr, "Failed to initialize.\n");
return 1;
}
#endif
/// Configure ocal address for server.
printf("Configuring local address...\n");
struct addrinfo hints;
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_PASSIVE;
struct addrinfo *bind_address;
getaddrinfo(0, "8080", &hints, &bind_address);
/// Create scket.
printf("Creting socket...\n");
SOCKET socket_listner;
socket_listner = socket(bind_address->ai_family, bind_address->ai_socktype, bind_address->ai_protocol);
if (!ISVALIDSOCKET(socket_listner)){
fprintf(stderr, "Coud not create socket (%d).\n", GETSOCKETERRNO());
return 1;
}
/// Bind socket
printf("Binding socket\n");
if (bind(socket_listner, bind_address->ai_addr, bind_address->ai_addrlen)){
fprintf(stderr, "Could not bind address (%d).\n", GETSOCKETERRNO());
return 1;
}
freeaddrinfo(bind_address);
/// Listen on the socket for connections
printf("Listening...\n");
if (listen(socket_listner, 10) < 0){
fprintf(stderr, "Listening failed: (%d).\n", GETSOCKETERRNO());
return 1;
}
fd_set master;
FD_ZERO(&master);
FD_SET(socket_listner, &master);
SOCKET max_socket = socket_listner;
printf("Waiting for connections...\n");
while(1){
fd_set reads;
reads = master;
if (select(max_socket, &reads, 0, 0, 0)){
fprintf( stderr, "Select() failed. (%d).\n", GETSOCKETERRNO());
return 1;
}
SOCKET i;
for(i = 1; i <= max_socket; ++i){
if (FD_ISSET(i, &reads)){
if (i == socket_listner){ /// Is it a new client?
struct sockaddr_storage client_address;
socklen_t client_len = sizeof(client_address);
SOCKET socket_client = accept( socket_listner, (struct sockaddr*) &client_address, &client_len);
if (!ISVALIDSOCKET(socket_client)){
fprintf(stderr, "Accept() failed with error: (%d).\n", GETSOCKETERRNO());
return 1;
}
FD_SET(socket_client, &master);
if (socket_client > max_socket)
max_socket = socket_client;
char address_buffer[100];
getnameinfo((struct sockaddr*)&client_address, client_len,
address_buffer, sizeof(address_buffer), 0, 0, NI_NUMERICHOST);
printf("New connection from %s \n", address_buffer);
}
else /// Is not e listener.
{
char read[1024];
int bytes_received = recv(i, read, 1024, 0);
if (bytes_received < 1){
FD_CLR( i, &master);
CLOSESOCKET(i);
continue;
}
/*** DO SOMETHING WITH THE BUFFER DATA ***/
}
} /// if FD_ISSET.
} /// for i to max socket.
}/// END while.
printf("Closing listening....\n");
CLOSESOCKET(socket_listner);
#if defined(_WIN32)
WSACleanup();
#endif
printf("Finished!");
return 0;
}
- Comments(0) https://www.guivi.one/?p=78
- Share
TCP Client in C++ for Linux and Windows.
Uncategorised Posted on 14 Dec, 2020 08:52:58#if defined(__WIN32)
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0600
#endif
#include <winsock2,h>
#include <ws2tcpip.h>
#pragma comment (lib, "ws2_32.lib")
#else
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <unistd.h>
#include <errno.h>
#endif
#include <stdio.h>
#include <string.h>
#if defined(_WIN32)
#define ISVALIDSOCKET(s) ((s) != INVALIV_SOCKET)
#define CLOSESOCKET(s) closesocket(s)
#define GETSOCKETERRNO()(WSAGetLastError())
#else
#define ISVALIDSOCKET(s) ((s) >= 0)
#define CLOSESOCKET(s) close(s)
#define GETSOCKETERRNO()(errno)
#define SOCKET int
#endif
#if defined(_WIN32)
#include <conio.h>
#endif
int main(int argc, char* argv[])
{
/// Initialize Windows socket
#if defined(_WIN32)
WSADATA d;
if (WSASartup(MAKEWORD(2, 2), &d)){
fprintf(stderr, "Failed to initialize.\n");
return 1;
}
#endif
/// Checn numberof arguments is corect or print the help string
if (argc != 3){
fprintf(stderr, "usage: tcp_client hostname port.\n");
}
/// Get socket information for houst address.
printf("Configure remote adress...\n");
struct addrinfo hints;
memset(&hints, 0, sizeof(hints));
hints.ai_socktype = SOCK_STREAM;
struct addrinfo *peer_address;
if (getaddrinfo(argv[1], argv[2], &hints, &peer_address)){
fprintf(stderr, "getaddrinfo() failed. (%d)\n", GETSOCKETERRNO());
return 1;
}
/// Print Socket information t screen
printf("Remote address is: ");
char address_buffer[100];
char service_buffer[100];
getnameinfo(peer_address->ai_addr, peer_address->ai_addrlen,
address_buffer, sizeof(address_buffer),
service_buffer, sizeof(service_buffer), NI_NUMERICHOST);
printf("%s %s\n", address_buffer, service_buffer);
/// Create socket.
printf("Creating socket...\n");
SOCKET socket_peer;
socket_peer =socket(peer_address->ai_family, peer_address->ai_socktype, peer_address->ai_protocol);
if (!ISVALIDSOCKET(socket_peer)){
fprintf(stderr, "socket() failed (%d).\n", GETSOCKETERRNO());
return 1;
}
/// Connect to peer.
printf("Connecting...\n");
if (connect(socket_peer, peer_address->ai_addr, peer_address->ai_addrlen)){
fprintf(stderr, "connect() failed (%d).\n", GETSOCKETERRNO());
return 1;
}
freeaddrinfo(peer_address); /// free the peer_address as we do not need any longer.
printf("Connected.\n");
printf("To send data enter text follow by enter.\n");
/// The for ever client loop
while(1){
fd_set reads;
FD_ZERO(&reads);
FD_SET( socket_peer, &reads);
#if !defined(_WIN32)
FD_SET(0, &reads);
#endif
struct timeval timeout;
timeout.tv_sec = 0;
timeout.tv_usec = 100000;
if (select(socket_peer+1, &reads, 0, 0, &timeout) < 0){
fprintf(stderr, "select() failed. (%d)\n", GETSOCKETERRNO());
return 1;
}
if (FD_ISSET(socket_peer, &reads)){
char read[4096];
int bytes_received = recv(socket_peer, read, 4096, 0);
if (bytes_received < 1){
printf("Connection closed by peer.\n");
break;
}
printf("Received (%d bytes): %s", bytes_received, read);
}
#if defined(_WIN32)
if (_kbhit()){
#else
if (FD_ISSET(0, &reads)){
#endif
char read[4096];
if (!fgets(read, 4096, stdin))break;
printf("Sending: %s", read);
int bytes_send = send(socket_peer, read, strlen(read), 0);
printf("Sent %d bytes.\n", bytes_send);
}
}/// while ends.
printf("Close socket.\n");
CLOSESOCKET(socket_peer);
#if defined(_WIN32)
WSACleanup();
#endif
printf("Finished.\n");
return 0;
}
- Comments(0) https://www.guivi.one/?p=75
- Share
Add overlay with alpha channel on an image using OpenCV
Uncategorised Posted on 10 Nov, 2020 15:43:11bool Overlay(cv::Mat& img, cv::Mat& ovr)
{
if (img.cols != ovr.cols || img.rows != ovr.rows)
return false;
#pragma omp parallel for // make sure to add #include <omp.h> and -fopenmp
for (int i = 0; i < img.rows; i++){
for (int j = 0; j < img.cols; j++){
cv::Vec4b bytes = ovr.at<cv::Vec4b>(i, j);
if (bytes[3] == 255){
img.at<cv::Vec3b>(i, j)[0] = ovr.at<cv::Vec4b>(i, j)[0];
img.at<cv::Vec3b>(i, j)[1] = ovr.at<cv::Vec4b>(i, j)[1];
img.at<cv::Vec3b>(i, j)[2] = ovr.at<cv::Vec4b>(i, j)[2];
}
}
}
return true;
}
- Comments(0) https://www.guivi.one/?p=68
- Share
Small program to stop the screen saver or screen blanking by moving cursor.
C/C++ Programming, Uncategorised Posted on 04 Sep, 2020 08:07:31#include <iostream>
#include <windows.h>
bool iskeypressed(unsigned timeout_ms = 0)
{
return WaitForSingleObject(
GetStdHandle(STD_INPUT_HANDLE),
timeout_ms
) == WAIT_OBJECT_0;
}
int main()
{
POINT cursor;
GetCursorPos(&cursor);
std::cout << "Press any key to stop the program!\n";
while (!iskeypressed(500)) {
cursor.x += 10;
SetCursorPos(cursor.x, cursor.y);
Sleep(1000);
cursor.x -= 10;
SetCursorPos(cursor.x, cursor.y);
Sleep(500);
}
std::cout << "Bye, Bye!\n";
return 0;
}
- Comments(0) https://www.guivi.one/?p=62
- Share