run index.html on npm - npm

I am complete beginner so I apologize in advance.
I have installed npm with these scripts in terminal
1.curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
2.nvm install node
then I set it to run like this
http-server -a localhost
Starting up http-server, serving ./public
Available on:
http://localhost:8081
an I have an index. html in my documents that I would like to display. I have tried to just state the whole path in the browser so like http://localhost:8081/Documents/testServer/index.html
But that doesn't work

You must install the tools inside the folder that contains index.html file as below
First : Open the folder that contain index.html
Second : Install Tools
1.curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
2.nvm install node
Third : Open the live server at :
http://localhost:8081/Documents/testServer/index.html

Related

How to create and deploy an endpoint with Directus?

I have a nooby Directus question :
How to create an endpoint and attach it to my project ?
I try to follow the doc in vain :
Create a directus project
npm init directus-project example-project
SQLite / Admin / Password
cd example-project; npx directus start
I can access directus admin at http://0.0.0.0:8055/admin/content
CTRL+C
Create an endpoint
cd .., going away of my directus project, npm init directus-extension
endpoint / demo-directus-endpoint / javascript
Modifying endpoint / to /hello in src/index
cd demo-directus-endpoint; npm run build
Deploy extensions inside directus project
https://docs.directus.io/extensions/creating-extensions/
To deploy your extension, you have to move the output from the dist/ folder into your project's ./extensions/<extension-folder>/<extension-name>/ folder. <extension-folder> has to be replaced by the extension type in plural form (e.g. interfaces). <extension-name> should be replaced with the name of your extension.
cd ../example-project
mkdir ./extensions/endpoints/demo
cp -R ../demo-directus-endpoint/dist/index.js ./extensions/endpoints/demo
index.js looks like this :
"use strict";module.exports=e=>{e.get("/hello",((e,l)=>l.send("Hello, World!")))};
npx directus start
17:43:40 ✨ Loaded extensions: demo
17:43:40 ⚠️ PUBLIC_URL should be a full URL
17:43:40 ⚠️ Spatialite isn't installed. Geometry type support will be limited.
17:43:40 ✨ Server started at http://0.0.0.0:8055
Trying to get url http://0.0.0.0:8055/hello
curl http://0.0.0.0:8055/hello => {"errors":[{"message":"Route /hello doesn't exist.","extensions":{"code":"ROUTE_NOT_FOUND"}}]}
17:43:55 ✨ request completed GET 404 /hello 8ms
What to do in order to get Hello, World! when curl http://0.0.0.0:8055/hello ?
Thank you for your help
Answer found
curl http://0.0.0.0:8055/demo/hello => Hello, World!

How to install Apache on OmniOS

I am attempting to install Apache on OmniOS. I followed the instructions here: option 2 https://wiki.openindiana.org/oi/3.+Installing+software+and+package+management
Ran the command:
echo $PATH results in /opt/local/sbin:/opt/local/bin:/usr/gnu/bin:/usr/sbin:/sbin
curl https://pkgsrc.joyent.com/packages/SmartOS/bootstrap/bootstrap-2016Q4-x86_64.tar.gz | gtar -zxpf - -C /
pkgin -y update
pkgin -y install apache-2.4.6 resulted in the messages Calculating dependencies...done and then nothing to do
I can not find the apache service or configuration directory as they are described here: https://docs.joyent.com/public-cloud/instances/infrastructure/images/smartos/apache
/opt/local/etc/httpd The configuration directory for Apache
svcs pkgsrc/apache Checking service for Apache
Server Info:
uname -v results in omnios-r151026-d9b45886bd
Running x86
Also running SunONE webserver
Though incomplete, my commands did make a change. My Perl scripts can no longer find DBI.
Why does the Apache install say there is nothing to do? What am I missing?
UPDATE
Ran which apache2 resulted in no apache2
Ran pkgin list to list all installed packages. Only apache
reference is apache-maven-3.5.4
Ran find . -name '*apache*' in the following directories:
\etc nothing
\opt found:
vim, el, and elc files in SUNWspro
org-apache-tools-ant-module files and folder in netbeans/3.5V11/modules/patches
apache folder in SUNWwbsvr/plugins/java/samples/webapps/jstl/src/org which contains java files
vim, tag, el and elc files in sfw --- also an apache folder in sfw which contains readme/bash type files for apache/php and one so file
apache-maven-3.5.4 files/folders in local
org-apache-xml-resolver* files in sunstudio12.1
'\usr' found:
2 vims in share/vim/vim80/syntax
apache-fcgi.conf in lib/python2.7/vendor-packages/cherrypy/scaffold
'\var' nothing
As far as I can tell, the binaries have not been installed
I tried running pkgin -y install apache-2 and it worked. It installed apache-2.4.3. Perhaps apache-2.4.6 does not exist in the repository.
This mean apache is already installed on the Linux system. To run below command which will tell the location of the system binary.
which apache2
for the configuration folder look for below directory:
/etc/apache2

