Skip to content

Instantly share code, notes, and snippets.

View dunderrrrrr's full-sized avatar
🦄

Emil dunderrrrrr

🦄
View GitHub Profile
@dunderrrrrr
dunderrrrrr / python-virtualenv.md
Last active January 27, 2022 11:12
virtualenv is a tool to create isolated Python environments.

virtualenv

virtualenv is a tool to create isolated Python environments.

https://pypi.org/project/virtualenv/#description

virtualenvwrapper

virtualenvwrapper is a set of extensions to Ian Bicking’s virtualenv tool. The extensions include wrappers for creating and deleting virtual environments and otherwise managing your development workflow, making it easier to work on more than one project at a time without introducing conflicts in their dependencies.

https://virtualenvwrapper.readthedocs.io/en/latest/

@dunderrrrrr
dunderrrrrr / python-requests.md
Created February 21, 2020 13:31
The requests library is the de facto standard for making HTTP requests in Python.

The requests library is the de facto standard for making HTTP requests in Python. It abstracts the complexities of making requests behind a beautiful, simple API so that you can focus on interacting with services and consuming data in your application.

https://realpython.com/python-requests/

$ pip install requests

GET

@dunderrrrrr
dunderrrrrr / install-pelican-on-ubuntu1804.md
Created February 21, 2020 13:32
Pelican is a static site generator that requires no database or server-side logic.

Pelican is a static site generator that requires no database or server-side logic.

Pelican currently runs best on Python 2.7.x; earlier versions of Python are not supported. There is provisional support for Python 3.3+, although there may be rough edges, particularly with regards to optional 3rd-party components. However, it sure does work with 3.6.

Set up Pelican

Create a user and virtualenv

$ sudo adduser pelican
$ sudo su - pelican
@dunderrrrrr
dunderrrrrr / how-to-beautifulsoup.md
Created February 21, 2020 13:33
Beautiful Soup is a Python library for pulling data out of HTML and XML files.

Beautiful Soup is a Python library for pulling data out of HTML and XML files. It works with your favorite parser to provide idiomatic ways of navigating, searching, and modifying the parse tree. It commonly saves programmers hours or days of work.

Create virtualenvs and install bs4

$ mkvirtualenv --python=/usr/bin/python3 bs4test
(bs4test)$ pip install beautifulsoup4
(bs4test)$ pip install requests

The following will print the entire page in HTML as an bs4-object.

@dunderrrrrr
dunderrrrrr / ubuntu-netplan.md
Created February 21, 2020 13:34
Netplan is a utility for easily configuring networking on a linux system.

Netplan is a utility for easily configuring networking on a linux system. You simply create a YAML description of the required network interfaces and what each should be configured to do. From this description Netplan will generate all the necessary configuration for your chosen renderer tool.

Netplan reads network configuration from /etc/netplan/*.yaml which are written by administrators, installers, cloud image instantiations, or other OS deployments. During early boot, Netplan generates backend specific configuration files in /run to hand off control of devices to a particular networking daemon.

Example Static IP

network:
  version: 2
  renderer: networkd
 ethernets:
@dunderrrrrr
dunderrrrrr / pihole-on-ubuntu-1804-nginx.md
Last active February 21, 2020 13:36
Pihole is an incredible easy to use and install AdBlocking Server with an easy to use web interface.

Pihole is an incredible easy to use and install AdBlocking Server with an easy to use web interface. PiHole works by replacing your current DNS server and uses multiple blocklists to block malicious DNS queries and AD Sites.

Begin setting your server on a static IP, guide here.

Install PiHole

$ git clone --depth 1 https://github.com/pi-hole/pi-hole.git Pi-hole
$ cd Pi-hole/automated\ install/
$ ./basic-install.sh
@dunderrrrrr
dunderrrrrr / certbot-for-nginx.md
Created February 21, 2020 13:35
Certbot is a free, open source software tool for automatically using Let’s Encrypt certificates.

Certbot is a free, open source software tool for automatically using Let’s Encrypt certificates on manually-administrated websites to enable HTTPS.Certbot is made by the Electronic Frontier Foundation (EFF), a 501(c)3 nonprofit based in San Francisco, CA, that defends digital privacy, free speech, and innovation.

Installing

$ sudo apt-get update
$ sudo apt-get install software-properties-common
$ sudo add-apt-repository universe
$ sudo add-apt-repository ppa:certbot/certbot
$ sudo apt-get update
@dunderrrrrr
dunderrrrrr / micro-editor.md
Created February 21, 2020 13:37
Micro is a terminal-based text editor that aims to be easy to use and intuitive.

Micro is a terminal-based text editor that aims to be easy to use and intuitive, while also taking advantage of the full capabilities of modern terminals. It comes as one single, batteries-included, static binary with no dependencies, and you can download and use it right now.

Installing

Install micro.

snap install micro --classic
@dunderrrrrr
dunderrrrrr / ubuntu-firewall-ufw.md
Created February 21, 2020 13:37
The default firewall configuration tool for Ubuntu is ufw.

The default firewall configuration tool for Ubuntu is ufw. Developed to ease iptables firewall configuration, ufw provides a user friendly way to create an IPv4 or IPv6 host-based firewall. By default UFW is disabled.

Gufw is a GUI that is available as a frontend.

ufw [--dry-run] enable|disable|reload
ufw [--dry-run] default allow|deny|reject [incoming|outgoing]
ufw [--dry-run] logging on|off|LEVEL
    toggle logging. Logged packets use the LOG_KERN syslog facility. Systems configured for rsyslog
    support may also log to /var/log/ufw.log. Specifying a LEVEL turns logging on for the specified LEVEL.
@dunderrrrrr
dunderrrrrr / python-script-to-service.md
Created February 21, 2020 13:38
Two ways of doing it. Using `supervisord` or `systemd`, well probably more, but this is easy.

Two ways of doing it. Using supervisord or systemd, well probably more, but this is easy.

supervisord

Supervisor is a client/server system that allows its users to monitor and control a number of processes on UNIX-like operating systems.

$ sudo apt-get install supervisor