Heisenberg - Digital Alchemist, Software Architect, Automation Specialist and Mechanical Engineer.
Labels
Thursday, 24 December 2020
Tuesday, 22 December 2020
Monday, 21 December 2020
Sunday, 20 December 2020
Problem building mesdb
I had trouble building mesdb using Netbeans but note that it did build correctly from the original source on the box, from the command line by running make.
Friday, 18 December 2020
/bin/bash^M: bad interpreter: No such file or directory
This is caused by windows carriage returns, the ^M is a carriage return character.
Windows uses CRLF whereas Linux only uses LF source
I had this issue when working between Linux and Windows using Sublime Text
and in this case, at the bottom of the editor, switched from Windows to Unix.
Prevent cron from sending emails
> /dev/null 2>&1
Tuesday, 15 December 2020
Monday, 14 December 2020
How to find out if your Linux system is 32bit or 64 bit
Run lscpu and look at the Architecture value.
Thursday, 10 December 2020
Restoring a system archived with fsarchiver.
This is a Work In Progress walk-through, restoring a system archived with fsarchiver
UPDATED: 1 July 2021
Monday, 7 December 2020
Sunday, 6 December 2020
ifconfig not in /bin ?
If ifconfig is not where I would expect it to be, that is /bin/ifconfig then don't be getting all defrosted, just do;
sudo ln -s /sbin/ifconfig /bin/ifconfig
Wednesday, 2 December 2020
Installing and Configuring Jupiter Notebooks on Debian
To install, do;
apt install jupyter-notebook
To launch in the /var/jupyterNotebooks directory, do;
cd /var/jupyterNotebooks && jupyter-notebook --ip=0.0.0.0
This will allow access to the server IP address on port 8888
The following will startup Jupyter in a sub dire 'NoteBooks' and can be closed by CTRL-C or by shutting down from the browser The QUIT button.
!#/bin/bash
echo "Starting Jupyter Notebooks..."
/usr/bin/jupyter-notebook --notebook-dir NoteBooks
sudo python3 -m pip install PyMysql[ed25519]
sudo python3 -m pip install PyMysql[rsa]
sudo python3 -m pip install pandas
Tuesday, 1 December 2020
Wednesday, 25 November 2020
How to reset admin password in Redmine
How to reset admin password in Redmine
Tuesday, 24 November 2020
Using samdump2 and John the Ripper to retrieve passwords
Using Samdump2 and John The Ripper
Wednesday, 18 November 2020
Linux Version
Find Linux distribution version release information.
RedHat
cat /etc/redhat-release
hostnamectl
Slackware
cat /etc/slackware-version
Debian
lsb_release -a
Sunday, 15 November 2020
CSS cheatsheet
The following shows the difference between html selectors, class and id.
Friday, 13 November 2020
SVN configuration
Subversion HowTo
A simple guide to setting up svn on Slackware...
Friday, 6 November 2020
MySQL CHANGE value based on CONDITION
MYSQL CHEAT-SHEET
Thursday, 5 November 2020
Cups printing
Some cups printing stuff
Tuesday, 3 November 2020
HTML Semantic Elements
HTML Semantic Elements
Sunday, 1 November 2020
mysql++.h and libmysql++-dev missing in Debain 10
mysql++
is missing in Debian 10 and despite several attempts to install it, I haven't yet been able to, so...
to install it under Debian Bullseye, do;
apt install libmysql++-dev
Bullseye can be found here: https://www.debian.org/devel/debian-installer/
See also here: https://packages.debian.org/search?keywords=libmysql%2B%2B-dev&searchon=names&suite=all§ion=all
Saturday, 24 October 2020
Setup VPN in Debian
In this case, using xfce and assuming Network manager is installed and configured, you need to then install the following;
sudo apt-get install network-manager-openconnect
You may need to install additional network-manager plug-ins and you can search those by;
sudo apt search 'network-manager-*'
then installing as;
sudo apt-get install network-manager-plugin-name
Thursday, 22 October 2020
To change Netbeans C++ binary output location
RIGHT-CLICK PROJECT
PROJECT PROPERTIES > LINKER > GENERAL > OUTPUT
To enable MySQL logging during runtime.
To enable MySQL logging...
Monday, 19 October 2020
Forgot MySQL root password
To recover a forgotten root password for MySQL
Saturday, 17 October 2020
Connect to remote mySQL server from the command line.
where username is the username of the remote mySQL server.
The following can also be used to test connection;
nc -z -w1 xxx.xxx.xxx.xxx 3306
MySQL Master Slave replication setup
MySQL replication setup
mySQL info
A quick way to get some mysql information is to run
mysql --help --verbose
How to setup a ramdisk in Linux
How to setup a ramdisk in Linux
Friday, 16 October 2020
Change temporary tables in mySQL to memory
To change the location of temporary tables in mySQL, we need to edit the tmpdir variable in my.cnf or which ever file contains the [mysqld] section.
Thursday, 15 October 2020
Show sleeping process in Linux
ps -e S
and of course
ps -e S | grep -i "processname"
Thursday, 8 October 2020
Check for FULLTEXT INDEX in mySQL database
When converting from MyISAM to InnoDB;
It is important if running an older version of MySQL to first check for FULLTEXT INDEX as full-text indexing is not supported by InnoDB in older databases.
To run a check, execute the following query;
SELECT TABLE_SCHEMA, TABLE_NAME
FROM information_schema.statistics
WHERE index_type LIKE 'FULLTEXT%'
Additionally, to convert multiple tables at once, do;
SELECT CONCAT('ALTER TABLE ',TABLE_NAME,' ENGINE=InnoDB;')
FROM INFORMATION_SCHEMA.TABLES
WHERE ENGINE = 'MyISAM' AND table_schema = 'mydb';
You may need to use the options to show Full text in the results to avoid lines being truncated, also watch out from some dodgy table names, like group.
Sunday, 4 October 2020
To update default browser in Debian Linux
To update the default web browser in Debian, do;
sudo update-alternatives --config x-www-browser
I noticed this had changed after I installed Chrome...
Saturday, 3 October 2020
Exchange Web Services in evolution Mail
The below is a screen shot of how I managed to connect to Exchange Web Services in the Evolution Mail client.
Thursday, 1 October 2020
MySQL copy table
MySQL copy table with and without data;
CREATE TABLE IF NOT EXISTS table_copy
SELECT * FROM table;
Saturday, 26 September 2020
SSH as root
If you really want to ssh at root;
edit /etc/ssh/sshd_config
Friday, 25 September 2020
Apache, php, mySQL and phpMyAdmin install on Debian
Thursday, 24 September 2020
Wednesday, 23 September 2020
Install ifconfig on Debian
apt-get install net-tools
MySQL views
The basic syntax to create a view is as follows;
Tuesday, 22 September 2020
Sunday, 20 September 2020
C, C++ Structure - The . and the -> notation
A brief reminder about dot and arrow operators.
Saturday, 19 September 2020
Xdebug install and configuration for use with PhpStrom
To enable and configure Xdebug for use with PhpStorm
This was carried out on my Mac, yet to be tested under Linux.
Friday, 18 September 2020
Linux links
Quick reminder on links in Linux
ln -s sourceFile linkFile (soft link or symbolic link)
ln sourceFile linkFile (hard link)
Wednesday, 16 September 2020
Tuesday, 15 September 2020
Saturday, 12 September 2020
Friday, 11 September 2020
DL - Process Control Applications
Process Control Applications, where they are and what they do.
Wednesday, 9 September 2020
DL - Gascut Stamping
A note on fec.mes_gascut_stamping.
Monday, 7 September 2020
DL - Query to check for missing gas cut stamping details
A reminder of why I used a combination of JOIN and INNER JOIN
This serves as a decent example of this.CLion CYGWIN warning - TODO
sudo
A quick reminder on adding a user to the sudo file.
We want to use visudo as root to edit the /etc/sudoers file.
we add our user as follows;
username ALL=(ALL) ALL
Saturday, 5 September 2020
Run a C program as a daemon in Linux
Mostly from here
The complete working skeleton code can be found here
When launched, this will live for 20 seconds and then terminate, logging startup and exit messages to /var/log/messages not syslog as expected on Slackware 14.2 but verified to write to /var/log/syslog on Debian 10.5
This can be pulled from: https://github.com/plisken1/daemon_template.git
Run a shell script (or an application) as a daemon in Linux
See my other blog post here
Writing to the message log in Linux with C
The following is an example of writing to the message log in Linux with C
from here, maybe here and also here if you are feeling brave.
#include <syslog.h>
#include <stdio.h>
int main()
{
setlogmask (LOG_UPTO (LOG_NOTICE));
openlog ("myprogramlog", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
for (int x=0;x<10;x++)
{
syslog (LOG_NOTICE, "Program started, count = %d",x);
syslog (LOG_INFO, "A tree falls in a forest");
}
closelog ();
return 0;
}
Linux Daemon Writing HOWTO
The following is a copy of the document from here
Linux Daemon Writing HOWTO
Devin Watson
v1.0, May 2004This document shows how to write a daemon in Linux using GCC. Knowledge of Linux and a familiarity with C are necessary to use this document. This HOWTO is Copyright by Devin Watson, under the terms of the BSD License.
Friday, 4 September 2020
Build C++ app in CLion for Linux (including a MySQL application)
How to build a C++ application, using MySQL and deploy on Linux.
In this case, we are using Debian 10 (also works on Slackware 14.2)
We are building an application (example can be found here, albeit slightly modified but importantly includes mysql.h). Also on GitHub here
MySQL install on Debian & solution to mysql-config not found.
To install mysql server on Debian
apt-get install mariadb-server
To start, run;
service mysql start
I also found mysql_config not to be found on Debian 10
likely due to the development stuff not being installed as I could also not find /usr/include/mysql
so, installing and resolving is as follows;
sudo apt-get install libmariadb-dev-compat
also worthwhile maybe;
alp-get install libmysqlcppconn-dev
apt-get install libmysql++
Wednesday, 2 September 2020
Tuesday, 1 September 2020
How to get public IP address in Linux
curl ifconfig.me
Monday, 31 August 2020
SQL JOINS
A brief reminder on the different types of SQL JOINS
Sunday, 30 August 2020
Install Java 8 on Debian
The following can be used to install Java 1.8 on Debian 10
From the following link;https://adoptopenjdk.net/installation.html?variant=openjdk8&jvmVariant=hotspot#x64_linux-jdk
1) wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | sudo apt-key add -
2) sudo add-apt-repository --yes https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/
If the above fails;
2) - (optional) sudo apt-get install -y software-properties-common
3) sudo apt-get install adoptopenjdk-8-hotspot
both java installations (assuming the default was installed) can be found in /usr/lib/jvm
Also, mind update netbeans.conf (probably in /usr/local/netb*/etc/) to point to java 8 as opposed to (11 for example), assuming we're using NB8.2
Failure to do the above may not prevent NB from launching but may well prevent you from Creating a New Project
Thursday, 27 August 2020
DL Process Control Applications - WIP
WIP
Wednesday, 26 August 2020
start/stop apache on Mac
sudo apachectl start
sudo apachectl stop
also note
brew services
PHP install on MacOS with note on Debian 10.5
For Mac with Home-brew
brew install phpAfter install with Home-brew, the location of both the default and new install can be seen below;
the latter is the original Mac install.
Also see here
For Debian;
sudo apt-get install php
then
sudo apt-get install php7.3-cgi
Note, replace the 7.3 with whatever php version was installed in the previous step.
This can be checked by
php -version
or
dpkg -s php
Sunday, 23 August 2020
C++ File structure in both Netbeans and CLion
Below shows the file structure of a simple C++ application in both Netbeans and CLion (on a Mac).
Friday, 21 August 2020
Thursday, 20 August 2020
DL Process Control applications - database connectivity and build process.
Note on the C++ binaries and the database connectivity.
Wednesday, 19 August 2020
C++ Pointers
Some stuff on Pointers (again).
MySQL and PostgreSQL comments
# this is a comment
-- this is a comment
Tuesday, 18 August 2020
Gascut stamping instructions
Sunday, 16 August 2020
Linux Display Managers
Debian/Ubuntu
/etc/X11/default-display-manager
RedHat/CentOS/Fedora
/etc/sysconfig/desktop
OpenSuSe
/etc/sysconfig/displaymanager
OR on systemd systems, do;
systemctl status display-manager
To switch Display Managers (Debian)
sudo dpkg-reconfigure <displayManagerName>
Actually with the above, we can use any installed DisplayManager and then from the prompt, simply choose the one we wish to switch to.
To restart the Display Manager (Debian), do;
sudo service <displayManager> restart
Example: sudo service gdm restart
See also here
and here for the good old RedHat logo, which is a must for any Applications Menu logo.
Saturday, 15 August 2020
Linux - UEFI or Legacy boot.
[ -d /sys/firmware/efi ] && echo UEFI || echo Legacy
Basically, if the refi file exists, we are in UEFI mode.
I'm not sure if the /sys folder is even there on < 2.6 kernels, it doesn't appear on my Slackware 8.1 (specifically for the SCS machine).
Friday, 14 August 2020
Thursday, 13 August 2020
Some apt-get stuff
To search for packages, do;
apt-cache search package
To update package list, do;
apt-get update
See also here
Wednesday, 12 August 2020
Kill a running query in mysql
Firstly, login to the MySQL database and run;
show processlist;
We can then kill the process bu the ID as follows;
kill id;
This can be verified bu again running show processlist; to ensure that the query has indeed been stopped.
Tuesday, 11 August 2020
OpenVMS Commands with unix equivalents
OpenVMS Commands with unix equivalents
Monday, 10 August 2020
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;
}
Sunday, 28 June 2020
Linux system services
Systemd systemctl commands
Friday, 26 June 2020
C++ Boost Libraries
Usage examples of the c++ boost libraries
C++ Header file template
C++ Header file template (including a guard)
#ifndef HEADERNAME_H_
#define HEADERNAME_H_
// CONTENT
#endif
The above basically ensures that only one instance of a definition is loaded or defined.
A basic C++ file with a header
What follows is a basic C++ file with a Header file
-- taken from https://www.learncpp.com/cpp-tutorial/header-files/ --
Wednesday, 24 June 2020
To connect with a MySQL database with C++ including boost
To connect to a MySQL database using C++
Sunday, 21 June 2020
Makefile basics
The basis of a simple Makefile
Saturday, 20 June 2020
Import C++ project into CLion from GitHub
Import C++ project into CLion from GitHub, where project has been created in another IDE.
See also https://blog.david14.com/2020/05/some-commonly-used-git-and-github-stuff.htmlThursday, 18 June 2020
Path bug with Debian as root.
Example;
adduser which is in /usr/sbin and as root adducer is not found.
Of course you can do /usr/sbin/adduser but which kind of looney would be wanting to do that.
The above can be seen when doing su and doing su - gets around it without modifying anything.
How to find the Hostname and Domain name on Mac or Linux
hostname
To find the domain name on a Mac, we can do as we would on a Linux box also;
cat /etc/resolv.conf
The following may also help on a Mac;
scutil --dns
It may also be worth looking under the Search Domains section;
System Preferences >> Network >> [Select NIC] >> Advanced >> DNS
On Linux, we can also do the following;
domainname - not always set for some reason, especially on my Slackware systems.
dnsdomainname - This shows on my Slackware systems.
nisdomainname - not always set for some reason, especially on my Slackware systems.
ypdomainname - not always set for some reason, especially on my Slackware systems.
Wednesday, 10 June 2020
Useful Eclipse Java autocomplete settings
Tuesday, 9 June 2020
Install and sign gdb - The GNU Debugger for Mac using Homebrew.
https://sourceware.org/gdb/wiki/BuildingOnDarwin ***IMPORTANT***
https://www.youtube.com/watch?v=JdcpDOf5Sog
Sunday, 7 June 2020
Double tapping the space bar inserts a period or full stop on Mac
SETTINGS > KEYBOARD > TEXT
Saturday, 6 June 2020
Stored Procedures in MySQL and PostgrSQL
DELIMITER $$ CREATE PROCEDURE getPercentage() BEGIN SELECT (COUNT(fault_resolved)/ count(id)*100)AS percent FROM log; END$$ DELIMITER ;
Note: The DELIMITER $$ exists to change the delimiter used, which is normally ;
This means we can have our statement inside and using a ; but will not be seen as the end of the statement.
This can be called by
CALL getPercentage();
Examples of basic C++ Header and class files.
Example of basic Header and class files
How to add Eclipse software repository to RedHat Core Ready Studio
https://access.redhat.com/documentation/en-us/red_hat_codeready_studio/12.12/html/installation_guide/assembly_installing-devstudio-in-eclipse
Thursday, 4 June 2020
How to boot into macOS Recovery and optionally erase the disk
The following can be used to reboot into recovery;
Command (⌘) + R
Reinstall the latest macOS that was installed on your Mac (recommended).
Option + ⌘ + R
Upgrade to the latest macOS that is compatible with your Mac.
Shift + Option + Command (⌘) + R
Reinstall the macOS that came with your Mac, or the closest version still available.
To optionally erase the disk;
Choose View > Show All Devices and then choose the top drive, the system drive and choose erase.
Note: Its worth copying the drive name as we can use it to name the newly formatted drive, if that's your thing.
Reference here and here for recover options.
Wednesday, 3 June 2020
SCS upgrade to support usb mouse and keyboard.
1- BACKGROUND.
1b- NOTES AND FILES.
2- PROCEDURE TO UPGRADE SCS USING CONFIGURED KERNEL (HEISENBERG).
3- STEPS TO SWITCH FROM PS2 TO USB.
4- STEPS TO SWITCH FROM USB TO PS2.
5- PROCEDURE TO REVERSE UPGRADE.
6- PROCEDURE TO CREATE HEISENBERG KERNEL.
7- LINKS.
Tuesday, 2 June 2020
Some quick comparisons between black and while box testing.
Black Box Testing:
- Requires No knowledge of the internal structure of program or application.
- Requires No programming knowledge required.
- The main goal is to test the behaviour of the software or application.
- Focused on the external or end-user perspective.
- Generally provide less detailed reports.
- Not time consuming.
White Box Testing:
- Requires knowledge of the internal structure of program.
- Requires programming knowledge.
- The main goal to test the internal operations of the system.
- Focused on code itself, its structure, conditions, paths and branches.
- Generally provide the most detailed reports.
- Extremely time consuming.
Sunday, 31 May 2020
Find files in Linux
Basic use of the find command in Linux
To find a file named my file.txt anywhere;
find / -name "myfile.txt"
To find a file named my file.txt in the current directory;
find . -name myfile.txt
To find all files in the current directory;
find . -name *.txt
To find all jpg files in /home/plisken;
find /home/plisken -name *.jpg
To search the contents of files in current directory;
find . -type f -exec grep "keyword" '{}' \; -print
Tuesday, 26 May 2020
Add to the shell PATH in MacOS
Open .bath_profile
(Don't forget [SHIFT + CMD + .] toggles displaying of hidden filed in finder.)
To ad a folder such as /Users/plisken/connectiq/bin we would add the following line to the end of .bash_profile;
export PATH="/Users/plisken/connectiq/bin:$PATH"
OR
export PATH=$PATH:/Users/plisken/connectiq/bin
and of course we can check the current $PATH by doing echo $PATH
Relaunching the terminal may be required...
Wednesday, 20 May 2020
Some commonly used git and GitHub stuff, including links to guides etc.
https://netbeans.org/kb/docs/ide/git.html
https://code.visualstudio.com/docs/editor/versioncontrol
https://www.jetbrains.com/help/pycharm/version-control-integration.html
https://helpx.adobe.com/uk/dreamweaver/using/git-support.html
https://desktop.github.com
Below are some common git commands;
Saturday, 16 May 2020
PHP variables and scope
A variable declared outside of a function will not be available inside of a function, unless be declare it inside the function with the global command.
Wednesday, 13 May 2020
Sync data from Fitbit to the Apple Health app.
A step by step of this project, how it came about, progress, problems and solutions along the way can be found here
Tuesday, 12 May 2020
Monday, 11 May 2020
Quickly add dir to OSX
ls is located in /bin
By default we can't add or modify things there (topic for another time), but we can modify things in /usr/local/bin so where better a place to add a dir file/command...
goto /usr/local/bin
and do sudo ln -s /bin/ls dir
dir now exists in /usr/local/bin as a symbolic link to /bin/ls
Sunday, 10 May 2020
Alternative methods of joining results from two tables
If we are wanting to pull information from two different tables that are linked in some way, the conventional way of doing this is as follows:
SELECT table1.item, table2.item
FROM table1 JOIN table2 ON table1.item = table2.item;
However an alternative is to use the following;
SELECT table1.item, table2.item
FROM table1, table2
WHERE table1.item = table2.item;
Saturday, 9 May 2020
iPad keyboard click, camera should and lock screen sound not working
It's important to note that while in this state, in settings, the keyboard click and lock screen sound options will still show as enabled.
Thursday, 30 April 2020
Change text in an HTML document and passing php variable to javascript.
If we were using php to echo the html then unfortunately, once the echo is done, the html is created so to speak and it's no longer possible to change or update it.
But, we can use javascript, as per the example below, where the 1st line could be high up on the page and would display old text and once the script below runs, this old text would be changed to new text.
This can of course be done by embedding php echo statements to include variables, which is also a way of passing a variable from php to javascript.
<p align="left" id="id1">old text</p>
<script>
document.getElementById("id1").innerHTML = "new text";
</script>
OR
<script>
document.getElementById("dt").innerHTML = "<?php echo $someVar ?>";
</script>
Tuesday, 28 April 2020
basic web page redirect or reload
The following is a basic web page redirect;
<html>
<head>
<meta HTTP-EQUIV="refresh" CONTENT="3; URL=index.html">
</head>
</html>
function reload_page()
{
window.location = window.location.href;
}
</script>
Sign Magnitude, Two's compliment binary representations
As an additional note, two's compliment involves inverting and adding 1.
So if we look at the table below for 0100 which is 4, the two's compliment representation of -4 would be 1100
How do we get there, well we first invert from 0100 to 1011 and then add 1 to give 1100
To go the other way;
If we have -3 which is 1101 we invert to give 0010 and add 1 to give 0011 which is of course 3
Saturday, 18 April 2020
Add a Right Click action to any Application
Thursday, 16 April 2020
Cyclomatic Complexity
Cyclomatic Complexity
Cyclomatic Complexity is the number of independent paths through code and there are many websites that do a better job of explaining it than I can, but...
Wednesday, 8 April 2020
To test a fail2ban filter using fail2ban-regex
fail2ban-regex <logfile> <filter>
Example:
fail2ban /var/log/apache/error_log /etc/fail2ban/filter.d/apache-noscripts.conf
Tuesday, 7 April 2020
To block, unblock or check IP addresses with iptables in Linux
The format to block and IP address is as follows:
iptables -A INPUT -s BAN-IP-ADDRESS -j DROP
iptables -A INPUT -s BAN-IP-ADDRESS/MASK -j DROP
To block an IP address, use the following;
iptables -A INPUT -s 192.168.254.100 -j DROP
To view all blocked IP addresses, do;
iptables -L INPUT -v -n
OR
iptables -L INPUT -v -n | less
OR (especially if blocked with fail2ban) **
iptables -L -n --line
To check for a specific IP address, do;
iptables -L INPUT -v -n | grep "192.168.254.100"
To unblock an IP address, do;
iptables -D INPUT -s 192.168.254.100 -j DROP
Alternatively to unblock an entry blocked with fail2ban (see ** above) do;
iptables -L -n --line
then find the IP address you wish to unban.
then do
iptables -D ruleName n
where ruleName is the rule name associated with the banned IP
and n is the number associated with the banned IP
ref: https://www.cyberciti.biz/faq/linux-howto-check-ip-blocked-against-iptables/
Set and retrieve cookies with php
setcookie(name, value, expire, path, domain, security);
I only use the name, value and expire, where expire is in seconds, so;
time() + 24*60*60 is 1 day.
Tuesday, 24 March 2020
Server Settings for Dreamweaver
In my example, my web server is on my local network, accessible from the internet, so to prevent setting up firewall rules and port forwarding to allow external access to FTP etc, I would rather connect using the local private IP address.
However, previously when attempting this, the default directory was the home directory for the user used which is no good.
The screen shot below, shows how to properly accomplish this;
Saturday, 7 March 2020
MySQL triggers
The first one was to evaluate a condition on inserting a new record, while the second one was to evaluate the same condition but this time on update.
Sunday, 1 March 2020
Backup and restore MySQL database
To backup a MySQL database
See this link here
shell> mysqldump [arguments] > file_name
shell> mysqldump --all-databases > dump.sql
shell> mysqldump --triggers --routines --all-databases > dump.sql
shell> mysqldump --databases db1 db2 db3 > dump.sql
shell> mysqldump --databases dbname > dump.sql
OR omit the --databases
shell> mysqldump test > dump.sql
To dump only specific tables from a database use;
shell> mysqldump dbmane table1 table3 table7 > dump.sql
To dump only the structure from a database use;
shell> mysqldump --no-data dbmane > dump.sql
shell> mysqldump --d dbmane > dump.sql
Note: -d includes the triggers.
To dump only the routines from a all databases use;
mysqldump -u username -p -n -t -d -R --all-databases > routines.sql
To add the host 192.168.254.198 and the user root, do;
shell> mysqldump --host=192.168.254.198 --port=3307 -u root -p dbmane > dump.sql
See also my post here for details on how to simply copy the table structure.
mysqldump --host=[...] -udev -p --no-data --triggers --routines my_db > my_db_structure.sql
To restore a MySQL database
To login to mysql, do;
mysql -u username -p