Skip to content

Instantly share code, notes, and snippets.

@sanchezg
sanchezg / deploy-django.md
Last active May 25, 2022 19:54 — forked from rmiyazaki6499/deploy-django.md
Deploying a Production ready Django app on AWS

Deploying a Production ready Django app on AWS

In this tutorial, I will be going over to how to deploy a Django app from start to finish using AWS and EC2. Recently, my partner Tu and I launched our app Hygge Homes (a vacation home rental app for searching and booking vacation homes based off Airbnb) and we wanted to share with other developers some of the lessons we learned along the way.

Following this tutorial, you will have an application that has:

  • An AWS EC2 server configured to host your application
  • SSL-certification with Certbot
  • A custom domain name
  • Continuous deployment with Github Actions/SSM Agent
@sanchezg
sanchezg / pandas-cheatsheet.md
Created November 28, 2018 20:00
pandas cheatsheet and common use cases

pivot_table

In : 
df = pd.DataFrame({
    "A": ["foo", "foo", "foo", "foo", "foo", "bar", "bar", "bar", "bar"],
    "B": ["one", "one", "one", "two", "two", "one", "one", "two", "two"],
    "C": ["small", "large", "large", "small", "small", "large", "small", "small", "large"],
    "D": [1, 2, 2, 3, 3, 4, 5, 6, 7]
})
@sanchezg
sanchezg / index.html
Created September 11, 2018 14:42
index.html for poor twitter app
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Poor Twitter App</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Simple twitter-like app">
<meta name="keywords" content="vuejs, django, restapi">
<!-- bootstrap -->
@sanchezg
sanchezg / README.md
Created May 8, 2018 21:45 — forked from jacobsvante/README.md
My version of the Agnoster theme, with Virtualenv support

agnoster.zsh-theme

A ZSH theme optimized for people who use:

  • Solarized
  • Git
  • Unicode-compatible fonts and terminals (I use iTerm2 + Menlo)

For Mac users, I highly recommend iTerm 2 + Solarized Dark

import requests
from urllib.parse import quote_plus, urlencode
def geocode_from_address(address):
"""
Returns a tuple of coordinates (lat, long) obtained from the address passed
as argument. The Location is obtained using the Google APIs v3.
"""
address = quote_plus(address)
@sanchezg
sanchezg / bash-history-to-zsh-history.py
Created December 20, 2016 23:51 — forked from op/bash-history-to-zsh-history.py
Bash history to Zsh history
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# This is how I used it:
# $ cat ~/.bash_history | bash-history-to-zsh-history >> ~/.zsh_history
import sys
def main():
@sanchezg
sanchezg / singleton1.py
Created December 12, 2016 12:46
Differents singletons implementation in python. From http://stackoverflow.com/a/6798042 & http://stackoverflow.com/a/7346105
class Singleton(object):
_instances = {}
def __new__(class_, *args, **kwargs):
if class_ not in class_._instances:
class_._instances[class_] = super(Singleton, class_).__new__(class_, *args, **kwargs)
return class_._instances[class_]
class MyClass(Singleton):
pass
from sklearn.feature_extraction.text import CountVectorizer
class ProjectionCountVectorizer(CountVectorizer):
def __init__(self, projection_path, *args, **kwargs):
self.projection_path = projection_path.split('/')
super().__init__(*args, **kwargs)
def build_preprocessor(self):
built = super().build_preprocessor()
import numpy as np
class OneHotTransformer:
def __init__(self, func):
self.f = func
def fit(self, X, y=None):
unseen = object()
seen = set()
for x in X:
import numpy as np
class DirectTransformer:
"""Utility for building class-like features from a single-point function, but that may need
some general configuration first (you usually override __init__ for that)
"""
def fit(self, X, y=None):
return self