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
@mccabiles
mccabiles / nginx.conf
Created September 17, 2019 11:24
Using gzip with Nginx and Vue CLI project
...
gzip on;
gzip_static on;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gzip_proxied any;
gzip_vary on;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
@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).
@dmitrykustov
dmitrykustov / upgrade-postgres-9.4-to-9.6.md
Last active August 8, 2022 17:52 — forked from dideler/upgrade-postgres-9.3-to-9.4.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.

@gilyes
gilyes / Backup, restore postgres in docker container
Last active June 11, 2024 21:21
Backup/restore postgres in docker container
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 -Upostgres
@willurd
willurd / web-servers.md
Last active July 19, 2024 02:15
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
@jrobinsonc
jrobinsonc / number-format.js
Last active July 23, 2021 22:09
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);