• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

web

Install Cockpit on Rocky 9

October 3, 2022

Cockpit is a web-based graphical interface for Linux users and admins.

Install

dnf install cockpit

dnf install cockpit

Start and Enable

systemctl start cockpit
systemctl enable cockpit.socket

systemctl start cockpit systemctl enable cockpit.socket

Status

systemctl status cockpit

systemctl status cockpit

Web access

http://192.168.0.20:9090

http://192.168.0.20:9090

Filed Under: Linux Tagged With: admins, cockpit, install, interface, users, web

Ajax Live Search

May 22, 2022

Just implemented an Ajax live search on a website.

Here’s the search page. Results are displayed in div output.

<script src="https://code.jquery.com/jquery-3.4.1.js"></script>
<script type="text/javascript">
$(document).ready(function(){
    $("#search").keyup(function(){
        var query = $(this).val();
        if (query != "") {
        $.ajax({
            url: 'links-ajax.php',
            method: 'POST',
            data: {query:query},
            success: function(data){
            $('#output').html(data);
            $('#output').css('display', 'block');
            $("#output a").on("click", function(){
                $("#output").val($(this).html());
            });
            $("#search").focusout(function(){
                window.setTimeout(function() {
                $('#output').css('display', 'none');
                }, 500);
            });
            $("#search").focusin(function(){
                $('#output').css('display', 'block');
            });
            }
        });
        } else {
        $('#output').css('display', 'none');
    }
    });
});
</script>
 
<div class="form-row">
    <div class="col">
        <input type="text" name="search" id="search" autocomplete="off" placeholder="Search here...." class="form-control form-control-success">
    </div>
</div>
<div id="output"></div>

<script src="https://code.jquery.com/jquery-3.4.1.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#search").keyup(function(){ var query = $(this).val(); if (query != "") { $.ajax({ url: 'links-ajax.php', method: 'POST', data: {query:query}, success: function(data){ $('#output').html(data); $('#output').css('display', 'block'); $("#output a").on("click", function(){ $("#output").val($(this).html()); }); $("#search").focusout(function(){ window.setTimeout(function() { $('#output').css('display', 'none'); }, 500); }); $("#search").focusin(function(){ $('#output').css('display', 'block'); }); } }); } else { $('#output').css('display', 'none'); } }); }); </script> <div class="form-row"> <div class="col"> <input type="text" name="search" id="search" autocomplete="off" placeholder="Search here...." class="form-control form-control-success"> </div> </div> <div id="output"></div>

Here’s the links-ajax.php which display the search results with links.

<?php
$servername='localhost';
$username='';
$password='';
$dbname = "";
$conn=mysqli_connect($servername,$username,$password,"$dbname");
if(!$conn) { die('Could not Connect MySql Server:' .mysql_error()); }
if (isset($_POST['query'])) {
    $query = <<<"SQL
                 SELECT * FROM links WHERE `name` LIKE '%{$_POST['query']}%' 
                 OR `url` LIKE '%{$_POST['query']}%' 
                 OR `tag` LIKE '%{$_POST['query']}%' 
                 ORDER BY name ASC, url ASC"
             SQL;
    $result = mysqli_query($conn, $query);
    if (mysqli_num_rows($result) > 0) {
        while ($user = mysqli_fetch_array($result)) {
            echo "<a target='_blank' rel="noopener">".$user['name']."</a><br/>";
        }
    } else {
        echo "<p style='color:red'>No results found...</p>";
    }
}
?>

<?php $servername='localhost'; $username=''; $password=''; $dbname = ""; $conn=mysqli_connect($servername,$username,$password,"$dbname"); if(!$conn) { die('Could not Connect MySql Server:' .mysql_error()); } if (isset($_POST['query'])) { $query = <<<"SQL SELECT * FROM links WHERE `name` LIKE '%{$_POST['query']}%' OR `url` LIKE '%{$_POST['query']}%' OR `tag` LIKE '%{$_POST['query']}%' ORDER BY name ASC, url ASC" SQL; $result = mysqli_query($conn, $query); if (mysqli_num_rows($result) > 0) { while ($user = mysqli_fetch_array($result)) { echo "<a target='_blank' rel="noopener">".$user['name']."</a><br/>"; } } else { echo "<p style='color:red'>No results found...</p>"; } } ?>

