Skip to content

Instantly share code, notes, and snippets.

function dogrant{
$actualPath = Get-Location | select Path -ExpandProperty Path
#EDIT THIS PATH
$remotePath = "apps/"
#USE TYPE DIRECTORY LIKE THIS :---> c:\apps\backend\users or c:\apps\frotend\sync
$parent = (get-item $(Get-Location)).parent | select Name -ExpandProperty Name
$current = Split-Path -leaf -path (Get-Location)
$targetPath = $remotePath+""+$parent+"/"+$current
#EDIT DIRECTORY OF VAGRANT
cd C:\vagrant
#!/bin/bash
# Copyright 2017-2019 JetsonHacks
# MIT License
# Create a swap file and set up permissions
# If a parameter is passed, it should be the place to create the swapfile
set -e
SWAPDIRECTORY="/mnt"
# Ubuntu recommends 6GB for 4GB of memory when using suspend
# You can use 1 or 2 if need be
SWAPSIZE=6
@richard24se
richard24se / celery.sh
Created April 27, 2020 14:43 — forked from amatellanes/celery.sh
Celery handy commands
/* Useful celery config.
app = Celery('tasks',
broker='redis://localhost:6379',
backend='redis://localhost:6379')
app.conf.update(
CELERY_TASK_RESULT_EXPIRES=3600,
CELERY_QUEUES=(
Queue('default', routing_key='tasks.#'),
@richard24se
richard24se / celery.py
Created April 29, 2020 16:09 — forked from IrSent/celery.py
Celery Best Practices
# Safe Queue Celery App Settings
from __future__ import absolute_import, unicode_literals
from celery import Celery
app = Celery('some_project',
broker='amqp://',
backend='amqp://',
include=['some_project.tasks'])
@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.
@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
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 / 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)
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=
# 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