Heisenberg - Digital Alchemist, Software Architect, Automation Specialist and Mechanical Engineer.
Labels
Thursday, 30 July 2020
Saturday, 25 July 2020
Switch between text and graphical environments in Debian or RHEL
To switch between booting to a graphical environment and a console
Sunday, 19 July 2020
Rename Network on RedHat and Debian (possibly others)
How to rename Network on RHEL, Debian and possibly others.
Saturday, 18 July 2020
Register RHEL from command line
To register RHEL from the command line, do the following;
subscription-manager register --username user --password pass --auto-attach
This can be verified at https://access.redhat.com/management
RHEL Network Configuration
RedHat Network configuration
Run nmtui
Mount CD from command line in RedHat
How to mount a CD in RedHat
Linux shell command shortcuts
Handy forgotten shortcuts, for those lazy moments;
- UP Arrow - Previous command.
- TAB - Autocomplete.
- history - Displays command history.
- !! - Execute previous command (I don't like, prefer UP ARROW).
- !n - Executes the command n in the history.
- !$ - Recall argument used on the previous command (if there was one).
- ALT . - Filter through previous arguments (doesn't always work, especially on Mac).
- ^r (CTRL r) - search through history.
Sunday, 12 July 2020
Passing arrays to functions in C
The following is an example of how to pass a CHAR array to a function in C
In this example, we are simply counting the number of letters in a char array;
int getNumberOfLetters(char w[])
{
int l=0;
while (w[l]!='\0')
{
l++;
}
return l;
}
char word[100]; // initialise a char array with 100 cells
scanf("%s",word); // Get a word as input
int length = getNumberOfLetters(word); // call our function
Another Example, this time printing out the passed string;
#include <stdio.h>
void my_function(char * str)
{
printf("%s\n",str);
}
int main()
{
char name[]="Harold Hellman";
my_function(name);
return 0;
}
We can create a function that takes an array of chars as follows;
void myFunction (char* arg)
OR
void myFunction (char arg[])
and similarly, we can call either of the above with;
char myArray[10]="Harry";
myFunction(myArray);
Saturday, 11 July 2020
Bool data type in C
The following is an example of how to define and use a bool datatype in C
typedef enum { false, true } bool;
bool myVar = true;
if (myVar)
{
// do something
}
Or using an int (any integer is considered true, but not 0 ofc);
int notZero=1;
while(notZero)
{
scanf("%d",¬Zero);
}
Finally using stdbool.h (probably preferred);
#include <stdbool.h>
bool condition=true;
while(condition)
{
// do something
}
With regards to C++, I'm not so sure we even need to #include stdbool.h
Wednesday, 8 July 2020
Application Blocked By Java Security
Solution to the following error
This documentes the requirements for launching an app with all-permissions.
Friday, 3 July 2020
Format specifiers in C with a note on data types.
With the printf() function, we use the following;
%d - integer variable.%c - character.
%f - for float variable.
%s - for string variable.
%lf - for double.
%x - for hexadecimal.
\n - gives us a newline.
An example of use can be seen below;
#include <stdio.h>
int main()
{
int i = 5;
float f = 9.8;
printf("Here we have an integer: %d",i);
printf("\n");
printf("and here we have a float: %f",f);
return 0;
}