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
  • 09:12 (UTC +01:00)
View GitHub Profile
@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
@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
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 / countryinfo.py
Created April 3, 2019 16:00 — forked from pamelafox/countryinfo.py
Python list of country codes, names, continents, capitals, and pytz timezones
countries = [
{'timezones': ['Europe/Andorra'], 'code': 'AD', 'continent': 'Europe', 'name': 'Andorra', 'capital': 'Andorra la Vella'},
{'timezones': ['Asia/Kabul'], 'code': 'AF', 'continent': 'Asia', 'name': 'Afghanistan', 'capital': 'Kabul'},
{'timezones': ['America/Antigua'], 'code': 'AG', 'continent': 'North America', 'name': 'Antigua and Barbuda', 'capital': "St. John's"},
{'timezones': ['Europe/Tirane'], 'code': 'AL', 'continent': 'Europe', 'name': 'Albania', 'capital': 'Tirana'},
{'timezones': ['Asia/Yerevan'], 'code': 'AM', 'continent': 'Asia', 'name': 'Armenia', 'capital': 'Yerevan'},
{'timezones': ['Africa/Luanda'], 'code': 'AO', 'continent': 'Africa', 'name': 'Angola', 'capital': 'Luanda'},
{'timezones': ['America/Argentina/Buenos_Aires', 'America/Argentina/Cordoba', 'America/Argentina/Jujuy', 'America/Argentina/Tucuman', 'America/Argentina/Catamarca', 'America/Argentina/La_Rioja', 'America/Argentina/San_Juan', 'America/Argentina/Mendoza', 'America/Argentina/Rio_Gallegos', 'America/Argentina/Ushuai
@osw4l
osw4l / httpd.conf
Created July 30, 2018 21:49 — forked from jpalala/httpd.conf
my fedora httpd.conf
#
# This is the main Apache HTTP server configuration file. It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.2> for detailed information.
# In particular, see
# <URL:http://httpd.apache.org/docs/2.2/mod/directives.html>
# for a discussion of each configuration directive.
#
# Do NOT simply read the instructions in here without understanding
# what they do. They're here only as hints or reminders. If you are unsure
# download
scp -r [email protected]:/folder ./
# upload
scp -r my_dir/ [email protected]:/folder
@shared_task
def generate_pdf(user_id, body):
user = User.objects.get(id=user_id)
files = body['new_files']
tabs = {}
for pic in files:
file = FileDetail.objects.get(filename=pic['filename'])
tab = file.story_set.get().channel.tab_set.first()
@osw4l
osw4l / attrs_with_values.py
Last active February 14, 2018 23:12
get the number of attributes with values that an object has
class Computer(object):
name = None
serial = None
model = None
kind = None
attrs_with_value = None
def __init__(self, *args, **kwargs):
self.name = kwargs.get('name', None)
self.serial = kwargs.get('serial', None)
@osw4l
osw4l / celery_beat.conf
Last active January 6, 2020 05:53
deploy
[program:celery_beat]
command=/opt/env/bin/celery --app=project.celery:app beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler
directory=/opt/project
user=root
stdout_logfile=/opt/logs/celery_beat/beat.log
stderr_logfile=/opt/logs/celery_beat/beat.error.log
autostart=true
autorestart=true
startsecs=10
function ajax(options) {
return new Promise(function (resolve, reject) {
$.ajax(options).done(resolve).fail(reject);
});
}
then run:
ajax({
url: YOUR_URL,