How to use NodeJS with KNEX.js to Access Oracle Database

Below is a cheat sheet install guide:

npm init
npm install knex --save
npm install oracledb

Follow the instructions to downloading the appropriate oracle basic client. You’ll need to basically download a basic client zip file, unzip the folder, and set the folder in either your Windows Path (PATH) or your Linux Path (LD_LIBRARY_PATH) More info can be found here: https://oracle.github.io/odpi/doc/installation.html

You’ll probably end up unzipping the basic client to /opt/oracle/instaclient_### or c:\oracle\instaclient##_#

There shouldn’t be any need to install a heavy ODT installer based version.

This guide should support Oracle 10 through Oracle 12 for connecting to Oracle database. This method assumes you only have an SID as well which was my own case and proved to be difficult to determine what to do to resolve it.

Below is a code example of a node js application using knex to connect to an oracle database.

Remember, table names are case sensitive, so you may need to capitalize the table name. (This isn’t necessarily true in older Oracle versions)

console.log('Biri.me Oracle Test Code');

var knex = require('knex')({
    client: 'oracledb',
    connection: {
        host: 'host.address.com:1234',
        user: 'username',
        password: 'password',
        database: 'databasename',
        instanceName: 'INSTANCE1',
        requestTimeout: 100,
        connectString: '(DESCRIPTION=          			
            (ADDRESS_LIST=            
            (ADDRESS=(PROTOCOL=TCP)              
            (HOST=host.address.com)(PORT=1234) ) )           
            (CONNECT_DATA=(SERVICE_NAME=INSTANCE1) ) )'
        //expirationChecker?(): boolean;
    },
    fetchAsString: [ 'number', 'clob' ]
  });

knex.select('*').from('TABLENAME').then(result=>console.log(result)).catch(error => console.log(error));

How To: Swap Between Ubuntu PHP Versions

If you are running into issues with a version of PHP running and want to swap the active PHP to a different version you can simply run the command below on Ubuntu to get an interactive menu to swap PHP versions…

sudo update-alternatives --config php

Sources:

https://stackoverflow.com/questions/42619312/switch-php-versions-on-commandline-ubuntu-16-04/48336881

And:

OpenVMS: How to Search Intrusions List Easily

Sometimes listing out the show/intrusions command can be tricky and lengthy to try and see if a user has been set as an intruder.

To overcome this easily, simply PIPE a SEARCH command through the show/intrusions command.

So for example you can use the following command to make analyzing the intrusions a lot easier.

$ PIPE show/intrusions | search sys$input "your search string"

Linux: Search for Text Within Files in a Directory

The easiest way is to use the command below:

grep -Ril "text you want to find" /some/directory

i stands for ignore case
R stands for recursive
l stands for “show the file name, not the result itself”

Ubuntu 16.04 RoundCube Install Guide (PHP7.0)

RoundCube Logo

RoundCube is a wonderful, free, open source webmail client to help users access their e-mail from any web browser.
RoundCube also has features that can be implemented such as calendars, address books (globally and locally per user), themes, plugins and much more.

This guide is intended to help share the experience I had with installing RoundCube as well as to hopefully help guide others through the process as well.

This guide’s steps were performed on an Ubuntu 16.04 server running PHP7.0 in particular.

Let’s Begin

Continue reading

Multiple WordPress installs, with separate domains, separate SSLs, same Ubuntu 16.04 server

This guide is intended to help act as a useful, quick guide for installing and configuring more than one WordPress server on a single server without using the WordPress MultiSite feature.

Continue reading

Ubuntu Apache & PHP read/write access

Give Ubuntu’s Apache2 ownership to the directory (-R is all files within it)

sudo chown -R www-data /var/www/html/some_directory

Give that folder read/write access:

sudo chmod 755 /var/www/html/some_directory

How To Configure SMTP for Ubuntu 14 Apache2/PHP (Simplified)

First, install ssmtp package:

sudo apt-get install ssmtp

Remove any old sendmail packages floating around that you won’t need:

sudo apt-get autoremove

Continue reading

WordPress Ubuntu Apache: interpret URL as a lower URL

This guide is to help users who were previously on a case insensitive web server and hosting many directories and files on their server mixed with upper and lower case letters who wish to move to a server that has case sensitivity such as Linux, or more specifically Ubuntu running Apache.

In this scenario, the Ubuntu Apache server is also running a Multi-site WordPress, running multiple domains on the same server so the traditional ways of configuring the vhosts file may not possible.

The trick is to set up a rewrite rule that essentially takes any URL provided to the server, and interprets it as a lowercase URL.

This seems pointless at first, but the trick is that the files being migrated to the Multi-site WordPress server, can be copied in just lower case form.

I found the easiest trick is to simply zip up all of the files, and then unzip them.

zip -0 -r foo.zip foo/
unzip -LL foo.zip

This will zip up the foo directory (including the directory itself) that contains all of the files and folders, and then UNZIP it all using the -LL flag which makes it all lowercased folders and files.

You can then perform the command:

cp -r /foo/* /var/www/html

to move the contents of everything that was inside the foo folder, directly into the html folder.

This will take care of having a migrated set of data that’s strictly in lower cased form.

The next step is to have Apache actually reference the lower case version each time a request is made.

For that we’ll need to sure mod_rewrite is enabled if it’s not already by running:

sudo a2enmod rewrite
sudo service apache2 restart

Next, we’ll need to edit the global apache2 conf file

sudo nano /etc/apache2/apache2.conf

At the bottom of the file include the lines:

RewriteEngine On
RewriteMap  lc int:tolower

Next, we’ll need to edit the .htaccess file used by WordPress

This should be found in the root of our webserver directory that WordPress is hosted on.

sudo nano /var/www/html/.htaccess

At the top of the file under the Options -Index (if it exists as the first line)

Place the lines of:

RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule (.*) ${lc:$1} [R=301,L]

The RewriteCond will check if any characters in the URL contain a capital letter.

If there is a capital letter found, it will run the function lc (defined in the apache2.conf file) that will convert the string $1, which is the regex group defined by (.*)  which is the whole URL in this case, to a lower case string.

It will then perform a redirect 301, and the L will indicate that this the LAST thing involved with this RewriteCond and RewriteRule set.

Disabling Browsable Directories with Apache

The simplest way is to modify the root directory .htaccess file and at the top of the file add the line of:

Options -Indexes

It took me longer than I wish it had to find this so hopefully this helps out others in the future.

© 2020 Biri.me

Theme by Anders NorénUp ↑