Labels

Android (1) bash (2) boost (2) C (34) C++ (2) cheatsheet (2) CLion (6) css (3) Debian (33) DL (17) Docker (2) Dreamweaver (2) Eclipse (3) fail2ban (4) git (5) GitHub (4) Hacking (3) html (8) http (1) iOS (1) iPad (1) IRC (1) Java (31) javascript (3) Linux (167) Mac (19) Machine Learning (1) mySQL (48) Netbeans (4) Networking (1) Nexus (1) OpenVMS (6) Oracle (1) Pandas (3) php (16) Postgresql (8) Python (9) raid (1) RedHat (14) Samba (2) Slackware (47) SQL (14) svn (1) tar (1) ThinkPad (1) Virtualbox (3) Visual Basic (1) Visual Studio (1) Windows (2)

Friday, 9 December 2022

How to remove a char from a C char array by index.

I use the following to remove a char from a C char array by index.

In this instance, I search for the first char and if it's a 0 then remove it.

Friday, 4 November 2022

JpGraph Error 25128

The function imageantialias() is not available in your PHP installation. Use the GD version that comes with PHP and not the standalone version.

Thursday, 29 September 2022

Updating a bash script from a repository

The following are two methods of updating a bash script from a repository

Friday, 23 September 2022

ISO keyboard on Mac

Had several issues through the years with UK keyboards not being recognised in MAC OS.

nmap

nmap -PN -n -v -p 80,3306 192.168.254.50

Wednesday, 3 August 2022

Installing VirtualBox Guest Additions

PHP - writing to browser console

To write debugging information to the browser console, add a helper function as follows;

function debug_to_console($data)
{
$output = $data;
if (is_array($output))
$output = implode(',', $output);

echo "<script>console.log('Debug Objects: " . $output . "' );</script>";
}

then simply do;

debug_to_console("something");

[source]


Sunday, 24 July 2022

Change java version on Mac

To see which version of java is installed, do;

java -version

with an example of the output being;

java version "17.0.4" 2022-07-19 LTS

Java(TM) SE Runtime Environment (build 17.0.4+11-LTS-179)

Java HotSpot(TM) 64-Bit Server VM (build 17.0.4+11-LTS-179, mixed mode, sharing)

If we want to change the default version, first do;

/usr/libexec/java_home -V

an example of the output is;

Matching Java Virtual Machines (2):

    17.0.4 (x86_64) "Oracle Corporation" - "Java SE 17.0.4" /Library/Java/JavaVirtualMachines/jdk-17.0.4.jdk/Contents/Home

    11.0.15.1 (x86_64) "Oracle Corporation" - "Java SE 11.0.15.1" /Library/Java/JavaVirtualMachines/jdk-11.0.15.1.jdk/Contents/Home

/Library/Java/JavaVirtualMachines/jdk-17.0.4.jdk/Contents/Home

then if we wanted to change it, we would do;

export JAVA_HOME='/usr/libexec/java_home -v 11.015.1'

The above is untested.

Tuesday, 19 July 2022

MySQL create a new user

CREATE USER 'username'@'%' IDENTIFIED BY 'password';

GRANT privilege ON database.table TO 'username'@'%';

The above can be combined into one as;

GRANT privilege ON database.table TO 'username'@'%' IDENTIFIED BY 'password';

To grant basic permissions on a specific database or table. for example;

CREATE USER 'username'@'%' IDENTIFIED BY 'password';

GRANT EXECUTE ON database.* TO 'username'@'%';

which would allow the username to run procedures in the specified database and nothing else.

The following may also be of use;

GRANT ALL PRIVILEGES ON *.* TO  'username'@'%' IDENTIFIED BY 'password';

GRANT GRANT OPTION ON *.* TO  'username'@'%';


Friday, 15 July 2022

Create iso file from file on a Mac

1) Open Disk Utility and choose FILE > NEW IMAGE > IMAGE FROM FOLDER
2) Choose the folder and select IMAGE FORMAT as DVD/CD Master.
3) Navigate to where the file is created and run the following command;

hdiutil makehybrid -iso -joliet -o LIC.iso LIC.cdr



where LIC.iso is the TARGET and LIC.cdr is the SOURCE.

On Linux we would use;

mkisofs -o LIC.iso /path/to/LIC

where LIC.iso is the TARGET and LIC is the SOURCE folder.

If we have a cdrom as a source, we could use;

dd if=/dev/cdrom of=/path/to/LIC.iso

Alpha and OpenVMS

To return to the default directory, do;

SET DEF DFCROOT:[000000]

or SET DEF [-] 


DIR *.DIR

Shows all sub directories.

DIR /SIZE/DATE

Shows file size and date attributes.

 

To change to a directory normally do;

SET DEF [dir_name] or [dir_name.sub_dir_name]

where a directory is denoted by a .DIR extension.


Random stuff;

@SYS$UPDATE:VMSLICENSE.COM

See also here

To configure TCPIP, do @TCPIP$CONFIG

To start networking at boot time, add the following to STARTUP_VMS.COM by doing EDIT STARTUP_VMS.COM

@SYS$STARTUP:TCPIP$STARTUP

A note on the Alpha, TCPIP PING doesn't seem to work, however see UCX HELP

DELETE FILE.EXT;5

Deletes FILE.EXT version 5

PURGE /KEEP=100 FILE.EXT

Deletes FILE.EXT, keeping the 100 latest versions of the file.

 

To INITIALIZE a DISK;

INITIALIZE HN1$DKA100 DATA

where the output of SHOW DEVICE shows HN1$DKA100 UNDER Name.

Afterwords, we can mount the disk as;

MOUNT DKA100 DATA where DATA is the label

To mount a CDROM showing as DKA100, use;

MOUNT /override=ident DKA100

Monday, 6 June 2022

Wednesday, 20 April 2022

Friday, 1 April 2022

How to echo a double space with PHP

When echoing text with PHP, if the string contains more than one space, the extra spaces are lost when rendered in the browser.

the following is a workaround;

str_replace(' ', '&nbsp', $my_text);

This is especially important if we want to display values returned from a database query and the value has a double space for example and of course if that double space is important.


Thursday, 17 March 2022

Thursday, 24 February 2022

Backing up or restoring from a CF card, usb stick or similar using dd

 The basic format of the commands are as follows;

dd if=/dev/sdb of=/tmp/backup-file

dd if=/dev/backup-file of=/dev/sdb

Thursday, 17 February 2022

Tuesday, 18 January 2022

Removing gpg keys

gpg keys can normally be removed from the /etc/apt/trusted.gpg.d directory.

This would be in the format of sudo rm ...

However if the keys are stored in /etc/apt/trusted.gpg then we need to use;

sudo apt-key del [keyid] which is fine for older? systems where the following shows a list of the keys;

sudo apt-key list

and the keyid field would be shown but on modern systems that seems not to be the case, so this time, we again use sudo apt-key list but note the last 8 characters of the long number and this becomes the keyid which can then be removed by using;

sudo apt-key del [keyid]

Monday, 10 January 2022

gzip -l shows incorrect uncompressed file size

In some cases the incorrect uncompressed file size is reported when running the following command;

gzip -l myfile.gz

A work around is the use the alternative below;

zcat myfile.ga | wc -c

[source]

Wednesday, 5 January 2022

Resize a VistualBox disk

To resize a virtualbox disk, you can do it from the GUI on current systems;