Skip to content

Instantly share code, notes, and snippets.

#source https://github.com/docker-library/golang/blob/ee2d52a7ad3e077af02313cd4cd87fd39837412c/1.15/alpine3.12/Dockerfile
#custom
rm -rf /usr/local/go/src/*
apk add build-base
apk add gnupg go bash
apk add --no-cache \
ca-certificates
# set up nsswitch.conf for Go's "netgo" implementation
wsl -u root ip addr add 192.168.1.225/24 broadcast 192.168.1.255 dev eth0 label eth0:1
netsh interface ip add address "vEthernet (WSL)" 192.168.1.220 255.255.255.0
#Elevated Shell
param([switch]$Elevated)
function Check-Admin {
$currentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent())
$currentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
}
if ((Check-Admin) -eq $false) {
if ($elevated) {
# could not elevate, quit
} else {
# install packages
sudo apt-get update
sudo apt-get install nload htop -y
# if your user doesn't exists then remove sudo passwords
USERNAME=$(whoami)
sudo grep -qxF "${USERNAME} ALL=(ALL) NOPASSWD: ALL" /etc/sudoers || echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" | sudo tee -a /etc/sudoers
# install reqs docker
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common -y
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 $(lsb_release -cs) stable"
# change to root and install packages
su -c "apk add sudo openrc curl python3 python3-dev nload htop"
# if your user doesn't exists then remove sudo passwords
USERNAME=$(whoami)
su -c "grep -qxF '${USERNAME} ALL=(ALL) NOPASSWD: ALL' /etc/sudoers || echo '${USERNAME} ALL=(ALL) NOPASSWD: ALL' | tee -a /etc/sudoers"
# install compilers
sudo apk add build-base
# install pip3
sudo apk add py3-pip
# upgrade pip3
BASE=docker
# modify these in /etc/default/$BASE (/etc/default/docker)
DOCKERD=/usr/bin/dockerd
# This is the pid file managed by docker itself
DOCKER_PIDFILE=/var/run/$BASE.pid
# This is the pid file created/managed by start-stop-daemon
DOCKER_SSD_PIDFILE=/var/run/$BASE-ssd.pid
DOCKER_LOGFILE=/var/log/$BASE.log
DOCKER_OPTS=
@richard24se
richard24se / simple_gridfs_server.py
Created July 30, 2020 22:21 — forked from artisonian/simple_gridfs_server.py
A simple GridFS server built with Flask
from flask import Flask, request, redirect, url_for, make_response, abort
from werkzeug import secure_filename
from pymongo import Connection
from pymongo.objectid import ObjectId
from gridfs import GridFS
from gridfs.errors import NoFile
ALLOWED_EXTENSIONS = set(['txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif'])
DB = Connection().gridfs_server_test
FS = GridFS(DB)
import pymysql
# Connect to the database
connection = pymysql.connect(host=$IP_SERVIDOR,
user=$USUARIO,
password=$CONTRASEÑA,
db=$BASE_DATOS,
charset='utf8mb4',
)
try:
@richard24se
richard24se / pysyslog.py
Created June 4, 2020 22:37 — forked from mgara/pysyslog.py
Tiny Python Syslog Server
#!/usr/bin/env python
# Tiny Syslog Server in Python.
##
# This is a tiny syslog server that is able to receive UDP based syslog
# entries on a specified port and save them to a file.
# That's it... it does nothing else...
# There are a few configuration parameters.
# create a ramdisk if you want to use stoe logs on the ram disk. (faster thant
@richard24se
richard24se / py_rotate_log_dict_config.py
Created June 4, 2020 22:37 — forked from biggers/py_rotate_log_dict_config.py
Python3 rotating log-file configuration via "config.dictConfig"
import sys
import logging
import logging.config
import random
import string
# "thank you" to folks on StackOverflow.com for various ideas,
# for this example. Works with Python3.