Skip to content

Instantly share code, notes, and snippets.

View simo97's full-sized avatar
🏠
Working from home

adonis simo simo97

🏠
Working from home
View GitHub Profile
@simo97
simo97 / create_web_s3_bucket.py
Last active February 19, 2020 12:23
A small function to create a s3 bucket for static web hosting. It upload file to the S3 bucket after creation.
import os
import json
import boto3
from django.conf import settings
def build_file_path(path, filename, static_root_folder):
NAME = static_root_folder + '/'
return path[path.find(NAME) + len(NAME):] + filename
@simo97
simo97 / ec2-host-from-tag-to-env-vars.sh
Created April 17, 2020 17:38 — forked from marcellodesales/ec2-host-from-tag-to-env-vars.sh
Create Environment Variables in EC2 Hosts from EC2 Host Tags, just like Beanstalk or Heroku does!
######
# Author: Marcello de Sales ([email protected])
# Description: Create Create Environment Variables in EC2 Hosts from EC2 Host Tags
#
### Requirements:
# * Install jq library (sudo apt-get install -y jq)
# * Install the EC2 Instance Metadata Query Tool (http://aws.amazon.com/code/1825)
#
### Installation:
# * Add the Policy EC2:DescribeTags to a User
@simo97
simo97 / css-media-queries-cheat-sheet.css
Created April 24, 2020 12:34 — forked from bartholomej/css-media-queries-cheat-sheet.css
CSS Media Query Cheat Sheet (with Foundation)
/*------------------------------------------
Responsive Grid Media Queries - 1280, 1024, 768, 480
1280-1024 - desktop (default grid)
1024-768 - tablet landscape
768-480 - tablet
480-less - phone landscape & smaller
--------------------------------------------*/
@media all and (min-width: 1024px) and (max-width: 1280px) { }
@media all and (min-width: 768px) and (max-width: 1024px) { }
-- creation de la table common_domain
CREATE TABLE public.common_domain
(
id SERIAL,
domain character varying(253) COLLATE pg_catalog."default" NOT NULL,
is_primary boolean NOT NULL,
tenant_id uuid NOT NULL,
CONSTRAINT common_domain_pkey PRIMARY KEY (id),
CONSTRAINT common_domain_domain_key UNIQUE (domain),
CONSTRAINT common_domain_tenant_id_1965101a_fk_common_company_id FOREIGN KEY (tenant_id)
@simo97
simo97 / django-q-cluster.config
Last active September 21, 2020 05:32 — forked from codeSamuraii/django-q-cluster.sh
Deploy Django-Q to an EC2 instance with Elastic Beanstalk
container_commands:
01_makemigrations:
command: "python manage.py makemigrations"
leader_only: true
02_migrate:
command: "python manage.py migrate"
leader_only: true
# Patch the current version, circular imports cause an ImportError (see https://github.com/Koed00/django-q/issues/331)
03_patch_django_q:
# Replace line 12 ('from django_q.cluster import worker, monitor') by 'from django_q.cluster import *'
@simo97
simo97 / FileField_manual_initialisation.py
Created June 12, 2021 12:46 — forked from avoiney/FileField_manual_initialisation.py
Manually associate an existing file to a model FileField
# Assuming you have a Article Model like this
# class Article(models.Model):
# ... Some field
# media = models.FileField(upload_to="path_to_inner_media_folder", blank=True)
from django.core.files.base import ContentFile
import os
# Create an article with the associated model
new_article = Article()
@simo97
simo97 / Connecting_postgress_RDS_from_local_via_bastion.md
Created July 23, 2021 01:05 — forked from kshailen/Connecting_postgress_RDS_from_local_via_bastion.md
Ways to connect to postgress RDS instance from bastion host and from local host

When it comes to databases and AWS VPC, best practice is to place your database in private subnet. By definition, private subnet in AWS is not reachable from the Internet because no Internet gateway is attached to private subnet. This is the way you protect your data. This kind of configuration is good for security but bad for data management.

How can you easily access and manage your secured data?

basic_RDS_bastion_architecture

There are two basic ways to acees it.

  1. Access postgres RDS from bastion host. There are following requirements for this.
@simo97
simo97 / is_into_square.py
Created September 5, 2021 18:12
Check if a point(lat, long) is contained into a square (BBOX) knowing his max and min coordinates
def is_into_square(latMin, latMax, longMin, longMax, lat , long) -> bool:
"""
This function check if a point(lat, long) is contained into a square (BBOX) knowing his max and min coordinates
:param latMin: min latitude of the BBOx
:param latMax: max latitude of the BBOx
:param longMin: max longitude of the BBOx
:param longMax: max longitude of the BBOx
:param lat: the latitude of the point to verified
:param long: the longitude of the point to be verified
:return: bool
@simo97
simo97 / auth.py
Last active January 28, 2022 20:10
from fusionauth.fusionauth_client import FusionAuthClient
class FusionAuthBackend:
def authenticate(username: str, password: str, *args, **kwargs):
# fusionauth_client.
client = FusionAuthClient(settings.FUSION_AUTH_API_KEY, settings.FUSION_AUTH_BASE_URL)
_tenant_id = settings.FUSION_AUTH_MAIN_TENANT_ID
if _tenant_id != "":
client.set_tenant_id(settings.FUSION_AUTH_MAIN_TENANT_ID)
@simo97
simo97 / README.md
Created February 16, 2022 15:39 — forked from leonardofed/README.md
A curated list of AWS resources to prepare for the AWS Certifications


A curated list of AWS resources to prepare for the AWS Certifications

A curated list of awesome AWS resources you need to prepare for the all 5 AWS Certifications. This gist will include: open source repos, blogs & blogposts, ebooks, PDF, whitepapers, video courses, free lecture, slides, sample test and many other resources.