Skip to content

Instantly share code, notes, and snippets.

View kpavlovsky's full-sized avatar
😀

Kostja P kpavlovsky

😀
  • Europe
View GitHub Profile
@kpavlovsky
kpavlovsky / new-speedpy-project.applescript
Created August 9, 2022 10:58
Create a new Django SaaS from RayCast
#!/usr/bin/osascript
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Speedpy New Project
# @raycast.mode silent
# Optional parameters:
# @raycast.icon 🚀
# @raycast.argument1 { "type": "text", "placeholder": "project name" }
FROM python:3.10.1-bullseye
SHELL ["/bin/bash", "-c"]
ENV PIP_NO_CACHE_DIR off
ENV PIP_DISABLE_PIP_VERSION_CHECK on
ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 0
RUN apt-get update \
&& apt-get install -y --force-yes \
nano python3-pip gettext chrpath libssl-dev libxft-dev \
libfreetype6 libfreetype6-dev libfontconfig1 libfontconfig1-dev\
FROM python:3.8.12-bullseye
SHELL ["/bin/bash", "-c"]
ENV PIP_NO_CACHE_DIR off
ENV PIP_DISABLE_PIP_VERSION_CHECK on
ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 0
RUN apt-get update \
&& apt-get install -y --force-yes \
nano python3-pip gettext chrpath libssl-dev libxft-dev \
libfreetype6 libfreetype6-dev libfontconfig1 libfontconfig1-dev\
@kpavlovsky
kpavlovsky / deployment_v3.py
Created October 4, 2020 03:44
Deployments with temouts, abort, non-blocking with paramiko
def run_deployment_v3(deployment: Deployment):
"""Runs deployment as 'app' user with separate commands passing commands via base64 scripts,
with timeouts and possibility to abort deployment"""
if deployment.is_aborted:
print("deployment is aborted")
deployment.log("Deployment was aborted")
deployment.status = DEPLOYMENT_STATUS.aborted
deployment.save(update_fields=['status', ])
return "Aborted"
server = deployment.application.server # type: Server
@kpavlovsky
kpavlovsky / paramiko_long_running_command_non_blocking_output_timeout.py
Created September 29, 2020 16:01
Using paramiko run long running command non blocking with timeout of 60 seconds
import paramiko
import time
from io import StringIO
import sys
import select
def main():
"""Run cat command and tries to cancel it """
ip_address = '52.28.75.66'
with open('/Users/k/.ssh/id_rsa', 'r') as f:
@kpavlovsky
kpavlovsky / deployment.py
Created September 28, 2020 05:34
Run the deployment: Celery, Paramiko
def run_deployment(deployment: Deployment):
"""Runs deployment as 'app' user with separate commands passing commands via base64 scripts"""
server = deployment.application.server # type: Server
rsa_key = server.user.private_key # type: str
deployment.log(f"ran run_deployment_v2 for deployment {deployment.id}")
username = 'app'
deployment.log(f'??? Connecting to {username}@{server.ip_address}')
try:
pkey = paramiko.RSAKey.from_private_key(StringIO(rsa_key))
client = paramiko.SSHClient()
@kpavlovsky
kpavlovsky / Dockerfile
Created July 3, 2020 13:36
Dockerfile Python 3.8 Simplified
FROM python:3.8
SHELL ["/bin/bash", "-c"]
ENV PIP_NO_CACHE_DIR off
ENV PIP_DISABLE_PIP_VERSION_CHECK on
ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 0
WORKDIR /code/
COPY ./code/requirements.txt /code/
RUN pip install -r requirements.txt
COPY ./code/ /code/
@kpavlovsky
kpavlovsky / Dockerfile
Created July 3, 2020 13:33
Dockerfile for PYPY3
FROM pypy:3
SHELL ["/bin/bash", "-c"]
ENV PIP_NO_CACHE_DIR off
ENV PIP_DISABLE_PIP_VERSION_CHECK on
ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 0
RUN apt-get update \
&& apt-get install -y --force-yes \
nano python-pip gettext chrpath libssl-dev libxft-dev \
libfreetype6 libfreetype6-dev libfontconfig1 libfontconfig1-dev\
@kpavlovsky
kpavlovsky / Dockerfile
Created July 3, 2020 13:31
Dockerfile for PHP-7
FROM python:3.8
SHELL ["/bin/bash", "-c"]
ENV PIP_NO_CACHE_DIR off
ENV PIP_DISABLE_PIP_VERSION_CHECK on
ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 0
RUN apt-get update \
&& apt-get install -y --force-yes \
nano python-pip gettext chrpath libssl-dev libxft-dev \
libfreetype6 libfreetype6-dev libfontconfig1 libfontconfig1-dev\
@kpavlovsky
kpavlovsky / Dockerfile
Created July 3, 2020 13:30
Dockerfile for Node 14
FROM python:3.8
SHELL ["/bin/bash", "-c"]
ENV PIP_NO_CACHE_DIR off
ENV PIP_DISABLE_PIP_VERSION_CHECK on
ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 0
RUN apt-get update \
&& apt-get install -y --force-yes \
nano python-pip gettext chrpath libssl-dev libxft-dev \
libfreetype6 libfreetype6-dev libfontconfig1 libfontconfig1-dev\