
Tipps und Tricks für Entwickler und IT-Interessierte
iPython ist ein Kommandozeileninterpreter zum interaktiven Arbeiten mit der Programmiersprache Python.
$ virtualenv --python python3 jupyter $ cd jupyter $ . bin/activate $ pip install --upgrade pip $ pip install jupyter
Finally run jupyter
jupyter notebook
$ virtualenv --python python3 anaconda $ cd anaconda $ . bin/activate $ wget https://repo.continuum.io/archive/Anaconda3-4.3.1-Linux-x86_64.sh | bash
jupyter notebook
Remove lines with special pattern
$ perl -ni -e 'print unless /pattern/' /path/to/filename
exec sudo -i killall -u [oldname] id [oldname] usermod -l [newname] [oldname] groupmod -n [newname] [oldname] usermod -d /home/[newname] -m [newname] usermod -c "[full name (new)]" [newname] id [newname]
The systemctl
isolate is temporary way. To make it permanent you have to use systemctl
set-default as shown below:
sudo systemctl set-default multi-user.target
and reboot.
To revert graphical session use
sudo systemctl set-default graphical.target
apt-get update | refresh available updates |
apt-get upgrade | upgrade with package replacements; |
apt-get dist-upgrade | upgrade Ubuntu version |
apt-get install pkg | install pkg |
apt-get purge pkg | uninstall pkg |
apt-get autoremove | Remove obsolete packages |
apt-get -f install | try to fix broken packages |
dpkg -i pkg.deb | install file pkg.deb (file) |
dpkg --configure -a | try to fix broken packages |
ls_release -a | Find out used version |
Virtuelle Umgebung stellen eigenständige Umgebungen dar, in denen Programme und Pakete installiert/modifiziert werden können ohne die Betriebssystemumgebung zu verändern.
Dadurch können zum Beispiel andere Versionen von Python oder von Python-Modulen getestet werden.
Technisch gesehen ist eine virtuelle Umgebung ein Verzeichnis, in dem die gewünschten Pakete und Programme bzw. die gewünschte Python-Version installiert ist. Entsprechend werden die notwendigen Umgebungsvariablen modifiziert: PATH, PYTHONLIB, …
Zur Unterstützung von virtuellen Umgebungen gibt es mehrere Programme/Pakete
➜ python -m venv .venv ➜ pip -V pip 21.2.4 from D:\python\venv\lib\site-packages\pip (python 3.9) ➜ & .\.venv\Scripts\Activate.ps1 ➜ pip -V pip 21.1.3 from d:\venv\.venv\lib\site-packages\pip (python 3.9)
Installation
$ pip install poetry
$ poetry new app Created package app in app $ cd app $ tree . . ├── README.rst ├── app │ └── __init__.py ├── pyproject.toml └── tests ├── __init__.py └── test_app.py 2 directories, 5 files
$ poetry config virtualenvs.create true --local $ poetry config virtualenvs.in-project true --local
$ tree . . ├── README.rst ├── app │ └── __init__.py ├── poetry.toml ├── pyproject.toml └── tests ├── __init__.py └── test_app.py 2 directories, 6 files
Inhalt der Projektdatei poetry.toml
[virtualenvs] create = true in-project = true
➜ poetry install Updating dependencies Resolving dependencies... Writing lock file Package operations: 10 installs, 0 updates, 0 removals • Installing pyparsing (2.4.7) • Installing atomicwrites (1.4.0) • Installing attrs (21.2.0) • Installing colorama (0.4.4) • Installing more-itertools (8.8.0) • Installing packaging (21.0) • Installing pluggy (0.13.1) • Installing py (1.10.0) • Installing wcwidth (0.2.5) • Installing pytest (5.4.3) Installing the current project: app (0.1.0)
$ tree . . ├── README.rst ├── app │ └── __init__.py ├── poetry.lock ├── poetry.toml ├── pyproject.toml └── tests ├── __init__.py └── test_app.py
$ brew install pyenv-virtualenv
Anpassen der Bash Startdatei .bashrc
if which pyenv-virtualenv-init > /dev/null; then eval "$(pyenv virtualenv-init -)" fi
Auflisten aller zur Verfügung stehenden Python Versionsn
$ pyenv install --list
Installation einer Python Version
pyenv install 3.7.2
Auflisten aller installierten Versionen
$ pyenv versions * system (set by /Users/<your username>/.pyenv/version) 2.7.14 3.7.1 3.7.2
# Python 2 $ pyenv virtualenv 2.7.14 venv
# Python 3 $ pyenv virtualenv 3.7.2 venv
Umgebungen anzeigen: die letzen beiden Zeilen zeigen die soeben eingerichtete Umgebung an
$ pyenv versions * system (set by /Users/RalphG/.pyenv/version) 2.7.14 3.7.1 3.7.2 3.7.2/envs/venv venv
Alternativ: nur die virtuellen Umgebungen anzeigen
$ pyenv virtualenvs
Umgebung aktivieren / deaktivieren
$ pyenv activate <name> $ pyenv deactivate
$ which python ~/pkg.virtualenv/bin/python
$ pip install virtualenv
Feststellen des Pfades der gewünschten Python Version
Python 2
$ which python2 /usr/local/bin/python2
Python 3
$ which python3 /usr/local/bin/python3
Einrichten der virtuellen Umgebung
Python 2
$ virtualenv venv2 --python /usr/local/bin/python2
Python 3
$ virtualenv venv3 --python /usr/local/bin/python3
Update all Python packages
pip3 list| cut -f1 -d' '|xargs -I {} pip3 install {} --upgrade
def tracefunc(frame, event, arg, indent=[0]): if event == "call": indent[0] += 2 print "-" * indent[0] + "> call function", frame.f_code.co_name elif event == "return": print "<" + "-" * indent[0], "exit function", frame.f_code.co_name indent[0] -= 2 return tracefunc import sys sys.settrace(tracefunc) main()
I just want to learn and work with a new technology, so I bought a 3D printer based on an Arduino Mega 2560. (More on this in the following Blog entry)
To be prepared with the Arduino, I want to play with it. So I started with a starter kit and a sensor kit from elegoo.com
Set / Kit for Arduino MEGA2560
Most complete Ultimate Starter Kit with German tutorial, MEGA2560 R3 Microcontroller and many additional for the Arduino Mega2560 R3
After installing and setting up everything, I started with my first small project: Measure the distance with a sonic sensor and display it through an LCD panel:
1 x MEGA2560 R3 Mikrocontroller
1 x MB-102 Versuchsaufbau
1 x Prototyp-Erweiterungsplatine
1 x LCD1602 Anzeige(mit Pin Header)
1 x DHT11 Modul
1 x Joystick-Modul
1 x 5V Relais
1 x Schallsensor-Modul
1 x DS3231 Echtzeituhren-Modul
1 x Drehgeber modul
1 x Membranschalter-Modul
1 x Versuchsaufbau
1 x HC-SR501 PIR-Modul
1 x ADXL335 Modul
1 x MAX7219 Modul
1 x Wasserfüllstanderkennung-Sensormodul
1 x RC522 RFID-Modul
1 x Servomechanismus (SG90)
1 x Schrittmotor
1 x ULN2003 Schrittmotor-Treibermodul
1 x Power Supply Module
1 x Ultraschall-Sensor-Modul
1 x IR-Empfängermodul
1 x IR-Fernbedienung
1 x 3V Gleichstrommotor
1 x USB Kabel
1 x 65 M-M Kabel
1 x 10 Female-to-Male Kabel
1 x 9 V Akku mit DC
1 x 9 V 1 A Netzteil
1 x Kugelschalter
1 x Segmentanzeige
1 x 4-stellige 7-Segmentanzeige
1 x IC L293D
1 x IC 74HC595
1 x Aktiver Summer
1 x Passiver Summer
2 x Potentiometer
1 x Thermistoren
5 x Diode Rectifier (1N4007)
5 x NPN Transistor (pn2222)
5 x NPN Transistor (S8050)
2 x Fotozelle
5 x 22pF Keramikkondensator
5 x 104pF Keramikkondensator
2 x Elektrolytkondensator (10uF 50 V)
2 x elektrolytischen Kondensator (100uF 50 V)
1 x RGB LED
5 LEDs, jeweils in weiß, gelb, blau, grün, rot
5 x Druckschalter
10 Widerstände (Ohm): 10, 100, 220, 330, 1k, 2k, 5k1, 10k, 100k, 1m
1 x JoystickModule
1 x RelayModule
1 x Rotary EncoderModule
1 x DS-3231 RTC Module
1 x Ultrasonic SensorModule
1 x HC-SR501 PIR sensor Module
1 x Flame SensorModule
1 x Linear HallModule
1 x Metal TouchModule
1 x Digital TemperatureModule
1 x Big SoundModule
1 x Small SoundModule
1 x RGB LEDModule
1 x SMD RGBModule
1 x Two-tone ColorModule
1 x 7 Color FlashModule
1 x Laser EmitModule
1 x ShockModule
1 x IR ReceiverModule
1 x IR EmissionModule
1 x Tilt SwitchModule
1 x ButtonModule
1 x Active BuzzerModule
1 x Passive BuzzerModule
1 x 18B20 tempModule
1 x Photo-resistorModule
1 x Temperature and HumidityModule
1 x GY-521 Module
1 x Photo-interrupterModule
1 x Tap ModuleModule
1 x Membrane SwitchModule
1 x AvoidanceModule
1 x TrackingModule
1 x Magnetic SpringModule
1 x Water Lever Sensor
1 x Power Supply Module
1 x LCD1602 Module (with pin header)
$
$ npm install --save-dev @ionic/app-scripts@latest
$ npm install --save-dev @ionic/app-scripts@latest
$ npm install --save-dev @angular/tsc-wrapped@latest
$ npm install --save-dev @angular/compiler-cli@latest
Read here for details
$ npm install ios-sim@latest
Or edit line 283 in file lib.js and follow https://github.com/phonegap/ios-sim/pull/213/files
vi platforms/ios/cordova/node_modules/ios-sim/src/lib.js
Change to
list.push(util.format('How to fix Error: spawn EACCES
$ ionic hooks add