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
@RamsesMartinez
RamsesMartinez / web-servers.md
Created August 30, 2017 01:44 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000

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" [email protected]

@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.')
@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 / 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 / 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 / supervisor
Last active May 4, 2017 05:21
Supervisor service
sudo systemctl start supervisor
sudo systemctl stop supervisor
sudo systemctl restart supervisor
@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 / 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 / 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