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
@Sanix-Darker
Sanix-Darker / [PYTHON]Levenshtein_distance.py
Last active October 7, 2019 10:54
[PYTHON]Levenshtein_distance
import difflib
print("Levenshtein distance implementation !")
_str = 'appel'
difflib.get_close_matches('appel', ['ape', 'apple', 'peach', 'puppy'], n=2)
# returns ['apple', 'ape']
# difflib.get_close_matches finds the best "good enough" matches.
# Here, first argument is being matched against the second one.
@Sanix-Darker
Sanix-Darker / [PYTHON]PLAGON.py
Created June 6, 2020 01:07
[PYTHON]PLAGON.py
# ____ _ _ ____ ___ _ _
# | _ \| | / \ / ___|/ _ \| \ | |
# | |_) | | / _ \| | _| | | | \| |
# | __/| |___ / ___ \ |_| | |_| | |\ |
# |_| |_____/_/ \_\____|\___/|_| \_|
# --------------------------------------
from os import listdir as os_listdir, path as os_path
# pip install -U scikit-learn
from sklearn.feature_extraction.text import TfidfVectorizer
@awebartisan
awebartisan / useDragDrop.ts
Last active November 2, 2020 19:35
useDragDrop hook that handles DragStart, DragOver and Drop operations
import React from 'react';
const handleDragStart = (event: React.DragEvent) => {
event.dataTransfer.effectAllowed = 'move';
event.dataTransfer.setData(
'text/plain',
event.currentTarget.getAttribute('data-index'),
);
};
@Integralist
Integralist / remote-git.md
Created February 21, 2012 09:51
Basic set-up of remote git repository on a standard server

Set-up remote git repository on a standard server

The first thing to do is to install Git on the remote server.

Once you do that the rest of the process is split into three sections:

  1. Server set-up
  2. Local set-up (push commits)
  3. Server (pull commits)
@avoiney
avoiney / FileField_manual_initialisation.py
Last active June 12, 2021 12:46
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()
@tobiase
tobiase / models.py
Last active October 4, 2021 11:08
Prefill wagtailforms with URL parameters
from __future__ import absolute_import, unicode_literals
import django
import django.forms
import wagtail.wagtailforms.models as form_models
from django.db import models
from django.shortcuts import render
from django.utils.translation import ugettext_lazy as _
from modelcluster.fields import ParentalKey
from wagtail.wagtailadmin.edit_handlers import (
@kogakure
kogakure / fabfile.py
Created October 17, 2009 15:15 — forked from jefftriplett/fabfile.py for django
Python: Deployment for Django with Fabric
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
fabfile for Django
------------------
see http://morethanseven.net/2009/07/27/fabric-django-git-apache-mod_wsgi-virtualenv-and-p/
modified for fabric 0.9/1.0 by Hraban (fiëé visuëlle)
several additions, corrections and customizations, too
@DipandaAser
DipandaAser / storage.go
Last active January 21, 2022 15:57
List all objects of a AWS S3 folder (bypass the limit of 1000 objects)
package storage
import (
"context"
_ "github.com/aws/aws-sdk-go-v2/feature/s3/manager"
"github.com/aws/aws-sdk-go-v2/service/s3"
"github.com/aws/aws-sdk-go-v2/service/s3/types"
_ "github.com/aws/aws-sdk-go-v2/service/s3/types"
)
@kshailen
kshailen / Connecting_postgress_RDS_from_local_via_bastion.md
Last active October 12, 2022 13:26
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.
@marcellodesales
marcellodesales / ec2-host-from-tag-to-env-vars.sh
Last active November 8, 2022 11:49
Create Environment Variables in EC2 Hosts from EC2 Host Tags, just like Beanstalk or Heroku does!
######
# Author: Marcello de Sales (marcello.desales@gmail.com)
# 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