I couldn’t get the links working, until I added the 500ms of timeout in .focusout.

Filed Under: HTML, PHP Tagged With: ajax, live, search, web

Python Web Server

May 20, 2022

Here’s a quick way to start a web server using Python (not recommended for production).

If you want to use python3, you may have to use explicitly use python3.

Check what versions you have first.

python --version
python3 --version

python --version python3 --version

Start web server using port 8080 in the current directory.

python -m http.server 8080

python -m http.server 8080

If you want an alternate directory, use this -d option.

python -m http.server 8080 -d /tmp

python -m http.server 8080 -d /tmp

It’s a great tool for quick downloads.

Filed Under: Linux Tagged With: download, python, server, web

Tomcat Install

June 4, 2021

Tomcat requires JRE.

wget jre-8uversion-linux-x64.tar.gz
# or
apt-get install default-jdk

wget jre-8uversion-linux-x64.tar.gz # or apt-get install default-jdk

Install Tomcat 8 on Linux.

wget https://mirrors.gigenet.com/apache/tomcat/tomcat-8/v8.5.66/bin/apache-tomcat-8.5.66.tar.gz
tar zxpvf apache-tomcat-8.5.66.tar.gz
cd /opt/tomcat/apache-tomcat-8.5.66/bin/
./startup.sh

wget https://mirrors.gigenet.com/apache/tomcat/tomcat-8/v8.5.66/bin/apache-tomcat-8.5.66.tar.gz tar zxpvf apache-tomcat-8.5.66.tar.gz cd /opt/tomcat/apache-tomcat-8.5.66/bin/ ./startup.sh

Status|Start|Stop|Restart Tomcat.

systemctl status tomcat8
systemctl start tomcat8
systemctl stop tomcat8
systemctl restart tomcat8

systemctl status tomcat8 systemctl start tomcat8 systemctl stop tomcat8 systemctl restart tomcat8

Filed Under: Misc Tagged With: apache, install, restart, server, start, status, stop, tomcat, web

GCP Web Server

January 8, 2020

Here’s a quick script to stand up a web server based on Centos image.

gcloud compute instances create [VM-NAME] \
    --zone=[ZONE] \
    --image-family=debian-9 \
    --image-project=debian-cloud \
    --tags=allow-ssh,allow-health-check \
    --subnet=lb-subnet \
    --metadata=startup-script='#! /bin/bash
apt-get update
apt-get install apache2 -y
a2ensite default-ssl
a2enmod ssl
vm_hostname="$(curl -H "Metadata-Flavor:Google" \
http://169.254.169.254/computeMetadata/v1/instance/name)"
echo "Page served from: $vm_hostname" | \
tee /var/www/html/index.html
systemctl restart apache2'

gcloud compute instances create [VM-NAME] \ --zone=[ZONE] \ --image-family=debian-9 \ --image-project=debian-cloud \ --tags=allow-ssh,allow-health-check \ --subnet=lb-subnet \ --metadata=startup-script='#! /bin/bash apt-get update apt-get install apache2 -y a2ensite default-ssl a2enmod ssl vm_hostname="$(curl -H "Metadata-Flavor:Google" \ http://169.254.169.254/computeMetadata/v1/instance/name)" echo "Page served from: $vm_hostname" | \ tee /var/www/html/index.html systemctl restart apache2'

Filed Under: Cloud Tagged With: apache, debian, gcp, metadata, server, vm, web

Matrox Monarch Configuration

July 4, 2019

You can import the Matrox Monarch HD configuration on boot up from a web page. Go to:

Command Center > Automatic Configuration.
Type in URL Address starting with https.
Check "Load settings on device reboot."
You can either power off the device or hit reset.
Holding reset for more than 5 seconds does a factory reset.
On next bootup, device will have configuration contained from the remote file.

Command Center > Automatic Configuration. Type in URL Address starting with https. Check "Load settings on device reboot." You can either power off the device or hit reset. Holding reset for more than 5 seconds does a factory reset. On next bootup, device will have configuration contained from the remote file.

Filed Under: Misc Tagged With: configuration, file, live streaming, matrox, monarch, remote, web

  • Home
  • About
  • Archives

Copyright © 2023