Categories
Blog

Install Latest neovim (nvim)

Thanks to AppImage, the nvim application can be downloaded directly from the releases section of the neovim git repo, made executable, and used. I learned about this, from this DEV post. Simply, use curl to download nvim to the location you want (in my case, I used /usr/bin/nvim , but in the post, they put it somewhere else.
# get the latest stable build
sudo curl -o /usr/bin/nvim -LO https://github.com/neovim/neovim/releases/download/stable/nvim.appimage

# make it exectuable
sudo chmod +x /usr/local/bin/nvim
Note:
I have made small changes to the commands from the original post, to fit my own needs.
Categories
Blog

Mount an FTP Server as a Drive in Ubuntu

I do sidework for a company, that for certain reasons, I am unable to git clone a local copy of the site. So when I do work on their site, I need to FTP in. However, my editor of choice is VIM. Until today, I was using filezilla to connect to their FTP, and using the rightclick > View/Edit in order to open a local copy of the file, and was using VIM locally to edit the file, then going back to filezilla (that is listening for changes) and clicking ok to let it upload the modified file. I know that VIM actually does have the ability to connect and browse an FTP, but for some reason with this FTP server it was not working. So today, I found a way to mount an FTP server as a drive in Ubuntu, using a utility named curlftpfs.

Installation

Installation was pretty simple, using apt-get:
sudo apt-get install curlftpfs

Connection

  1. Create a directory to mount. I personally used ~/mnt/directoryname/:
    mkdir ~/mnt/directoryname
  2. My password for this FTP had special characters in it, so I had to use a special switch to be able to quote my username and password:
    curlftpfs -o user='username:passwordwithspecialcharacters' thefptserver.com ~/mnt/directoryname/
  3. From here, I was able to browse ~/mnt/directoryname as a directory, and can use VIM . to browse it as though its local.

Umount

It’s proably not secure to leave an FTP server mounted, so you can unmount when you’re done:
sudo umount ~/mnt/directoryname

That’s It!

This made my workflow for this particular situation waaaaaaay better than the filezilla solution!
sources:
– https://linuxconfig.org/mount-remote-ftp-directory-host-locally-into-linux-filesystem
– https://stackoverflow.com/questions/8959905/linux-curlftpfs-password-with-symbols
Categories
Blog

Installing Node.js and NPM on Windows Subsystem Linux

UPDATE

Original Post

Today I ran through quite a bit of trouble getting the most current version of nodejs and npm installed in my Ubuntu 16 (on windows 10). It turns out, the normal way of using apt-get to install it, installs a pretty old version. The workaround, I found on a github gist here.
$ touch ~/.bashrc
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.6/install.sh | bash
// restart bash
$ nvm install node
It’s a simple curl command that will download and run a bash script that will install NVM (Node Version Manager), and then you use NVM to install the latest and greatest node and npm. Here is the actual github page for nvm itself, if you’re curious:
https://github.com/creationix/nvm/blob/master/README.md As of writing this article, this worked for me, and I was able to proceed working on my angular project originally started on my Macbook Pro.
Categories
Blog

CSS Form Validation

So, I had no idea that we had new CSS Pseudo classes for form validation in HTML5 :o.
For example, you can create an input field of type “email”:
<input id="myEmail" type="email" required>
And use CSS to style it if it is invalid:
input:invalid {
  border-color: red;
}
This blew my mind! lol. BUT, to take it even further, you can use JS to verify your form, simply by checking validity.valid on the element. Below is a short example:
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title></title>
    <style>
      input {
        border: solid 1px black;
      }
      input:invalid {
        border-color: red;
      }
    </style>
</head>
<body>
  <form>
    <input id="myEmail" type="email" required>
  </form>
  <button onclick="checkIfValid()">Check Validity</button>

  <script>
    const element = document.getElementById('myEmail');

    const checkIfValid = () => {
      const myAnswer = (element.validity.valid) ? "its valid!" : "not valid...";
      console.log(myAnswer);
    }


  </script>
</body>
</html>

sources:
– https://css-tricks.com/form-validation-ux-html-css/
Categories
Blog

Tail PHP error logs in Docker

FIRST – Docker PHP Setup!

Before you can actually see the docker php error logs, you have to enable php error logging in the php.ini file. I use an Ubuntu php image, and my php.ini location was here:
/usr/local/etc/php/
note: if you don’t know where your php.ini location is, you can create a TEMPORARY php file with this command in it:
<?php phpinfo(); ?>
REMEMBER that you should not leave this file existing in your site, because its insecure and will give public access to your server info!

I noticed that my php.ini file didn’t exist there, so I had to create it. Then I added this:
log_errors = On
error_log = /dev/stderr

Tailing the Logs

To tail the docker logs, use this command:
docker logs -f DOCKER_CONTAINER_NAME

To tail just the error logs:

docker logs -f your_php_apache_container >/dev/null

To tail just the access logs:

docker logs -f your_php_apache_container 2>/dev/null

Exta Note!

In PHP, you can also use the error logs as a debug console. Send info to it with:
<?php
  error_log('debug message goes here');
?>

sources:
– https://github.com/docker-library/php/issues/212