Friday, April 20, 2018

Error: More than one instance of bitcore-lib found

this error was shown when I tried to run bitcored on linux after adding new service which was the bitcore wallet service , the problem happened after each sub module trying to run its own copy of bitcore-lib, the bitcore.node depends on version "bitcore-lib": "^v0.13.19", and the bitcore-wallet-service depends on version "bitcore-lib": "^v0.15.0". So we have to remove one of these dependencies from the package in order to solve this problem:

npm uninstall --prefix /mynode/node_modules/bitcore-wallet-service -S bitcore-lib


Sunday, March 4, 2018

Keep the process of a program running after closing the shell terminal

to keep the process running after the shell terminal close on ubuntu 16.04 use the following
command:

nohup my_command > my.log 2>&1 &

if you don't want to log the output of this command to a log file the replace my.log by
/dev/null, So it will be like the following:

nohup my_command > /dev/null 2>&1 &

if you want to find the process after a while and want to kill the process then, list all
the running processes:

ps -ef

you will find the command in the CMD column of the diplayed list. Now find the process Id from
the PID column and insert the kill command

sudo kill pid

How to Secure your ubuntu server - essential steps




create new user $ adduser username
$ usermod -aG sudo username
$ echo 'username ALL=NOPASSWD ALL' >> /etc/sudoers

$ nano /etc/ssh/sshd_config
change ssh port from 22 to 9022
#Port 22
Port 9122

Disable Root Account
change in /etc/ssh/sshd_config
PermitRootLogin yes
to
PermitRootLogin no


Add firewall rules :
sudo iptables -I INPUT 1 -i lo -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 9122 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 443 -j ACCEPT
sudo  iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
sudo iptables -I INPUT -p udp  --dport 111 -j REJECT
sudo iptables -A INPUT -j REJECT

well be updated later .

Wednesday, February 28, 2018

VirtualBox on Windows 8 VM network settings

On Windows 8 , for VirtualBox virtual machine to communicate with host computer and the world you need to adjust the network parameters. as in the image below





and be sure that interface file in the unix guest set to dhcp .

Friday, December 1, 2017

VirtualBox Cannot ping VM from host - Destination host unreachable.


Virtualbox  on windows host  after create a new virtual machine and choose the network to be bridged , I can reach the world and ping the host machine and the router , but when I try to ping the virtual machine from the hot it respond with "Destination host unreachable".
The solution is simple I was using static IP for the virtual machine , changing the ip on the virtual machine  to be static will solve this issue.

Sunday, November 12, 2017

array_key_exists(): The first argument should be either a string or an integer


array_key_exists(): The first argument should be either a string or an integer In Php when you get this error , that means you are dealing with an Array , and your code trying to get some keys out of this Array, but instead of passing a single parameter (string or an integer) to the function that do the job,you are passing something else.
Example :

$arr = [
'color' => 'Red',
'price' => '50'
]

Now, when you try to check if the color is red you are going to use the code :

if($arr['color'] === 'Red') echo "Red";

and that's ok and no error will be thrown, but the following code:

if($arr['color','price'] === 'Red') echo "Red";

will throw an Error Exception.as the error given above.

Thursday, October 26, 2017

Change all posts permalinks in wordpress when move site from server to server


great trick to change all posts permalinks in wordpress when move site from server to server
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');

UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');

UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');

Reference