Default

Python Code Cookbook

2018-07-01. Category & Tags: Default Python, Reuse, Import, Include

See also:

Pandas #

Get column_nr in pandas/numpy.

if isinstance(X, pd.DataFrame):
    X_is_df = True
    row_nr = X.shape[0]
    column_nr = X.shape[1]
    if isinstance(X.columns, pd.core.index.MultiIndex):
        df_columns_is_multi_index = True
    else:
        df_columns_is_multi_index = False
else: # non-DF
    X_is_df = False
    row_nr = np.shape(X)[0]
    column_nr = np.shape(X)[1]

use dataframe directly against spark #

lib Optimus

from optimus import Optimus
op = Optimus(master="local")
df = op.create.df(<some data>)
...

Sourcing/Importing #

execfile or os.system #

execute the other python file in place:

...

Python Code Reuse

2018-07-01. Category & Tags: Default Python, Reuse, Import, Include

execfile or os.system #

execute the other python file in place:

execfile("/path/to/my/lib/mylib.py")

or:

import os
os.system("python /path/to/my/lib/mylib.py")

import #

import sys 
import os
sys.path.append(os.path.abspath("/path/to/my/lib"))
import mylib

ref #

See other methods here.

Steps to Check Netwok Interface Card (NIC) Configurations

2018-06-13. Category & Tags: Default Network, NIC

UBUNTU 20.04 #

New command: ip & ss.
ubuntu.com

check & setup nic in cli #

check hardware info (canNOT guarantee it is up?):

ethtool -i wlp4s0

config ip & gateway:

ip link set dev wlp4s0 up
dhclient wlp4s0
ip route add 192.168.50.1 dev wlp4s0
ip route add default via 192.168.50.1

UBUNTU 18.04 dated #

Check the physical NIC is connected.

lspci

Note: The NIC will be shown regardless if drivers are installed, this is a PCI feature. Ref.

...

VirtualBox Network and Skills

2018-04-14. Category & Tags: Default VirtualBox, Network

OBS: cloning a VM with the status of pause (not powered-off), it canNOT re-initialize the MAC address. Thus, it is necessary to disconnect the cable and poweroff to re-initialize the MAC and then boot.

INSTALL ON UBUNTU #

Tested on v18.04.

sudo apt-get update && \
sudo apt-get -y install virtualbox

(sometimes, maybe need to prepare the env before installation:)

sudo apt-get update && \
sudo apt-get -y install gcc make linux-headers-$(uname -r) dkms && \
wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -  && \
wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add -  && \
sudo sh -c 'echo "deb http://download.virtualbox.org/virtualbox/debian $(lsb_release -sc) contrib" >> /etc/apt/sources.list'

NICs #

Two NICs are needed BEFORE installing the system to avoid messy issues.

...

Hadoop HDFS

2017-06-19. Category & Tags: Default Hadoop, HDFS

(Update: tested v2.7.2 on Ubuntu 18)

Install #

OBS: security warning ! Note: change the core-site.xml and hdfs-site.xml content before running.
Note: change the HDUSER username before running.

# w/ java
curl https://raw.githubusercontent.com/SunnyBingoMe/install-hadoop/master/setup-hadoop | bash

Env & Hd-Structure Config (Multi-Node Only) #

Make sure the master node and the hadoop user, e.g. $hduser can access work nodes using passphrase-less ssh keys.
If a different username ($hduser) rather than the installer user ($user) is to run hadoop, we need to run setup_profile and setup_environment after su $hduser (some minor errors will be given by bash, no worries.)

...

DHCP

2017-05-16. Category & Tags: Default DHCP, DHCP Server, DHCPD

Install & Basic Config #

install #

sudo apt-get install isc-dhcp-server

interfaces #

vi /etc/default/isc-dhcp-server

INTERFACES="eth0 eth1 eth2"

config network param #

vi /etc/dhcp/dhcpd.conf

# ns servers separated by comma "," ! ! !
option domain-name-servers 10.0.0.1, 10.0.0.2;

# lease time in sec: -1 for infinity.
default-lease-time -1;
max-lease-time -1;

# a very basic subnet declaration:
subnet 10.0.0.0 netmask 255.255.255.0 {
    interface enp0s3; # optional
    range 10.0.0.150 10.0.0.254; # separated by space " "
    option routers 10.0.0.1; # separated by space " "
}

To check DHCP servers:
service isc-dhcp-server status

...

Moving Blog

2016-05-04. Category & Tags: Default Default

Firstly, address changed: DMML.nu

Secondly, reason. I thought high price lead to good service, but I was wrong:

error & reboot

Four days host failure, and I lost all files.

lose files

Fortunately, I have backups.

Besides, wordpress is too heavy, I need a light weighted platform.

g+ digest 更新 2013/07/05

2013-07-05. Category & Tags: Default Default, Music

  • [04.07.2013 21:19 (fr. gplus)]
									[![](https://lh5.googleusercontent.com/proxy/tygbzAPl0Eb07JWuIU15RL63UlG-MAHAFXEDIkCc3nJhXNCmBFRR-d2opHL7KRlb2seb7dNdVwfPmmjve3S4=w125-h125)<p class='attachment_article_content'>Wiktionary RDF extraction. Currently available languages: English, German, French, Russian In the works: Greece, Vietnamese Need data from other languages? Help us creating wrappers for each language editions (if you know Regex, XML and Wiktionary, an initial wrapper can be created in less than ...  

](http://wiki.dbpedia.org/Wiktionary?show_files=1)

Digest powered by RSS Digest

g+ digest 更新 2013/07/02

2013-07-02. Category & Tags: Default Default, Music

  • [01.07.2013 21:38 (fr. gplus)]
									[![](https://lh4.googleusercontent.com/proxy/VS4exI8pbr-l34-G7BGtit8Hv09Y34D3gmiPoZavJmc2MfctTXyTCf0uaXOuxgAJkQxlMxUdfd8_n9FlGt48YCcvnZNYXqPP=w125-h125)<p class='attachment_article_content'>Your News. Delivered. Stay current. Learn. Get inspired.  

](http://cloud.feedly.com/)

  • [digg reader (fr. gplus)]
digg reader
									[![](https://lh3.googleusercontent.com/proxy/kCbGnCgI73O_nJPuYQlDAOKe-rQfO4tJte8riWaBSEmWpky3phC89Y6UCjqpuFn73fvMmusv5gWCPJxxbqU7kxjcBxJJ698=w125-h125)<p class='attachment_article_content'>Welcome to Digg  

](http://digg.com/reader)

  • [21.06.2013 15:21 (fr. gplus)]
									[![](https://lh5.googleusercontent.com/proxy/Ui5a93A3PSZBW4dZ3e53soFUcRU95pxBAxCKN_mtyXM_jSpO74RwkgKnXVbamJeQXZLujRLUwGxLvxkKZhBaTqpP2A=w125-h125)<p class='attachment_article_content'>A collection of some simple plugins and pieces of code.  

](http://welldonethings.com/)

  • [Reshared post from 李俊: (fr. gplus)]
**[Original Post (fr. gplus)] :**

目前找到的看着最舒服的基于twitter bootstrap的tags manager

									[![](https://lh5.googleusercontent.com/proxy/Ui5a93A3PSZBW4dZ3e53soFUcRU95pxBAxCKN_mtyXM_jSpO74RwkgKnXVbamJeQXZLujRLUwGxLvxkKZhBaTqpP2A=w125-h125)<p class='attachment_article_content'>A tags manager or tags handler or tag input helper to manage tags in a form, it's a jquery plugin for bootstrap.  

](http://welldonethings.com/tags/manager)

...