Skip to main content

Posts

Atom community packages recommendation for Python development

Below are Atom community packages I installed for Python development. They are covered most of functions u need. Take this post as an backup.  
Recent posts

useful linux commands for pdf editor

pdfunite        pdfunite merges several PDF (Portable Document Format) files in order of their occurrence on command line to one PDF result file. EXAMPLE         pdfunite sample1.pdf sample2.pdf sample.pdf        merges all pages from sample1.pdf and sample2.pdf (in that order) and creates sample.pdf pdftocairo        pdftocairo [options] PDF-file [output-file] DESCRIPTION        pdftocairo  converts Portable Document Format (PDF) files, using the cairo output device of the pop‐pler PDF library, to any of the following output formats: OPTIONS        -png   Generates a PNG file(s)        -jpeg  Generates a JPEG file(s)        -tiff  Generates a TIFF file(s)        -pdf   Generates a PDF file pdfseparate        pdfseparate extract single pages from a Portable Document Format (PDF).        pdfseparate  reads  the  PDF  file PDF-file, extracts one or more pages, and writes one PDF file for each page to PDF-page-pattern, PDF-page-pattern should contain %d.  %d is replaced

How to install 3rd parties modules to Python 3.6

How to work with multiple versions of Python installed in parallel? Python version upgrades quickly, it's caused multiple versions on my Debian OS: Python 2 defaults to 2.7; Python 3 defaults to 3.5, then when I installed Python 3.6. It causes 3rd parties modules import problem in Python 3.6.  Take popular pyperclip as example. When I installed pyperclip module, which is popular one to copy/paste clipboard content, in bash with:  pip3 install pyperclip  It prompts install successful, but prompt error when I import in Python 3.6.  >>> import pyperclip Traceback (most recent call last): File "<pyshell#0>", line 1, in <module> import pyperclip ModuleNotFoundError: No module named 'pyperclip' The reason is the default Python 3 is 3.5 i/o 3.6. Install with pip3 will point to 3.5 directly. So solved it, install as following:  peter@Debian:~$ python3.6 -m pip install pyperclip Docs Refer: https://docs.python.org/3/installin

Solve Chrome doesn't allowed to install crx extension

The latest Chrome doesn't allowed user to install crx extension directly and request to install from Chrome web store, we can decompress the crx file to zip folder or download zip file for instead. Below Tunnel-Switch example will teach you how to pass it: Download Tunnel-Switch zip file:  https://github.com/oylbin/tunnel-switch Decompress zip file Chrome-->more tools-->extensions-->tick 'Developer mode'-->Load unpacked extension Browse to decompress zip folder to load Pass, click option to setup Remarks: For other extensions, when you load it, it'll prompt ''manifest_version'' should be 2 problem, you can refer below manifest.jason file to add red line to try. { " name " : " TunnelSwitch " , " version " : " 1.0.4 " , " manifest_version " : 2 , " description " : " cycle through your proxy settings " , " icons " : { " 128

Upgrade BeautifulSoup4 to compatible with Python 3.6

After upgraded to Python 3.6 from 3.5, I encountered BeautifulSoup (bs4) error, such as 'ImportError: cannot import name 'HTMLParseError'. Seems there's compatible problem for BeautifulSoup 4 version. Solution: Upgrade beautifulsoup 4 version to 4.6.0 Commands: $ pip3 install --upgrade beautifulsoup4 Deep in: Install pip3 command: $ sudo apt install python3-pip

Simulate browser to solve https 403 error

As more and more website use https instead of http, we'll encounter 403 error when get content with requests modules. To solve it, the easiest way is simulating browser to access. OS: Debian 9 Python: 3.5.3 Module: requests setup headers as 1st step: headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3)\            AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.81 Safari/537.36'} then add headers as parameter: res = requests.get(xqurl, headers=headers) Below is my example to get stock price in dictionary from a https website: getStockPriceFromXueqiu.py

Linux command to translate DomainName to IP

To translate Domain name to IP address, there are 2 commands in Linux: 1. dig +short [Domain name] eg: $ dig +short google.com 216.58.197.142 2. nslookup [Domain name] eg:$ nslookup google.com Server:         172.31.0.2 Address:        172.31.0.2#53 Non-authoritative answer: Name:   google.com Address: 172.217.26.14