[Python]websocket的小型伺服器的簡例

安裝:

#git clone https://github.com/Pithikos/python-websocket-server
下載到目錄中

系統需要使用websocket模組:
sudo apt-get install python3-websocket

設定:

在server.py 裡改這一行,讓大家可以連線進來 WebsocketServer(PORT,”0.0.0.0″)

使用:

python3 server.py

 

程式位置:

https://github.com/Pithikos/python-websocket-server

 

 

 

ubuntu 18.04 youtube-dl not work

最近想要把自己家裡的音樂機器人升級一下,發現了居然已經不會自動下載Youtube的音樂檔了,測試了一下才發現youtube-dl好像已經失效了,果然Google Youtube 不是省油的GOOGLE,只好再把 Youtube-DL 下載最近的版本.

 

要將youtube升級到最新版本:

sudo pip3 install –upgrade youtube-dl


 

安裝SCRATCH 2.0的方法 18.04 UBUNTU

安裝SCRATCH 2.0 OFFLINE在UBUNTU 18.04

# install necesary i386 libraries
sudo apt-get install libgtk2.0-0:i386 libstdc++6:i386 libxml2:i386 libxslt1.1:i386 libcanberra-gtk-module:i386 gtk2-engines-murrine:i386 libqt4-qt3support:i386 libgnome-keyring0:i386 libnss-mdns:i386 libnss3:i386

sudo ln -s /usr/lib/i386-linux-gnu/libgnome-keyring.so.0 /usr/lib/libgnome-keyring.so.0
sudo ln -s /usr/lib/i386-linux-gnu/libgnome-keyring.so.0.2.0 /usr/lib/libgnome-keyring.so.0.2.0

wget http://airdownload.adobe.com/air/lin/download/2.6/AdobeAIRSDK.tbz2
sudo mkdir /opt/adobe-air-sdk
sudo tar jxf AdobeAIRSDK.tbz2 -C /opt/adobe-air-sdk


wget https://aur.archlinux.org/cgit/aur.git/snapshot/adobe-air.tar.gz
sudo tar xvf adobe-air.tar.gz -C /opt/adobe-air-sdk
sudo chmod +x /opt/adobe-air-sdk/adobe-air/adobe-air

https://scratch.mit.edu/scratch2download/
sudo mkdir /opt/adobe-air-sdk/scratch
wget https://scratch.mit.edu/scratchr2/static/sa/Scratch-456.0.1.air
sudo cp Scratch-456.0.1.air /opt/adobe-air-sdk/scratch/
cp Scratch-456.0.1.air /tmp/
cd /tmp/
unzip /tmp/Scratch-456.0.1.air
sudo cp /tmp/icons/AppIcon128.png /opt/adobe-air-sdk/scratch/scratch.png

Create launcher:

$ cat << _EOF_ > /usr/share/applications/Scratch2.desktop
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Exec=/opt/adobe-air-sdk/adobe-air/adobe-air /opt/adobe-air-sdk/scratch/Scratch-456.0.1.air
Icon=/opt/adobe-air-sdk/scratch/scratch.png
Terminal=false
Name=Scratch 2
Comment=Programming system and content development tool
Categories=Application;Education;Development;ComputerScience;
MimeType=application/x-scratch-project
_EOF_

$ chmod +x /usr/share/applications/Scratch2.desktop

And that’s it. First run is a little bit longer, as the Air is unpacking Scratch 2 application to ~/.appdata/edu.media.mit.Scratch2Editor folder.

原文:

https://askubuntu.com/questions/913892/how-to-install-scratch-2-on-ubuntu-16-10-or-17-04-64bit

Jupyter-設定密碼開放外部連接和密碼

Jupyter-設定密碼:
#以下先在JUPYTER中執行後產出密碼
from notebook.auth import passwd
passwd()

c.NotebookApp.notebook_dir = ‘/home/pi/project’

c.NotebookApp.open_browser = False

c.NotebookApp.ip = ‘*’
c.NotebookApp.password = ‘sha1:2fcf50cbab99:9f4273b304cca073073808e5f7678964d4bc4c49’

Jupyter 安裝Python2和Python3一起使用

安裝 install並且開放可以連線的ip

sudo apt-get install jupyter-notebook

jupyter-notebook –generate-config

vi /home/pi/.jupyter/jupyter_notebook_config.py

 

最近開始使用JUPYTER,但之前都學PYTHON2,

所以要幫原來的PYTHON3的版本裝上PYTHON2的支援.

python2 -m pip install ipykernel

python2 -m ipykernel install –user

 

Github放在這裡:

https://github.com/jacch/jupyternbonrpi

 

Jupyter-設定密碼:
#以下先在JUPYTER中執行後產出密碼
from notebook.auth import passwd
passwd()

c.NotebookApp.notebook_dir = ‘/home/pi/project’

c.NotebookApp.open_browser = False

c.NotebookApp.ip = ‘*’
c.NotebookApp.password = ‘sha1:2fcf50cbab99:9f4273b304cca073073808e5f7678964d4bc4c49’