Skip to content

Instantly share code, notes, and snippets.

View Alex-Just's full-sized avatar

AlekseiK Alex-Just

View GitHub Profile
python3 -c "import requests; proxies = {'http': '127.0.0.1:21233'}; response = requests.get('http://ya.ru', proxies = proxies); print ('Elapsed time: ', response.elapsed)"
@Alex-Just
Alex-Just / ssh.sh
Last active February 12, 2017 13:24
ssh-keygen -t rsa
cat ~/.ssh/id_rsa.pub | ssh user@host "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
# or
cat ~/.ssh/id_rsa.pub | ssh-copy-id user@host
ssh-add -K ~/.ssh/id_rsa
# You might need to start ssh-agent
eval `ssh-agent -s`
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get upgrade
whoami
# Add user to sudoers
sudo adduser <username> sudo
# Switch user
su - user2
# List all local users
cut -d: -f1 /etc/passwd
@Alex-Just
Alex-Just / habr_proxy.py
Last active January 17, 2017 12:53
Download target URL, append all 6 letter words with a ™ symbol, and display the outputs in the opened user's browser
#!/usr/bin/env python3
# Author: Alex Just <AlexJustEmail@gmail.com>
"""Download target URL, append all 6 letter words with a ™ symbol, and display the outputs in the opened user's browser
Project specification:
https://docs.google.com/document/d/1bua6MXG9rHyreSPVPEZBkk14WYHy31ia4Vb2rnrgvS0/edit
Installation:
$ pip3 install bs4 vcrpy
# One-liner
pyenv global 3.5.2 && virtualenv .env -p $(pyenv which python) && . .env/bin/activate && python -V && pyenv global system
# List installed versions
pyenv versions
# Set global version to
pyenv global 3.5.2
# Check current set version
@Alex-Just
Alex-Just / generators.py
Last active January 22, 2017 10:56
Understanding Python generators
# https://eev.ee/blog/2016/07/31/python-faq-why-should-i-use-python-3/#yield-from
# https://jeffknupp.com/blog/2013/04/07/improve-your-python-yield-and-generators-explained/
# `yield`
# - pauses generator (saves its state) on the current line of code
# - returns yielded value (and control) to the caller
# - receives another `somevalue` from the caller via generator.send(somevalue)
# `yield from`
# - yields an entire sequence
@Alex-Just
Alex-Just / bash.sh
Last active November 11, 2019 16:38
Bash programming
# Infinite Loop
while true; do echo 'Hit CTRL+C'; sleep 1; done
# Video to GIF
ffmpeg -i video.mov -ss 00:00:00.000 -pix_fmt rgb8 -r 10 -f gif - | gifsicle --optimize=3 > video.gif
@Alex-Just
Alex-Just / bash-cheatsheet.sh
Last active March 17, 2017 16:32 — forked from LeCoupa/bash-cheatsheet.sh
Bash CheatSheet for UNIX Systems
#!/bin/bash
# 0. Shortcuts.
CTRL+A # move to beginning of line
CTRL+E # moves to end of line
CTRL+G # aborts the current editing command and ring the terminal bell
CTRL+K # deletes (kill) forward to end of line
CTRL+L # clears screen and redisplay the line
CTRL+R # searches backward
import json
pp json.loads(json.dumps(resp.data))
pp json.loads(json.dumps(obj))