Skip to content

Instantly share code, notes, and snippets.

View camilonova's full-sized avatar

Camilo Nova camilonova

View GitHub Profile
@camilonova
camilonova / gist:8c44139b1f632fff54cf92af27c5e735
Created September 8, 2018 20:50
setup visual studio for python development
$ brew install python3
$ python3.7 get-pip.py
at vscode:
Install Python extension
Configure flake8 linter
Install code command in path
Install Spacegray extension
set Source Code Pro font at 13px
@camilonova
camilonova / README.md
Last active April 26, 2018 14:17
Enable WAL replication on postgres 10

Setup master server:

Create a user for the replication:

$ psql postgres
postgres=# CREATE USER replica REPLICATION LOGIN ENCRYPTED PASSWORD 'so-secret';

Change your postgres.conf:

@camilonova
camilonova / README.md
Last active April 18, 2018 23:16
Create a video using Gource
  1. Generar video:

gource -1920x1080 --title "Osaki" --logo axiacore-logo-small.png --user-image-dir .git/avatar/ --font-size 18 --seconds-per-day 0.3 --auto-skip-seconds 0.1 --disable-progress --stop-at-end -output-ppm-stream - | ffmpeg -y -r 60 -f image2pipe -vcodec ppm -i - -vcodec libx264 -preset ultrafast -pix_fmt yuv420p -crf 1 -threads 0 -bf 0 video.mp4

gource -1920x1080 --title "Osaki" --logo axiacore-logo-small.png --user-image-dir .git/avatar/ --auto-skip-seconds 1 --seconds-per-day 0.5 --hide mouse,progress -o - | ffmpeg -y -r 60 -f image2pipe -vcodec ppm -i - -vcodec libx264 -preset ultrafast -pix_fmt yuv420p -crf 1 -threads 0 -bf 0 gource.mp4

  1. Pista de audio

Editar audio en audacity y exportarlo a mp3 con la misma duración del video (maximo 90 segundos)

uptime # uptime and CPU stress
w # or better yet:last |head # who is/has been in
netstat -tlpn # find server role
df -h # out of disk space?
grep kill /var/log/messages # out of memory?
@camilonova
camilonova / script.py
Last active March 28, 2018 22:06
Migrate a django file field to a S3 field
from django.core.files.base import ContentFile
qs = Category.objects.exclude(image='').exclude(image_s3__isnull=False)
count = 0
total = qs.count()
for obj in qs:
new_file = ContentFile(obj.image.file.read())
new_file.name = obj.image.name.split('/')[-1:][0]
obj.image_s3 = new_file
obj.save()
obj.image.file.close()
@camilonova
camilonova / script.sh
Created March 19, 2018 17:38
Upgrade postgres 9.6 to 10
pg_lsclusters
sudo apt install postgresql-10 -y
export LC_CTYPE=en_US.UTF-8 export LC_ALL=en_US.UTF-8
sudo pg_dropcluster 10 main --stop
sudo service nginx stop
sudo pg_upgradecluster 9.6 main
sudo pg_dropcluster 9.6 main
sudo service nginx start
@camilonova
camilonova / script.py
Created March 7, 2018 23:24
Wrap html text if does not have a tag
from bs4 import BeautifulSoup
def wrap(to_wrap, wrap_in):
contents = to_wrap.replace_with(wrap_in)
wrap_in.append(contents)
for obj in Post.objects.all():
soup = BeautifulSoup(obj.content, 'html.parser')
for item in soup.children:
if item.name is None:
@camilonova
camilonova / gist:9e3c0f3b15d26a7e2a7d9b43de7daaab
Created November 16, 2017 23:46
create a 3.6 virtualenv
virtualenv test --python=/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6
@camilonova
camilonova / README.md
Created November 9, 2017 21:09
How to make nginx password protected

Run this on the shell:

sudo sh -c "echo -n 'sammy:' >> /etc/nginx/.htpasswd"
sudo sh -c "openssl passwd -apr1 >> /etc/nginx/.htpasswd"

Change nginx file to:

    location / {
 ...
@camilonova
camilonova / deploy.sh
Created August 26, 2017 21:00
Deploy multiple sites with uwsgi
npm install
bower install
gulp compile-sass
. ../bin/activate
pip install -r requirements.txt
python manage.py collectstatic --noinput
python manage.py compilemessages