Python Code Cookbook

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

See also: LearnPython, the Language 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/") or: import os os.system("python /path/to/my/lib/") 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. 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 dev wlp4s0 ip route add default via 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. ...

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. ...

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 | 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. ...


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,; # lease time in sec: -1 for infinity. default-lease-time -1; max-lease-time -1; # a very basic subnet declaration: subnet netmask { interface enp0s3; # optional range; # separated by space " " option routers 10. ...

Moving Blog

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

Firstly, address changed: Secondly, reason. I thought high price lead to good service, but I was wrong: Four days host failure, and I lost all 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)] [![](<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 ... ]( 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)] [![](<p class='attachment_article_content'>Your News. Delivered. Stay current. Learn. Get inspired. ]( [digg reader (fr. gplus)] digg reader [![](<p class='attachment_article_content'>Welcome to Digg ]( [21.06.2013 15:21 (fr. gplus)] [![](<p class='attachment_article_content'>A collection of some simple plugins and pieces of code. ]( [Reshared post from 李俊: (fr. gplus)] **[Original Post (fr. gplus)] :** 目前找到的看着最舒服的基于twitter bootstrap的tags manager [![](<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. ...