Using "Remote SSH" in VSCode on a target machine that only allows inbound SSH connections

Is there a way to use the VSCode Remote SSH extension to interact with a remote host that does not allow outbound internet connections?
Is it possible to download the vscode-server files from another system and copy to host?
I read this but I can't connect the server to internet.
When you connect to a host it executes a bash script that wgets or curls a tarball and extracts it in a directory in your home directory. Here's an offline workaround.
Attempt to connect, let it fail
On server, get the commit id
$ ls ~/.vscode-server/bin
553cfb2c2205db5f15f3ee8395bbd5cf066d357d
Download tarball replacing $COMMIT_ID with the the commit number from the previous step
For Stable Version
https://update.code.visualstudio.com/commit:$COMMIT_ID/server-linux-x64/stable
For Insider Version
https://update.code.visualstudio.com/commit:$COMMIT_ID/server-linux-x64/insider
Move tarball to ~/.vscode-server/bin/$COMMIT_ID/vscode-server-linux-x64.tar.gz
Extract tarball in this directory
$ cd ~/.vscode-server/bin/$COMMIT_ID
$ tar -xvzf vscode-server-linux-x64.tar.gz --strip-components 1
Connect again
You'll still need to install any extensions manually. There's a download button next to all the extensions in the marketplace. Once you have the .vsix file you can install them through the GUI with the Install from VSIX option in the extensions manager.
This is kind of a pain and hopefully they improve this process, but if you have a network-based home directory, you only have to do this once.
open vscode -> about
Version: 1.46.1
Commit: cd9ea6488829f560dc949a8b2fb789f3cdc05f5d
Date: 2020-06-17T21:17:14.222Z
Electron: 7.3.1
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Darwin x64 17.7.0
$COMMIT_ID = cd9ea6488829f560dc949a8b2fb789f3cdc05f5d
A new feature is being added to support offline install
However, you can now solve this issue by a new user setting in the Remote - SSH extension. If you enable the setting remote.SSH.allowLocalServerDownload, the extension will install the VS Code Server on the client first and then copy it over to the server via SCP.
Note: This is currently an experimental feature but will be turned on by default in the next release
https://code.visualstudio.com/blogs/2019/10/03/remote-ssh-tips-and-tricks
A a work around I have done the following:
Desktop ~/.ssh/config
...
Host *
RemoteForward 54321
...
Remote: ~/bin/wget in which ~/bin is added to PATH via .bashrc
#!/bin/bash
export LD_LIBRARY_PATH=$HOME/opt/lib/tsocks/
export TSOCKS_CONF_FILE=$HOME/opt/tsocks/tsocks.conf
$HOME/bin/tsocks /usr/bin/wget $#
Remote: ~/opt/tsocks/tsocks.conf
server = 127.0.0.1
server_port = 54321
server_type = 5
note tsocks binary has been scp-ed to ~/bin/tsocks and ~/opt/tsocks/ has been created with libtsocks.so which is normally stored in /usr/lib64/libtsocks.so
This is a work around that allows me to have wget functionality with out messing with anything outside my profile to get it to work (eg: no root required ... even though I have it).
Current Version of VS Code: 1.48.2
I just kill the wget process on the server end, and let the client download the archive and transfer it to the server end. That's quite easy as below.
make sure that you set in settings.json
"remote.SSH.allowLocalServerDownload": true,
execute the shell scrpits below.
# to find the <pid>
ps aux | grep wget | grep vscode-server
# kill the process
kill -9 <pid>
# then wait for the client downloading and transferring
# optional: If you want to know the progress, just
cd ~/.vscode-server/bin/<commit-id>/
watch -n 1 -d ls -rthl

