Skip to content

Instantly share code, notes, and snippets.

View bobycloud's full-sized avatar
🍎
Loving Creativity!

Bobby Babazadeh bobycloud

🍎
Loving Creativity!
View GitHub Profile
@bobycloud
bobycloud / auto-deploying.md
Created March 12, 2020 19:07 — forked from nickbclifford/auto-deploying.md
How to automatically deploy code to a server using Travis CI

Auto-Deploying via Travis CI

Because Travis CI can automatically execute scripts after successfully (or unsuccessfully!) executing tests, it is an obvious choice for a deployment tool. In order to deploy to a Git repository on a remote server, the process generally is as follows:

  • Set up SSH keys
  • Add the server's copy of the repository as a Git remote
  • Push to the remote
  • SSH into the server and execute any installation/compilation/miscellaneous commands

Before even touching .travis.yml...

Users

# Get user real ip address in Python3.x
import socket
def get_real_ip_addr(request):
x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR')
remote_addr = request.META.get('REMOTE_ADDR')
if x_forwarded_for:
ip = x_forwarded_for.split(' ,')[0]
elif remote_addr:
path: /venv/lib64/python3.7/site-packages/filer/utils/generate_filename.y
def randomized(instance, filename):
import uuid
uuid_str = str(uuid.uuid4())
return os.path.join(uuid_str[0:2], uuid_str[2:4], uuid_str,
get_valid_filename(filename))
def randomized(instance, filename):
@bobycloud
bobycloud / artilleryfedora
Created June 26, 2019 11:47
Install Artillery on Fedora
sudo npm install -g artillery --unsafe-perm=true --allow-root
@bobycloud
bobycloud / markdownx-original-image-name
Last active November 30, 2019 08:16
set original name for markdownx editor django
Set original image file name in markdownx editor panel instead of random unique string.
file_name = "{original_name}_{unique_name}.{extension}".format(
original_name=file_name,
unique_name=uuid4(),
extension=path.splitext(file_name)[extension][extension_dot_index:]
)