Skip to content

Instantly share code, notes, and snippets.

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

Ramsés Martínez Ortiz RamsesMartinez

🏠
Working from home
View GitHub Profile
{
"cmd": ["/home/USUARIO/anaconda3/bin/python3", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python"
}
@RamsesMartinez
RamsesMartinez / gunicorn_start
Created April 7, 2017 21:37 — forked from MauricioDinki/gunicorn_start
gunicorn start to run a django app
#!/bin/bash
# This runs on 9000 port
NAME="appname"
VIRTUALENV="virtualenv folder"
DJANGO_DIR="django root folder"
USER=root
GROUP=sudo
NUM_WORKERS=5
@RamsesMartinez
RamsesMartinez / server
Created April 7, 2017 21:39 — forked from MauricioDinki/server
nginx server
upstream app_server {
server 127.0.0.1:9000 fail_timeout=0;
}
server {
listen 80;
server_name <server name>;
return 301 https://$server_name$request_uri;
}
@RamsesMartinez
RamsesMartinez / sublime
Last active April 27, 2017 23:13
Sublime Key Bidings
[
{"keys": ["ctrl+alt+i"], "command": "reindent", "args": {"single_line": false}},
{ "keys": ["ctrl+}"], "command": "toggle_comment", "args": { "block": false } },
{ "keys": ["ctrl+shift+}"], "command": "toggle_comment", "args": { "block": true } },
{ "keys": ["ctrl+alt+shift+s"], "command": "save_all" },
{ "keys": ["ctrl+shift+-"], "command": "toggle_side_bar" },
]
@RamsesMartinez
RamsesMartinez / supervisor
Last active May 4, 2017 05:21
Supervisor service
sudo systemctl start supervisor
sudo systemctl stop supervisor
sudo systemctl restart supervisor
@RamsesMartinez
RamsesMartinez / guia-postgres.md
Last active December 21, 2020 23:20
Guia de Desarrollo Express para Postgresql

Guia de Desarrollo Express para Postgresql

Esta es una guia práctica para varios casos de uso común al momento de desarrollar usando postgresql tanto en producción como en desarrollo.

Instalación

Instalación en Linux

ramses@debian:~$ sudo apt-get install postgresql postgresql-contrib libpq-dev

Versión instalada Postgresql

@RamsesMartinez
RamsesMartinez / django_initial_migrations.md
Last active August 3, 2018 04:53
How to create a initial_migrations from an existing schema

Here are the steps (for whoever runs into this problem):

  1. Empty the django_migrations: table: delete from django_migrations;
  2. For every app, delete its migrations folder: rm -rf <app>/migrations/
    find . -path "*/migrations/*.py" -not -name "__init__.py" -delete
    find . -path "*/migrations/*.pyc"  -delete
    
  3. Reset the migrations for the "built-in" apps: python manage.py migrate --fake
  4. For each app run: python manage.py makemigrations . Take care of dependencies (models with ForeignKey's should run after their parent model).
@RamsesMartinez
RamsesMartinez / scp_upload.md
Created May 5, 2017 06:29
Upload files form local remote server

How to send a file from local to remote server

We have a simple way

ramses@debian:~ scp /path/to/local/file usuario@servidor:path/to/colocate/the/file

If we need the .pem file We can use this way:

ramses@debian:~ scp -i /path/to/key.pem path/to/local/file usuario@servidor:path/to/colocate/the/file
@RamsesMartinez
RamsesMartinez / mínimos-cuadrados.py
Created May 12, 2017 03:04 — forked from baruch-grs/mínimos-cuadrados.py
Método para calcular los mínimos cuadrados
import math
class LeastSquares(object):
"""docstring for LeastSquares"""
def __init__(self, x:list, y:list):
super(LeastSquares, self).__init__()
if len(x) != len(y):
raise NameError('Las listas deben tener misma longitud.')

To access your instance:

  1. Open an SSH client
  2. Locate your private key file (Key-Tesca.pem). The wizard automatically detects the key you used to launch the instance.
  3. Your key must not be publicly viewable for SSH to work. Use this command if needed: chmod 400 Key-Tesca.pem
  4. Connect to your instance using its Public DNS: ec2-123-456-789-123.us-west-2.compute.amazonaws.com

Example: ssh -i "Key-Tesca.pem" ubuntu@ec2-123-456-789-123.us-west-2.compute.amazonaws.com