Skip to content

Instantly share code, notes, and snippets.

View kostja-me's full-sized avatar
😀

Kostja kostja-me

😀
View GitHub Profile
@kostja-me
kostja-me / Dockerfile
Created July 3, 2020 13:29
Dockerfile for Python3.8
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\
@kostja-me
kostja-me / settings.py
Last active November 9, 2023 03:40
Nginx Cache Setup for Django Site. Uses Django Dummy Cache Backend by default to set required Cache-Control Headers for downstream Nginx Cache
REDIS_URL = os.getenv('REDIS_URL', 'redis://localhost:6379')
CACHES = {
"redis": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": REDIS_URL,
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
}
},
"default": {
@kostja-me
kostja-me / server_setup.py
Created October 28, 2019 11:06
Connect to a remote SSH server with private key in a string, download a bash script and run it with CURL
def server_setup(server_id: int):
"""Connects to server and runs installation of required software"""
server = Server.objects.get(pk=server_id)
server.setup_status = SETUP_STATUS.started
server.save(update_fields=['setup_status', ])
rsa_key = server.user.private_key
print(f"ran server_setup server_id={server_id}")
setup_command = "curl -sSL https://app.appliku.com/server_api/initial_installation.sh | bash"
try:
pkey = paramiko.RSAKey.from_private_key(StringIO(rsa_key))
@kostja-me
kostja-me / droplet_creation.py
Created October 28, 2019 10:56
Create a Digital Ocean Droplet with Ubuntu 18.04 via Python 3 API
manager = digitalocean.Manager(token=user.digital_ocean_token)
images = manager.get_global_images()
image_id = None
for i in images:
if i.slug == 'ubuntu-18-04-x64':
image_id = i.id
if not image_id:
return "Server creation failed, could not find a suitable image"
droplet = digitalocean.Droplet(
token=user.digital_ocean_token,
bool checkSeesEnemy(){
int layerMask = 1 << 8;
RaycastHit hit;
if (Physics.Raycast(transform.position, transform.TransformDirection (Vector3.forward), out hit, see_distance, layerMask)) {
Debug.DrawRay(transform.position, transform.TransformDirection (Vector3.forward) * hit.distance, Color.yellow);
Debug.Log("Did Hit");
return true;
} else {
Debug.DrawRay(transform.position, transform.TransformDirection (Vector3.forward) *1000, Color.white);
Debug.Log("Did not Hit");
@kostja-me
kostja-me / DokerfileNode
Last active May 22, 2018 21:02
Gitlab CI/CD Runner Scripts with Dockerfile to build Nodejs Angular 5 app in Docker
FROM node:9
USER node
RUN mkdir /home/node/.npm-global
ENV PATH=/home/node/.npm-global/bin:$PATH
ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
COPY interface/package.json /home/node/
COPY interface/package-lock.json /home/node/
RUN npm i -g [email protected]
RUN npm i -g @angular/[email protected]
WORKDIR /home/node
#!/usr/bin/env bash
if [ -z "${STAGE_PRIVATE_KEY}" ]; then echo "STAGE_PRIVATE_KEY is not set"; exit 255; fi
if [ -z "${STAGE_PUBLIC_KEY}" ]; then echo "STAGE_PRIVATE_KEY is not set"; exit 255; fi
pwd
ls
id
mkdir ~/.ssh/
echo -n "$STAGE_PRIVATE_KEY" > ~/.ssh/id_rsa
echo -n "$STAGE_PUBLIC_KEY" > ~/.ssh/id_rsa.pub
node@f03e150cb3aa:/code/interface$ npm list
[email protected] /code/interface
+-- UNMET DEPENDENCY [email protected]
+-- UNMET DEPENDENCY @angular-redux/[email protected]
+-- UNMET DEPENDENCY @angular-redux/[email protected]
+-- UNMET DEPENDENCY @angular/[email protected]
| `-- UNMET DEPENDENCY [email protected]
+-- UNMET DEPENDENCY @angular/[email protected]
| `-- UNMET DEPENDENCY [email protected]
+-- UNMET DEPENDENCY @angular/[email protected]
@kostja-me
kostja-me / setup_emacs.sh
Created February 23, 2018 07:59
Setting up Emacs for Any Programming Language
mv ~/.emacs ~/.emacs_dont_need_this
@kostja-me
kostja-me / utils.py
Last active February 18, 2018 20:39
get certificate expiration time in days, python3.6
from OpenSSL import SSL
import socket
import datetime
import sys
def get_domain_certificate_expiration_days(domain: str, port: int=443) -> int:
cur_date = datetime.datetime.utcnow()
cert_tested = 0