Skip to content

Instantly share code, notes, and snippets.

View milnomada's full-sized avatar

milnomada milnomada

View GitHub Profile
@milnomada
milnomada / Dockerfile.cron
Last active February 3, 2022 11:04
Run Cron jobs inside Docker container
FROM python:3.8.12-slim-buster
RUN apt update && apt install -y cron vim
RUN mkdir /code
ARG DB_HOST
ARG DB_NAME
ARG DB_USER
ARG DB_PASS
ARG CRON_SCHEDULE
@milnomada
milnomada / Dockerfile.socket
Last active July 29, 2021 13:00
Python Socket.io Server Dockerfile
FROM python:3.6.5-slim AS sobase
RUN apt-get clean && apt-get -y update
RUN apt-get -y install python3-dev build-essential
RUN apt-get -y install libssl-dev
RUN mkdir /code
COPY requirements.txt /code
RUN CFLAGS="-I/usr/local/opt/openssl/include" \
@milnomada
milnomada / index.html
Created July 29, 2021 09:46
Socket.io client for Python application
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no" />
<title>Socket.io</title>
<style>
body {
padding: 0;
margin: 0;
@milnomada
milnomada / main.py
Last active July 28, 2021 17:57
Simple Socket.io application with Python and uwsgi
import logging
import socketio
from engineio.async_drivers import gevent
logging.basicConfig(level=logging.INFO)
sio = socketio.Server(async_mode="gevent_uwsgi", cors_allowed_origins='*', engineio_logger=True)
logger = logging.getLogger("socket-server")
@sio.on('connect', namespace='/')
@milnomada
milnomada / install_base_packages
Created February 3, 2020 10:59
Install basic packages for Ubuntu Server
sudo apt install git python3 python3-dev vim htop jq automake build-essential
# Docker
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable"
sudo apt-get update
sudo apt install docker-ce
docker --version
@milnomada
milnomada / install-docker.sh
Last active August 25, 2019 12:08
Install docker in Ubuntu 16.04
# Install docker Ubuntu 16.04
sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable"
sudo apt-get update
apt-cache search docker-ce
sudo apt-get install -y docker-ce
@milnomada
milnomada / mongo-dockerfile
Created August 12, 2019 12:09
A working version of the dockerized mongodb v3.4
FROM debian:jessie-slim
RUN apt-get update && \
apt-get install -y ca-certificates && \
rm -rf /var/lib/apt/lists/*
RUN gpg --keyserver ha.pool.sks-keyservers.net --recv-keys 0C49F3730359A14518585931BC711F9BA15703C6 && \
gpg --export $GPG_KEYS > /etc/apt/trusted.gpg.d/mongodb.gpg
ARG MONGO_PACKAGE=mongodb-org
{
"settings": {
"index": {
"creation_date": "1556813167970",
"number_of_shards": "1",
"number_of_replicas": "1",
"uuid": "Q7778WcLRHmpX9061AH5fg",
"version": {
"created": "7000099"
},
from selenium import webdriver
from scrapy.http import HtmlResponse
from selenium.webdriver.chrome.options import Options
"""
whatch chromedriver version supporting the chrome browser version in system
"""
class SeleniumMiddleware(object):
def process_request(self,request,spider):
docker rm `docker ps --no-trunc -aq`