docker file to run automation test in JS files

I am trying to create a docker file to run selenium tests for a java script based project. Below is my docker file so far:
#base image
FROM selenium/standalone-chrome
#access to the project within docker container - Bundle app source
COPY ./seleniumTest/project /app
# Install Node.js
RUN sudo apt-get update
RUN sudo apt-get install --yes curl
RUN curl --silent --location https://deb.nodesource.com/setup_8.x | sudo bash -
#binding
EXPOSE 8080
#Define runtime
ENTRYPOINT /app/login.test.js
while running with $ docker run -p 4000:80 lamgadekamal/dockertest
returns: Unable to find image 'lamkam/dockertest:latest' locally docker: Error response from daemon: manifest for lamkam/dockertest:latest not found. Could not figure out why am I getting this?
I suspect that you need to build your image first, since the image cannot be found.
Run this command from the same directory where your Dockerfile is located. This will build the image.
docker build -t lamgadekamal/dockertest .
You can then verify that the image exists by running docker images
EDIT: After looking at this again, it appears that you are trying to run the wrong image. You are trying to run lamgadekamal/dockertest, but you built the image with the tag lamkam/dockertest? Seems like you have a typo. I would suggest running docker images to see exactly what is there, but in all likelihood, you need to run lamkam/dockertest.
docker run -p 4000:80 lamkam/dockertest

Installing manually PHPDocumentor on Mac

After trying to install PHPDocumentor with PEAR install with no success, i tried it manually as is detailed on the official website: http://www.phpdoc.org/docs/latest/for-users/installation.html
I downloaded the files and i make an alias on /usr/bin/ but when i try to execute phpdoc.php via terminal y it shows an error.
This is what i try:
> cd /usr/bin/
> ./phpdoc.php
And this is the error:
PHP Warning: include_once(/Applications/MAMP/htdocs/phpdocumentor/src/phpDocumentor/../../vendor/autoload.php): failed to open stream: No such file or directory in /Applications/MAMP/htdocs/phpdocumentor/src/phpDocumentor/Bootstrap.php on line 72
PHP Warning: include_once(): Failed opening '/Applications/MAMP/htdocs/phpdocumentor/src/phpDocumentor/../../vendor/autoload.php' for inclusion (include_path='/Applications/MAMP/bin/php/php5.3.6/lib/php/:/Applications/MAMP/bin/php/php5.3.6/lib/bin/') in /Applications/MAMP/htdocs/phpdocumentor/src/phpDocumentor/Bootstrap.php on line 72
PHP Fatal error: Class 'phpDocumentor_Task_Runner' not found in /Applications/MAMP/htdocs/phpdocumentor/bin/phpdoc.php on line 37
I am using Mac Os X and as you can see, i use MAMP to run Apache.
What's going on here? Why it tries to open a file which doesn't exist? (because it really doesn't exist inside PHPDocumentor folder)
Thanks.
Did you try :
curl -s http://getcomposer.org/installer | php
php composer install
on phpdocumentor2 directory (you should find composer.json)
Composer is a dependency manager for php. So it will populate phpdocumentor projet with external/vendor dependencies
Try this to install Composer into your MAMP php bin:
cd yourapp/ && curl -s http://getcomposer.org/installer | /Applications/MAMP/bin/php/php5.3.6/bin/php