Linux or Mac, List of the Port occupation

Mac, List of the Port occupation lsof -iTCP -sTCP:LISTEN -n -P Usage of lsof command, for the port management | | 10 lsof Command Examples in Linux: lsof meaning ‘LiSt Open Files’ is used to find out which files are open by which process. One of the reason to use lsof command is when a disk cannot be unmounted as it says the files are being used. Or some port is occupied. 1. List all Open Files with lsof Command In the below example, it will show long listing of open files some of them are extracted for better understanding which displays the columns like Command, PID, USER, FD, TYPE etc.

READ MORE

concatenate of numpy

You may first use np.concatenate >>> a = np.array([[1, 2], [3, 4]]) >>> b = np.array([[5, 6]]) >>> np.concatenate((a, b), axis=0) array([[1, 2], [3, 4], [5, 6]]) >>> np.concatenate((a, b.T), axis=1) array([[1, 2, 5], [3, 4, 6]]) >>> np.concatenate((a, b), axis=None) array([1, 2, 3, 4, 5, 6]) Don’t forget np.append: np.append is usually used for concatenating vectors: Examples >>> >>> np.append([1, 2, 3], [[4, 5, 6], [7, 8, 9]]) array([1, 2, 3, ..., 7, 8, 9]) When axis is specified, values must have the correct shape.

READ MORE

Configure ssl+Nginx (secure socket.io connection)

secure the nodejs app transmissions by ssl For quick reference: Deploy simple_socket_chat on fresh VPS, jump to buttom of this article 1. make a simplest socket.io app ref: https://socket.io/get-started/chat/ basic nodejs app: use the Node.JS web framework express to html as client end. create a package.json manifest file that describes our project npm install express@4.15.2 create an index.js file that will setup our application The index.js file supply the html content of “Hello world”. create a index.html file and modify the index.

READ MORE

nginxBasic: Set up server blocks on CentOS 7

Set Up Nginx Server Blocks on CentOS 7 NginxCentOS By Josh Barnett Published on November 5, 2014 Introduction Nginx uses server blocks to manage configurations. Server blocks allow one server to host multiple domains or interfaces. How to serve different content to different visitors depending on which domains they are requesting: Prerequisites access to centos7 server, has sudo privileges. Nginx installed. Before you begin with this guide, there are a few steps that need to be completed first. You will need access to a CentOS 7 server with a non-root user that has sudo privileges.

READ MORE

Flask on Google Colab, A free web app server

Flask on Google Colab Colab is strong and famous by its support of GPU/TPU. However, with Flask, it can be a web app server. That’s very cool! Ngrok Expose the localhost to a public temporary url that can be shared with all around the world. That’s so cool! But how? Flask on Google Colab: https://medium.com/@kshitijvijay271199/flask-on-google-colab-f6525986797b Transform Google Colab to a GPU instance with full SSH access: https://imadelhanafi.com/posts/google_colal_server/ Flask Chatroom on Colab: https://colab.research.google.com/github/shanaka-desoysa/shanaka-desoysa.github.io/blob/source/content/flask/Flask_Chat_Colab.ipynb#scrollTo=Hmx5lVRRa2Hq about the no-token ngrok test: no-token ngrok: https://dl.equinox.io/ngrok/ngrok/stable 1 Download: wget https://bin.

READ MORE

手把手教你搭建一个GAN(生成对抗网络)模型

手把手教你搭建一个GAN(生成对抗网络)模型 这个教程用 Keras 实现一个简单的GAN (生成对抗网络)模型. 基于这个:mnistGAN项目,我们将用到Keras 这个python 库。 将用到的python packages: keras: 神经网络模型相关 matplotlib: 画图 tensorflow: keras运行基础 tqdm: 进度条 Talk is cheap, show me the code. 1. 导入包: import os import numpy as np import matplotlib.pyplot as plt from tqdm import tqdm from keras.layers import Input # input layer from keras.models import Model, Sequential from keras.layers.core import Dense, Dropout from keras.layers.advanced_activations import LeakyReLU from keras.datasets import mnist from keras.optimizers import Adam from keras import initializers 2. 定义几个变量: # Let Keras know that we are using tensorflow as our backend engine os.

READ MORE

[转]Python 解析 PDF 文本和表格的四大方法介绍

Python 解析 PDF 文本和表格的四大方法介绍 == code for paper and NSFC Proj. parsing==: https://gitee.com/sonica/pdf_parsing 看到一个不错的知识文章,和大家分享一下: 很多文件为了安全都会存成 PDF 格式,比如有的论文、技术文档、书籍等等,程序读取这些文档内容带来了很多麻烦。Python 目前解析 PDF 的扩展包有很多,这里将对比介绍 PyPDF2、pdfplumber、pdfminer3k 以及 Camelot,告诉你哪个是好用的 PDF 解析工具。 本文使用的案例 PDF 文档下载链接: 链接: https://pan.baidu.com/s/1zH7vY47AqBYKM0XbdABbUA 提取码:xhem 另外,获取 PDF 文档之后,会发现 PDF 文档中的换行符是以行的位置相同的,而不是跟段落相同。 1. PyPDF2 解析 PDF 文档 这里主要参考了 2019-03-07,Usman Malik 写的一篇文章: Python for NLP: Working with Text and PDF Files 使用 Python 安装 PyPDF2 扩展包: pip install PyPDF2 #---------OR conda install -c conda-forge pypdf2 读取 PDF 文件 import PyPDF2 path = r"****.pdf" #使用open的‘rb’方法打开pdf文件(这里必须得使用二进制rb的读取方式) mypdf = open(path,mode='rb') #调用PdfFileReader函数 pdf_document = PyPDF2.

READ MORE

Storage Location for Unpacked Chrome Extensions

Storage Location for Unpacked Extensions Extension engine does not explicitly change their location or add a reference to its local paths, they are left in the place where there are selected from in all Operating Systems. Ex: If i load a unpacked Extension from E:\Chrome Extension the unpacked Extension is still in the same location Storage Location for Packed Extensions Navigate to chrome://version/ and look for Profile Path, it is your default directory and Extensions Folder is where all the extensions, apps, themes are stored

READ MORE

node2vec 调节不同节点的pq值

要对不同节点配置不同的pq值,需要sampling_strategy这个参数配合。通过dict_my_strategy传入一个字典即可。 import networkx as nx import matplotlib.pyplot as plt from node2vec import Node2Vec G = nx.les_miserables_graph() # nx.draw_networkx(G, with_labels=True) # draw the graph, simplest way. # nx.draw_spring(G, with_labels = True) # plt.show() dict_my_strategy = {'Myriel':{'p':10, 'q':0.1}} # use this dict to regulate the p,q for specific nodes. print(' walking...') node2vec = Node2Vec(G, dimensions=16, walk_length=20, num_walks=10, p=1, q=1, workers=1, sampling_strategy=dict_my_strategy) # Embed nodes print(' training...') model = node2vec.fit(window=4, min_count=1)

READ MORE