Wednesday, December 28, 2016

The secondary network interface did not show up

The secondary network interface did not show up

Find out the subnet mask:

/bin/ipcalc --netmask 172.31.26.153/20

Initialize the secondary:

# ifconfig eth1 172.31.26.153 netmask 255.255.240.0

Edit interfaces setting:

# vi /etc/network/interfaces

# The primary network interface
auto eth0
iface eth0 inet dhcp
post-up ip route add default via 10.0.0.1 dev eth0 tab 1
post-up ip rule add from 10.0.0.170/32 tab 1 priority 500

auto eth1
iface eth1 inet dhcp
post-up ip route add default via 10.0.0.1 dev eth1 tab 2
post-up ip rule add from 10.0.0.190/32 tab 2 priority 600

Restart network:

# /etc/init.d/networking restart

Reference:

http://work.allaboutken.com/node/21

Sunday, December 25, 2016

How to find which Linux distribution is being used

# awk -F '=' '/^ID=/ {print $2}' /etc/os-release | tr -d '"'

or

# awk -F '=' '/^ID=/ {print $2}' /etc/os-release | sed -e 's/"//g'

or

# awk -F '=' '/^ID=/ {print $2}' /etc/os-release | awk -F'"' '{print $2}'





Install Drupal 8

Install Drupal 8

# export DRUPAL_VERSION=8.2.4

Note: another way: DRUPAL_VERSION=8.2.4; export DRUPAL_VERSION

# export DRUPAL_MD5=288aa9978b5027e26f20df93b6295f6c

Note: another way: DRUPAL_MD5=288aa9978b5027e26f20df93b6295f6c; export DRUPAL_MD5

# curl -fSL "https://ftp.drupal.org/files/projects/drupal-${DRUPAL_VERSION}.tar.gz" -o drupal.tar.gz \
&& echo "${DRUPAL_MD5} *drupal.tar.gz" | md5sum -c - \
&& tar -xz --strip-components=1 -f drupal.tar.gz \
&& rm drupal.tar.gz \
&& chown -R www-data:www-data sites modules themes

# unset DRUPAL_VERSION
# unset DRUPAL_MD5
# env

Wednesday, December 21, 2016

Tuesday, December 20, 2016

Remove all dangling (orphan) images

Remove all dangling (orphan) images:

# docker rmi $(docker images -q -f dangling=true)

Remove all dangling (orphan) volumes

Remove all dangling (orphan) volumes:

# docker volume ls -q -f dangling=true
# docker volume rm $(docker volume ls -q -f dangling=true)

Remove all your stopped containers

Remove all your stopped containers:

# docker rm -v $(docker ps -aq -f status=exited)

Note: -v argument will remove the volumes associated with the container that aren't referenced by other containers.

Stop all running containers

Stop all running containers:

# docker stop $(docker ps -q)

Saturday, December 3, 2016

LINQ LIMIT

LINQ LIMIT

optArr.Where(d => d.IsSelected == true).Select(d => d.ID).Skip(0).Take(1).FirstOrDefault();

Friday, December 2, 2016

listen to MouseOver event

listen to MouseOver event

public MainWindow()
{
    InitializeComponent();

    StackPanel stackpanel = new StackPanel(); 
    stackpanel.MouseEnter += new MouseEventHandler(stackpanel_MouseEnter);
    stackpanel.MouseLeave += new MouseEventHandler(stackpanel_MouseLeave);
}

void stackpanel_MouseLeave(object sender, MouseEventArgs e)
{
    StackPanel stackpanel = (StackPanel)sender;
    stackpanel.Background = Brushes.Transparent;
}

void stackpanel_MouseEnter(object sender, MouseEventArgs e)
{
    StackPanel stackpanel = (StackPanel)sender;
    stackpanel.Background = Brushes.LightGray;
}

Reference:

http://stackoverflow.com/questions/10184551/stackpanel-highlight-on-mouse-over-from-code-behind