Mosh Python Cheat Sheet

Posted : admin On 1/2/2022

Cheat Sheet 1: Piazza This 7-page cheat sheet is one to keep handy on the desk when you are first trying to understand OOP in Python. It has full explanations and examples giving you a full scope of classes, inheritance, and naming conventions for best practices. It perfect for beginners and those who need a refresher. Unsafe SSH or Mosh connection (temporary servers: CI) ssh -o ControlMaster=no -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no SERVER with Mosh: Manfred Touron Blog Projects About Wiki Current Status Talks Ideas Now Contact Bookmarks Sponsor Reading List. In case you’re interested, we also have complete cheat sheets for Bootstrap, HTML, CSS, MySQL, and JavaScript. So download a copy of our Python cheat sheet and get that first.py program up and running! PDF Version of Python Cheat Sheet. Python Cheat Sheet (Download PDF) Infographic Version of Python Cheat Sheet (PNG) Python Cheat Sheet. Mosh Hamedani; Mosh Hamedani; Find a course. Programming Languages. Everything you need to program in Python in one course (includes 3 real-world projects)% COMPLETE The Ultimate C# Mastery Series Master C# - one of the world's most versatile programming languages 4 Course Bundle% COMPLETE The Ultimate JavaScript Mastery Series - Part 1.

  1. Python Cheat Sheets Pdf
  2. Mosh Python Cheat Sheet

§SSH / Mosh

©2012-2015 - Laurent Pointal Python 3 Cheat Sheet License Creative Commons Attribution 4 Latest version on. ☝ modules and packages searched in python path.

More SSH awesomeness on https://github.com/moul/awesome-ssh

§SSH or mosh into a host and attach or create a named tmux session

and with mosh

replaces SERVER with your SSH target hostname.

§Unsafe SSH or Mosh connection (temporary servers: CI)

with Mosh:

§Non-interactive SSH with password

§Networking

§Measure network performances and stability with iperf

With

Install:

  • Install on mac with brew install iperf
  • Install on Linux with sudo apt install iperf

TCP test:

  • Run on the server: iperf -s -p 6666
  • Run on the client: iperf -c ${SERVER} -p 6666

UDP test:

  • Run on the server: iperf -s -p 6666 -u
  • Run on the client: iperf -c ${SERVER} -p 6666 -u -b 900m

§traceroute & ping with mytraceroute (mtr)

  • Install on Linux: sudo apt install mtr
  • Usage: mtr ${IP}

Example:

§Find big files & Cleanup space

§Get aggregated sizes of sub-dirs and files

§Find big files

§Cleanup docker

§Git / GitHub

§Git / GitHub essential tools

  • Install “hub” (https://hub.github.com/)
  • Install “refined GitHub” browser extension (https://github.com/sindresorhus/refined-github)

§Do rebase instead of merge when pulling

git config --global pull.rebase true

§GitHub links

Update the following variables when appropriate:

  • USER a GitHub user or organization, i.e.: moul

  • Pull-Requests

    • In any repo of an user/organization: https://github.com/pulls?utf8=%E2%9C%93&q=is%3Aopen+is%3Apr+archived%3Afalse+user%3AUSER
    • Opened by an user: https://github.com/pulls?utf8=%E2%9C%93&q=is%3Aopen+is%3Apr+archived%3Afalse+author%3AUSER
    • Assignee to an user: https://github.com/pulls?utf8=%E2%9C%93&q=is%3Aopen+is%3Apr+archived%3Afalse+assignee%3AUSER
    • Mentioning an user/a team: https://github.com/pulls?utf8=%E2%9C%93&q=is%3Aopen+is%3Apr+archived%3Afalse+mentions%3AUSER
    • Requesting review from an user/a team: https://github.com/pulls?utf8=%E2%9C%93&q=is%3Aopen+is%3Apr+archived%3Afalse+review-requested%3AUSER

§Close a pull request from command line with “hub”

  1. Install “hub”
  2. Type hub api -X PATCH /repos/$USER/$REPO/pulls/$ID -F state=closed

§List projects in JSON

  • Fetch: hub api --paginate user/repos jq . > github.json
  • Only “moul’s” projects: cat github.json jq '.[] select(.owner.login 'moul') > moul.json
  • Remove some fields to have a smaller .json file: cat moul.json jq 'with_entries(select(.key test('_url') not)) del(.owner) del(.permissions) del(.url) del(.node_id)'

Or inline

§Bonus: find and close a pull-request named “Enabled GuardRails” in the current repository

§Manipulate JSON

§Flatten concatenated JSON files

Sometimes, when you run a command like this: hub api --paginate user/repos, you get multiple JSON outputs in the same file.

jq doesn’t care and you can run any jq command over the aggregated file, however, this .json file won’t be supported by most of the other softwares.

You can “repair” by flattening a concatenated JSON file by doing the following:

cat aggregate.json sed 's/^]$$/],/;$$s/],/]]/;1s/^/[/' jq '. add'

The sed ... command will transfer the standalones arrays into a a valid array of arrays.

The jq . add will flatten the array of arrays into a big 1 dimension array.

§Apply change on multiple files

§Replace a string by another in a whole Git repository

I’m using my https://github.com/moul/golang-repo-template project as repo template on GitHub.

The first task I need to do immediately after creating the new repo, is to replace every instance of golang-repo-template in the codebase by lorem-ipsum (the project name).

§Terminator on Windows

  • Install VcXsrv.exe on Windows and configure it to start automatically with the system
  • Create a startTerminator.sh file with the following content: cd; export DISPLAY=:0; nohup terminator &; sleep 1 and change the permissions chmod +x startTerminator.sh
  • Create a shortcut C:WindowsSystem32bash.exe {12345678-1234-5678-0123-456789abcdef} /home/moul/startTerminator.sh

§Web

§Temporary static web server

And then open your browser on http://localhost:8000

§Generate directory listing

§Proxy to avoid caching

§Socat

§Connect to a TTY over TCP

§TCP to UDP proxy

This TCP proxy can be forwarded over SSH to have access to an UDP port from localhost from a remote host

§Media manipulation

Python Cheat Sheets Pdf

§Loop a video with ffmpeg

Mosh Python Cheat Sheet

  1. calculate the amount of loops needed using https://dan.hersam.com/tools/time-calc.html
  2. for i in {1..383}; do printf 'file '%s'n' 'loop1.mp4' >> list.txt; done
  3. ffmpeg -f concat -i list.txt -c copy output.mp4

See this status

§Download YouTube video cover image

  • the image of one video: youtube-dl --write-thumbnail --skip-download https://www.youtube.com/watch?v=xxxxxxxx
  • the image of multiple videos: youtube-dl --write-thumbnail --skip-download -a urls.txt with one URL per line in urls.txt