Thursday, November 16, 2017

How to put a currently running process in foreground to background and detach from ownership

1. Ctrl + Z to stop (pause) the program and get back to the shell.
2. bg to run it in background.
3. disown -h [job-spec] where [job-spec] is the job number (like %1 for the first running job; find about your number with the jobs command) so that the job isn't killed when the terminal closes.
example: disown -h %1

Tuesday, August 15, 2017

How to install python 2 alongside python 3 with conda and install opencv

Create a new environment names pyth2 for installing python2. 

conda create --name pyth2 python=2

 
To check envs:

conda info --envs


After that you can switch environment in conda by:


In Windows: 

activate pyth2

In Linux: 


source activate pyth2
 
Then if you want to install opencv in pyth2 environment, run: 


conda install -c https://conda.anaconda.org/menpo opencv3 

 
To check installation:


import cv2 cv2.__version__

Sunday, June 25, 2017

How to install phpmyadmin in linux

To install phpmyadmin, run the following commands:

sudo apt-get update
sudo apt-get install phpmyadmin

After that if it is still not possible to access phpmyadmin via
http://localhost/phpmyadmin

Add a following  line to a file: /etc/apache2/apache2.conf

Include /etc/phpmyadmin/apache.conf

And restart the server by:

sudo service apache2 restart

Source:https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-phpmyadmin-on-ubuntu-16-04

Monday, June 19, 2017

How to connect to Mariadb with Phpmyadmin

A new debian 9 comes with Mariadb as a substitute of mysql by default. If you don't have the installation of refer to https://mariadb.com/downloads.

Next, you have to install phpmyadmin. Since I am on debian, my command is:

sudo apt-get install phpmyadmin

After that, include the following line in /etc/apache2/apache2.conf.

/etc/phpmyadmin/apache.conf 

Friday, April 21, 2017

How to configure fan in Dell laptop on Debian

For people who run Linux on their dell laptops have a problem that their fan is running noisily all the time. So the fix is to install a tool "i8kutils" which can be used to control fan depending on temperature of CPU.
First make sure that your current user is sudo user and install the tool:

sudo apt-get install i8kutils


Add a line "i8k" in /etc/modules:

sudo vim /etc/modules


Add a line "options i8k force=1" in a new file /etc/modprobe.d/options:

sudo vim /etc/modprobe.d/options


Run:

sudo modprobe i8k force=1


Open a new file called /etc/i8kmon.conf:

sudo vim /etc/i8kmon.conf


Copy the following to it:

# Run as daemon, override with --daemon option
set config(daemon) 0

# Automatic fan control, override with --auto option
set config(auto) 1

# Report status on stdout, override with --verbose option
set config(verbose) 1

# Status check timeout (seconds), override with --timeout option
set config(timeout) 20

# Temperature thresholds: {fan_speeds low_ac high_ac low_batt high_batt}
set config(0) {{-1 0} -1 40 -1 40}
set config(1) {{-1 1} 40 60 40 60}
set config(3) {{-1 2} 60 128 60 128}

# For computer with 2 fans, use a variant of this instead:
# Temperature thresholds: {fan_speeds low_ac high_ac low_batt high_batt}
# set config(0) {{-1 0} -1 52 -1 65}
# set config(1) {{-1 1} 41 66 55 75}
# set config(2) {{-1 1} 55 80 65 85}
# set config(3) {{-1 2} 70 128 75 128}

To run i8kmon daemon on startup, make a new file /etc/init.d/i8kmon:

sudo vim /etc/init.d/i8kmon


Then add the following to it:
(in my case debian-8 jessie, this file was created automatically when the tool was installed)

#!/bin/sh

### BEGIN INIT INFO
# Provides: i8kmon
# Required-Start:
# Required-Stop:
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Dell Inspiron fan/cpu-temperature monitor
### END INIT INFO

# i8kmon Dell Inspiron fan/cpu-temperature monitor
#
# Written by Miquel van Smoorenburg .
# Modified for Debian GNU/Linux
# by Ian Murdock .
#
# Modified for i8kutils by Karl E. Jørgensen ,
# Massimo Dal Zotto and
# Bradley Smith

PATH=/sbin:/bin:/usr/sbin:/usr/bin

. /lib/lsb/init-functions

NAME=i8kmon
DAEMON=/usr/bin/i8kmon
PROC_I8K=/proc/i8k
DESC="Dell Inspiron fan/cpu-temperature monitor"
# DAM orig: "--daemon --nouserconfig"
I8KMON_ARGS="--auto --daemon"
PIDFILE=/var/run/$NAME.pid
ENABLED=0

test -x $DAEMON || exit 5

if [ -f /etc/default/$NAME ] ; then
. /etc/default/$NAME
fi

case "$1" in
start)
if [ "$ENABLED" = 0 ]; then
log_warning_msg "Not starting. Disabled via /etc/default/$NAME."
exit 0
fi
log_daemon_msg "Starting $DESC" "$NAME"
modprobe i8k >/dev/null 2>&1 || true
if [ ! -f "$PROC_I8K" ]; then
log_progress_msg "Could not find $PROC_I8K."
log_end_msg 1
exit 1
fi
start-stop-daemon --start --quiet --pidfile $PIDFILE \
--background --make-pidfile --exec $DAEMON -- $I8KMON_ARGS
log_end_msg $?
;;
stop)
log_daemon_msg "Stopping $DESC" "$NAME"
start-stop-daemon --oknodo --stop --quiet --pidfile $PIDFILE
log_end_msg $?
rm -f $PIDFILE
;;
restart|reload|force-reload)
$0 stop && sleep 2 && $0 start
;;
*)
echo "Usage: $0 {start|stop|restart|reload|force-reload}" >&2
exit 2
;;
esac


then restart the machine.

Tuesday, February 7, 2017

Create a simple Angular 2 project

In the previous post, we installed node.js and npm. They are needed in our next step to create Angular 2 project.
First, we have to install angular-cli, which will be used to create an angular project, using npm.
npm install -g angular-cli
After that using the angular-cli, we can create angular2 project.
ng new your-project-name
And go to the project directory and run the server.
cd your-project-name
ng serve
The first project will be run on http://localhost:4200.

How to install node.js on Linux Mint 18 Sarah

curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs
After that npm is also installed along with node.js. To check version of node write:
node -v
To check npm:
npm
To update npm to the latest version:
sudo npm install npm@latest -g
To fix npm permissions, first, create a folder in current user's home directory. Copy directory path to the newly created folder.
mkdir npm-global
cd npm-global
pwd
Set npm prefix setting to that folder.
npm config set prefix /home/current-user/npm-global
Add path /home/current-user/npm-global/bin to the system PATH settings. Open .profile file.
vi ~/.profile
Add following line to the file
export PATH=$PATH:/home/current-user/npm-global/bin
Reset settings by:
source ~/.profile