Labels

Android (1) bash (2) boost (2) C (34) C++ (2) cheatsheet (2) CLion (6) css (3) Debian (33) DL (17) Docker (1) Dreamweaver (2) Eclipse (3) fail2ban (4) git (5) GitHub (4) Hacking (3) html (8) http (1) iOS (1) iPad (1) IRC (1) Java (30) javascript (3) Linux (164) Mac (19) Machine Learning (1) mySQL (47) 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 (45) SQL (14) svn (1) tar (1) ThinkPad (1) Virtualbox (3) Visual Basic (1) Visual Studio (1) Windows (2)

Friday 17 December 2021

MySQL current date

 The following are just examples of the use date offsets;


SET @timeframe=now()-interval 2 year; 
SELECT ...
WHERE o.doe >= @timeframe


SET @timeframe = DATE_SUB(CURDATE(), interval 1 day);
SELECT ...
WHERE o.doe >= @timeframe and o.doe <= @timeframe
 

The former will deal with the full date/time stamp, while the latter will consider only the date and is good for when we need to find results for a particular day for example.


Wednesday 15 December 2021

Thursday 25 November 2021

MySQL error when trying to create a function

This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)

Thursday 28 October 2021

Unable to open or incompatable vdproj solution

When using Visual Studio (recent versions), with vdproj files, you may get an error or warning that the file is incompatible or unable to open.

Monday 25 October 2021

Bash comparisons

 

integer comparison


-eq

    is equal to

    if [ "$a" -eq "$b" ]


-ne

    is not equal to

    if [ "$a" -ne "$b" ]


-gt

    is greater than

    if [ "$a" -gt "$b" ]


-ge

    is greater than or equal to

    if [ "$a" -ge "$b" ]


-lt


    is less than

    if [ "$a" -lt "$b" ]


-le

    is less than or equal to

    if [ "$a" -le "$b" ]



string comparison


==

    is equal to

    if [ "$a" == "$b" ]

!=

    is not equal to

    if [ "$a" != "$b" ]


[source]

Tuesday 21 September 2021

Detect screen size in php

Detecting the screen size in php, is not something that can be done with php alone but the following is what I use to kind of get around it.

Monday 20 September 2021

Get next AUTO INCREMENT value from a mysql table


SELECT AUTO_INCREMENT as 'next_id' FROM information_schema.TABLES
WHERE TABLE_SCHEMA = 'db_name' AND TABLE_NAME = 'table_name';



Sunday 29 August 2021

Configure Netbeans to use ssh key with GitHub

Following a recent change to GitHub, username and passwords would no longer work with Netbeans and others when interacting with repositories. Other IDE's such as Jetbrains are able to use Tokens but Netbeans proved to be a little more stubborn.

Saturday 28 August 2021

Discrete or continuous data

Continuous data is data obtained by measurement whereas discrete data is data obtained by counting.

Tuesday 17 August 2021

Mount vhd file under Linux

To mount a vhd file under Linux (tested with Debian buster), firstly get the following;

Tuesday 3 August 2021

Starting Services at boot time in slackware

 A reminder...

Any networking services should be handles by rc.init2 and simply requires making the appropriate script in /etc/rc.d executable.

But if we add our own custom script, then we can add the following to rc.local

# Start MCR Monitor
if [ -x /etc/rc.d/rc.mcr_monitor ]; then
        echo "Starting MCR Monitor..."
        . /etc/rc.d/rc.mcr_monitor start
fi


Tuesday 20 July 2021

Brief note on sed, its use with variables and also changing variables inside the file which is being run.

Generally to use sed, we would do;

sed -i 's/old-text/new-text/g' file.txt

where file.txt is the file containing old-text and new-text.

If we want to ensure that our search term is at the beginning of the line, we add the ^ as follows;

sed -i 's/^old-text/new-text/g' file.txt

Thursday 10 June 2021

Ping TTL

The TTL can give an indication of which OS you are pinging...

Linux 64

Windows 128


Tuesday 8 June 2021

Debugging output in visual Studio

Use the following to provide debugging information while developing in visual Studio;

System.Diagnostics.Debug.WriteLine("something of interest...");


