Skip to content

Instantly share code, notes, and snippets.

View osw4l's full-sized avatar
🎹
Piano player

Oswaldo Rodriguez osw4l

🎹
Piano player
  • universidad libre de colombia
  • Barcelona, Spain
  • 16:48 (UTC +01:00)
View GitHub Profile
sudo apt update
sudo apt install openjdk-8-jdk wget gnupg
wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt update
@osw4l
osw4l / how-to-copy-aws-rds-to-local.md
Created September 23, 2019 07:59 — forked from syafiqfaiz/how-to-copy-aws-rds-to-local.md
How to copy production database on AWS RDS(postgresql) to local development database.
  1. Change your database RDS instance security group to allow your machine to access it.
    • Add your ip to the security group to acces the instance via Postgres.
  2. Make a copy of the database using pg_dump
    • $ pg_dump -h <public dns> -U <my username> -f <name of dump file .sql> <name of my database>
    • you will be asked for postgressql password.
    • a dump file(.sql) will be created
  3. Restore that dump file to your local database.
    • but you might need to drop the database and create it first
    • $ psql -U <postgresql username> -d <database name> -f <dump file that you want to restore>
  • the database is restored
@osw4l
osw4l / docker-destroy-all.sh
Created September 26, 2019 00:09 — forked from JeffBelback/docker-destroy-all.sh
Destroy all Docker Containers and Images
#!/bin/bash
# Stop all containers
containers=`docker ps -a -q`
if [ -n "$containers" ] ; then
docker stop $containers
fi
# Delete all containers
containers=`docker ps -a -q`
if [ -n "$containers" ]; then
docker rm -f -v $containers
# heroku backup
heroku pg:backups:capture --app heroku_app_name
heroku pg:backups:download --app heroku_app_name
# when the latest.dump are downloaded
pg_restore --verbose --clean --no-acl --no-owner -h my_rds_host -U user -d db latest.dump
# download backup from remote database
pg_dump -h host -U user -C db --file=db_backup.dump
@osw4l
osw4l / _orders
Last active January 6, 2020 06:39 — forked from jaishirb/_orders
deploy
# first steps if you have locales issues
sudo dpkg-reconfigure locales
sudo apt install language-pack-en
sudo locale-gen en_US en_US.UTF-8
nano /etc/default/locale
LANG=en_US.UTF-8
LC_ALL="en_US.UTF-8”
LANGUAGE="en_US:en"
# first steps :)
@action(detail=False, methods=['get'])
def published(self, request):
queryset = self.model.objects.all()
page = self.paginate_queryset(queryset)
if page is not None:
serializer = self.get_serializer(page, many=True)
return self.get_paginated_response(serializer.data)
serializer = self.get_serializer(queryset, many=True)
return Response(serializer.data)
@osw4l
osw4l / _commands.sh
Last active October 19, 2020 11:43
django_deploy
# first steps if you have locales issues
sudo dpkg-reconfigure locales
sudo apt install language-pack-en
sudo locale-gen en_US en_US.UTF-8
nano /etc/default/locale
LANG=en_US.UTF-8
LC_ALL="en_US.UTF-8”
LANGUAGE="en_US:en"
# first steps :)
server {
server_name domain.com;
location / {
proxy_pass http://localhost:4500;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
@osw4l
osw4l / consumer.py
Created April 1, 2020 23:06
ws channels v1 example <3
from channels import Group
from channels.auth import channel_session_user_from_http
from channels.sessions import channel_session
from apps.calls.models import Contacto
@channel_session_user_from_http
def connect_update_contacto(message, pk):
contacto = Contacto.objects.get(id=pk)
@osw4l
osw4l / commands.sh
Last active July 24, 2024 02:54
deploy django-osw4l 2020
sudo su -
# update so
sudo apt update
sudo apt upgrade
# install curl
sudo apt install curl
#install docker-compose via curl