Labels

Android (1) Apache (1) bash (2) boost (2) C (37) C++ (5) cheatsheet (2) CLion (6) css (3) Debian (35) DL (17) dns (1) Docker (3) Dreamweaver (2) Eclipse (3) fail2ban (5) git (6) GitHub (5) Hacking (4) html (8) http (1) iOS (1) iPad (1) IRC (1) Java (34) javascript (3) Linux (186) Mac (22) Machine Learning (1) mySQL (54) Netbeans (7) Networking (1) Nexus (1) OpenVMS (6) Oracle (5) Pandas (3) php (17) Postgresql (8) Python (9) raid (1) RedHat (15) Samba (3) Slackware (54) SQL (14) ssh (1) svn (1) tar (1) ThinkPad (1) Virtualbox (4) Visual Basic (2) Visual Studio (1) Windows (8) wire (1)

Monday, 11 May 2020

Quickly add dir to OSX

A quick and dirty method of adding dir to a Mac is as simple as creating a link to /bin/ls

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

If the lock screen sound, keyboard click and camera sound aren't working on iPad, but you find other sounds are, such as music, ringtones etc, it is worth checking the control centre by swiping down from top right of screen as the system may have been muted.

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.

To change text in an html document or web page, we can use 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>

Half adder and 1 bit full bit adder

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>

 
The following is a basic javascript equivalent;
 
<script>
setTimeout(function () 
{
   // 5 seconds
   window.location.href= 'index.html';
}, 5000);
</script>
 
 
 
To reload a page without getting an alert, we can do the following;
 
<script>
    function reload_page()
    {
        window.location = window.location.href;
    }
</script>
 
then call it by;
 
<script type="text/javascript">
     reload_page();
</script>';
 
or from php;
 
echo '<script type="text/javascript">'.'reload_page();'.'</script>';


To call the function after some time, for example, to refresh the page in 5 seconds, we can do the following to call the reload_page function detailed above;


<script>
setTimeout(reload_page,5000);
</script>


Sign Magnitude, Two's compliment binary representations

The following table shows the difference between Sign Magnitude and Two's compliment

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

The following is an automator screenshot of how to add a Right Click action to highlighted text in any application on a Mac.

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

We can test any fail2ban filters by using the following:

fail2ban-regex <logfile> <filter>

Example:

fail2ban /var/log/apache/error_log /etc/fail2ban/filter.d/apache-noscripts.conf