Tuesday, June 16, 2020

AWS pem file "permission too open" error on Windows

Go to the file directory and issue this command

$path = ".\thewowbuys_aws_server.pem"
# Reset to remove explicit permissions
icacls.exe $path /reset
# Give current user explicit read-permission
icacls.exe $path /GRANT:R "$($env:USERNAME):(R)"
# Disable inheritance and remove inherited permissions
icacls.exe $path /inheritance:r

Sunday, May 24, 2020

AWS XAMPP Virtual Host configuration

First need to make sure AWS instance is up and running. Then need to assign an elastic IP to the Instance. Because of this elastic IP, services can access the instance directly.

First, need to edit httpd.conf

Sudo vi /opt/lampp/etc/httpd.conf

Around line 487 need to remove the comment and allow httpd-vhosts.conf

# Virtual hosts
Include etc/extra/httpd-vhosts.conf

Then need to create a custom domain in the hosts file.

sudo vi /etc/hosts

127.0.0.1 localhost
127.0.0.5 kingalawaka.com <new line >
#don't touch other existent values
# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

This file is used to locate the host.

Then need to create vitual host

sudo vi /opt/lampp/etc/extra/httpd-vhosts.conf

file should look like this

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "/opt/lampp/htdocs"
    ServerName dummy-host.example.com
    ServerAlias www.dummy-host.example.com
    <Directory "/opt/lampp/htdocs">
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        Allow from all
        Require all granted
    </Directory>
</VirtualHost>
<VirtualHost *:80>
    ServerAdmin 123pasindumanisha@gmail.com
    DocumentRoot "/opt/lampp/htdocs/mysite"
    ServerName kingalawaka.com
    ServerAlias www.kingalawaka.com
    DirectoryIndex index.html
    <Directory "/opt/lampp/htdocs/mysite">
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order Deny,Allow
        Allow from all
        Require all granted
    </Directory>
</virtualHost>

After saving the file

sudo /opt/lampp/lampp restart

if in case Apache service not stopped

sudo netstat -nap | grep :80

this will list down all the processes using port 80. Then from that, using process ID can kill the process.

sudo kill 980

then try to restart the lampp server.

Thursday, March 29, 2018

Open-CV migrating from Windows(Visual Studio) to Ubuntu

Depends on the scenario, it may be required you to change the development environment. After the change, the system never is expected to execute the code smoothly. for this errors, sometimes no errors in the compilation and when you run its simply exit no output will be visible.  I faced this issue and this is my findings of this problem. 


  • Case sensitiveness, if your images have .jpg and in your code, you mentioned as .JPG this may throw and assertation error. In some cases, it's not. Check carefully the case of your code. Linux is case sensitive. 
  • Never called executable code (method calling) outside the main method or any other method. 
This code segment is in outside the main method and not belong to any other method. This is more like a global declaration so I don't need to pass parameters to methods. This is going to fail in Linux environment. this should be inside a method.

This is Linux, and I insert that code segment inside the main method and worked fine. 
I don't know to explain why it's not working but I believe visual studio going to handle lots of things for us. But g++ compiler cant.

  • Always use pass by reference for parameter passing because then we can update the same variable.  
This is it for now and I will update this article with other problems I faced in future. 

Thursday, March 22, 2018

Install drivers in ubuntu using command line

First, you need to get superuser permission.
sudo passwd root
this will prompt you to enter your normal login password

then the system will ask for new set of the password to assign as the sudo password.
Done...

In order to install wifi drivers type, this commands.

this will prompt all the required drivers' list.

sudo ubuntu-drivers list
Will show all the driver packages which apply to your current system. You can then
sudo ubuntu-drivers autoinstall 
to install all the packages you need, or you can do:
sudo ubuntu-drivers devices
to show you which devices need drivers and their corresponding package names.
after identifying the required drivers you can issue the 
sudo apt-get install <driver name>
This will do the trick. Enjoy.

Tuesday, December 12, 2017

Install Packages in Anaconda

Power up the Anaconda prompt with Administrator privileges.

Activate the environment you need to install the package.

activate <your environment name>

then check in the anaconda repo that package is available or not

https://anaconda.org/anaconda/repo

most of the cases you can find the package and on that page, it will mention what is the command that you need to use to install. 

conda install --channel "anaconda" package

cheers enjoy ;)

Saturday, October 7, 2017

Anconda Basics (Tensorflow keras installation in Windows)

Data science is one of the biggest buzz word in tech arena. "Tensorflow" is getting lots of interest and lots of people talking about it. This is simple stepping stone for your data science world exploration. 

First download the Anaconda 
https://www.anaconda.com/download/

select what ever the platform you like to get your hands dirty. 

open Anaconda prompt  as Administrator.


By default there is only one environment is created. "root". Anaconda allows us to create multiple environments with different python or R versions. That is one of the reasons Anaconda is being popular. 

put following command to create a new environment 

conda create -n testing python=3.5



This will install bunch of packages and python as we specified. When I am writing this Tensorflor has some problems with python 3.6 so better to install 3.5. after installation you will get some help about how to activate and deactivate environments. 


There are two ways of installing packages in Anaconda. first method is using command prompt and other one is Anaconda Navigator. 

Open Anaconda Navigator as administrator.


hit refresh button to see whether our newly created environment is created or not. 


select our newly created environment and click Environments in left hand side panel. 




Then you can see all the installed packages in that environment. select "All" from the drop down and search whatever the package that you want to install. 

Installing Tensorflow 

search Tensorflow in the search box. In this particular case Tensorflow have that green check box. That means that, Tensorflow is already installed in the environment. 













 search Tensorflow package and click Tensorflow. This will be indicated by little down side arrow.


click apply button at the bottom of the window. this will install all the required things for Tensorflow.

Testing Tensorflow

In Anaconda there are many editor options. "Spider" is one of the main editors in Anaconda. press install and then you can launch "Spider" by Anaconda.


type following command to test Tensorflow


import tensorflow as tf

hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))

if you get the print statement. You are successfully install Tensorflow.  


Install Keras

Since we did Tensorflow installation in Anaconda Navigator, lets install Keras using command prompt. 

first run the Anaconda prompt as administrator and activate the environment. Otherwise it will installed in root environment. 


activate testing
 conda install mingw libpython


 conda install theano

 conda install --channel https://conda.anaconda.org/conda-forge keras

if you didn't get any errors you are good to go. 
open the spider editor and issue following command.


import tensorflow as tf
from keras import backend
print(backend._BACKEND)
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))


or you can use command prompt to test keras. 


python -c "from keras import backend; print(backend._BACKEND)"


Done ;) enjoy 

Tuesday, September 19, 2017

Visual Studio Not starting correctly

If you experience visual studio is not loading correctly and notify you about a package installation error or package load error

Please open an administrative CMD window and navigate to C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE and run these commands:

1.devenv.exe  /safemode

2.devenv.exe  /resetskippkgs

3.devenv.exe  /installvstemplates

4.devenv.exe  /resetsettings

5.devenv.exe  /resetuserdata

these commands are not related to each other so you can issue one command and check is the problem is solved or not. For my case

devenv.exe  /resetuserdata  This command restart the whole visual studio environment and you need to login to the developer account.

Reference :
link