Skip to content

Instantly share code, notes, and snippets.

View jcopps's full-sized avatar
🥁
Figuring out

Jeffry copps jcopps

🥁
Figuring out
View GitHub Profile
@jcopps
jcopps / README.md
Last active August 28, 2019 07:11
Switching between python2 and python3

Creating an alias will not be the best way to do it.

Using update-alternatives

sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.5 1

sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 2

sudo update-alternatives --config python Enter 2 for Python 2.7.

@jcopps
jcopps / gist:3a35a624ecf4da534f510ba2e24d4829
Created September 4, 2019 16:19
python3 python2 inconsistency with config parser or os_error
https://unix.stackexchange.com/a/210601/171474
I had a very similar issue. It seems to come from the use of python3 instead of python2.7
I had /usr/bin/python linked to python3 (I changed the link after installing python3 for greater convenience, it looks like aliasing is a much better idea).
Anyway, after unlinking it and relinking it to python2.7 upgrade worked fine.
Never overwrite /usr/bin/python to python3, this would cause apt-get and several other to fail.
@jcopps
jcopps / docker purge
Created November 29, 2019 06:19
Purge in docker to free up space
docker system prune & docker system prune --volumes
@jcopps
jcopps / docker-address-already-in-use
Created June 6, 2020 04:01
Docker - Possible workaround for address already in use
docker stop $(docker ps -a -q)
docker ps # again to make sure containers is off
sudo lsof -i tcp:2049 # now you get and list of process running and using 2049 port find and copy PID
sudo kill -9 yout_PID
https://stackoverflow.com/questions/55535967/error-starting-userland-proxy-listen-tcp-0-0-0-02049-bind-address-already-in
@jcopps
jcopps / make_utf_8_json.py
Created July 12, 2020 13:41
Python2.7 Make UTF-8 encoded JSON out of unicode(escaped)
import argparse
import codecs
import json
def make_utf_8_json(input_file, output_file):
content = json.loads(open(input_file, 'r').read())
cc = json.dumps(content, indent=2, sort_keys=True, ensure_ascii=False)
file = codecs.open(output_file, "w", "utf-8")
file.write(cc)
@jcopps
jcopps / accept all licenses - android on windows
Last active August 9, 2020 06:44
Accept licenses in Android - development
Location of the sdkmanager
C:\Users\IP510\AppData\Local\Android\Sdk\tools\bin>sdkmanager.bat --licenses
---------------------------------------
Accept? (y/N): y
All SDK package licenses accepted
@jcopps
jcopps / curl quick load test
Created June 7, 2021 09:49
Parallelize a http request for quick load test - CURL
"""Curl Quick Load Test
P10 - 10 indicates 10 parallel instances at once.
200 - Total number of requests
"""
seq 1 200 | xargs -n1 -P10 curl "http://github.com/jcopps"
@jcopps
jcopps / README.md
Created October 4, 2021 14:47 — forked from joyrexus/README.md
Convert csv to json

Convert a CSV (comma-separated value) file into JSON.

Usage

csv2json.py data.csv > data.json
@jcopps
jcopps / Debug a docker-compose service
Created October 6, 2021 11:34
How to debug a docker-compose service
version: '3.1'
services:
service_a:
image: "fat_image"
ports:
- "6382:6382"
volumes:
- /home/dir1:/home/dirA
- /home/dir2:/home/dirB
@jcopps
jcopps / Install Python3_9_7
Last active November 14, 2022 05:51
Install python3.9.7 and pip
sudo apt update
sudo apt install build-essential libncurses5-dev zlib1g-dev libnss3-dev libgdbm-dev libssl-dev libsqlite3-dev libffi-dev libreadline-dev curl libbz2-dev
sudo wget https://www.python.org/ftp/python/3.9.7/Python-3.9.7.tgz
tar -xvf Python-3.9.7.tgz
cd Python-3.9.7
./configure --enable-optimizations