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 / 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 / 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 / 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
@RamsesMartinez
RamsesMartinez / upgrade-postgres-9.4-to-9.6.md
Created September 7, 2017 02:34 — forked from dmitrykustov/upgrade-postgres-9.4-to-9.6.md
Upgrading PostgreSQL from 9.4 to 9.6 on Debian Jessie

To use the most modern version of Postgres software we need to add postgresql repository. Edit /etc/apt/sources.list or create /etc/apt/sources.list.d/pgdg.list and add there a line: deb http://apt.postgresql.org/pub/repos/apt/ jessie-pgdg main Then import the repository signing key, and update the package lists:

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update

Install a new version of PostgreSQL server.

Once the Debian upgrade finished, I used dpkg-query -l postgresql* to check which versions of postgres I have installed.

@RamsesMartinez
RamsesMartinez / git.config
Created December 11, 2017 15:30 — forked from jespada/git.config
git nice log
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%C(bold blue)<%an>%Creset' --abbrev-commit"
# Parar todos los contenedores
docker stop $(docker ps -a -q)
# Eliminar todos los contenedores
docker rm $(docker ps -a -q)
# Eliminar todas las imágenes
docker rmi $(docker images -q)
@RamsesMartinez
RamsesMartinez / number-format.js
Created May 13, 2018 03:43 — forked from jrobinsonc/number-format.js
Funcion para darle formato a un número. #javascript #numbers
function number_format(amount, decimals) {
amount += ''; // por si pasan un numero en vez de un string
amount = parseFloat(amount.replace(/[^0-9\.]/g, '')); // elimino cualquier cosa que no sea numero o punto
decimals = decimals || 0; // por si la variable no fue fue pasada
// si no es un numero o es igual a cero retorno el mismo cero
if (isNaN(amount) || amount === 0)
return parseFloat(0).toFixed(decimals);
Drop:
docker-compose exec db psql -U postgres -c "DROP DATABASE your-database"
Backup:
docker exec -t -u postgres your-db-container pg_dumpall -c > dump_`date +%d-%m-%Y"_"%H%M%S`.sql
Restore:
cat your_dump.sql | docker exec -i your-db-container psql -U postgres
@RamsesMartinez
RamsesMartinez / cmder-in-webstorm.md
Created November 2, 2018 19:47 — forked from sadikaya/cmder-in-webstorm.md
Cmder inside Webstorm terminal
  1. Set an environment variable called CMDER_ROOT to your root Cmder folder (in my case C:\Program Files (x86)\Cmder). It seems to be important that this does not have quotes around it because they mess with concatenation in the init script.
  2. In your IntelliJ terminal settings, use "cmd" /k ""%CMDER_ROOT%\vendor\init.bat"" as the Shell path. The double-double-quotes are intentional, as they counteract the missing double quotes in the environment variable.