Thursday 20 May 2021

Boostnote

I had issues installing boostnote on Debian using the download from the site.

Wednesday 21 April 2021

Properly stopping an application without using monit.

Issue: Application that should not have been running had been started using monit and then stopped using monit.

Tuesday 20 April 2021

Berkeley DB db.h is missing

I go this error while trying to configure gnucobol but I have seen it before somewhere, just cant for the life of me remember where. anyway, a solution is to install the following;

libdb-dev


Saturday 17 April 2021

HTML date picker

<label for="start">Start date:</label>
<input type="date" id="start" name="trip-start"
       value="2018-07-22"
       min="2018-01-01" max="2018-12-31">

Monday 5 April 2021

To dump query result to a file from commandline

If we want to save the output from a MySQL session to a file, we can do this by adding the following to the end of the query;

INTO OUTFILE '/tmp/myresults.csv';

Monday 22 March 2021

Trac on Slackware

Installation script for installing trac and it's dependencies on Slackware

Get it here: here

Note, you will need the rc.trac script, also from the above.



Thursday 18 March 2021

Wednesday 10 March 2021

Execute a shell command from php

To execute a shell command from php, typically do the following;

            <?php
            $output = shell_exec('sudo -u root monit summary');
            echo "<pre>$output</pre>";
            ?>

In the above scenario, we want to run something as root, so we need to modify our /etc/sudoers file;

Firstly, assuming the user is www-data then we can add the following line to /etc/sudoers

www-data ALL = NOPASSWD: /usr/sbin/monit

where /usr/sbin/monit is the command that we wish to allow the user www-data to run without the need to enter a password.



Friday 26 February 2021

Wednesday 24 February 2021

Change vim colours or more specifically to change the comments from blue to somehting more readable.

This works on Slackware

Create or edit your /home/user/.vimrc file, adding the following;

:set background = dark


Friday 19 February 2021

To relocate existing codebase to a new svn location

If we have an svn url which we backup and restore to a new url, then we can update existing source to point to the new url as below;

Monday 15 February 2021

To download and execture a script automatically in Linux

If we want to ensure that we are always running the most recent version of a script, then we can use curl as below;

curl -s http://192.168.254.198/stuff/scripts/myscript.sh | bash -s arg1 arg2 arg3

where http://192.168.254.198/stuff/scripts/myscript.sh is the location of the script, reachable from the target machine and arg1, arg2, arg3 are optional parameters that would be applicable if the script was run from the command line as ./myscript.sh arg1 arg2 arg3

 


To rename a drive or partition in Linux

tunefs -l name /dev/sda1

where name is the name we wish to use and /dev/sda1 is the target partition.


Monday 8 February 2021

HOWTO use Acronis Backup or Restore boot disk without a mouse

ALT + [LEFT SHIFT] + [NUM LOCK]

Then we can use the cursor keys or mouse keys with ENTER being a LEFT CLICK

source

Saturday 6 February 2021

Issue on Mac with Corsair K95

Automatically open the Google Chrome browser with Developer Tools

 To open Chrome with Developer Tools all the time, you simply open in with the following arguments;

--args --auto-open-devtools-for-tabs

To have this done in PhpStorm goto Tools>Web Browsers and edit Chrome, adding in the above to the Command Line Options field.

Friday 22 January 2021

Restore lost or broken configurations files in Debian

If we've deleted or messed up a configuration file, then we can restore by doing the following;

Thursday 21 January 2021

Read my.cnf file

If we want to read an option group within a my.cnf config file for MySQL, then we can do so as follows;

my_print_defaults --config-file=/etc/mysql/my.cnf mysqld2

in the above example, we will read from the file /etc/mysql/my.cnf all values under the group mysql2

If we use the --config-file only, then only this file will be read.
 

The following works quite well;

my_print_defaults mysqld1

this will read from all configuration files (assuming they are included), where mysqld1 is the group

Wednesday 6 January 2021

Problem building meslink

I had trouble building mesllink using Netbeans but note that it did build correctly from the original source on the box, from the command line by running make.

This is similar to a problem I had with mesdb detailed here. (worth reading first).