Skip to content

Instantly share code, notes, and snippets.

View rubinhozzz's full-sized avatar
🏠
Working from home

Ruben Sanchez rubinhozzz

🏠
Working from home
View GitHub Profile
@rubinhozzz
rubinhozzz / postgresql_upgrade
Created May 8, 2020 12:02
Upgrade for postgresql versions
1. pg_lsclusters
2. Stop all clusters, even the new one you want to use.
pg_ctlcluster <version> main stop
3. cd /tmp
4. sudo -H -u postgres /usr/lib/postgresql/12/bin/pg_upgrade \
-b /usr/lib/postgresql/10/bin \
@rubinhozzz
rubinhozzz / naming_conventions.txt
Created August 15, 2019 14:40
Naming conventions
Database
--------
Functions (sp_)
Triggers (tr_)
@rubinhozzz
rubinhozzz / pgadmin4_installation.txt
Last active May 6, 2024 15:20
Configuration pgadmin4, Gunicorn and NGINX
1. Download wheel (last version)
https://www.pgadmin.org/download/pgadmin-4-python-wheel/
2. Create /opt/pgadmin4
3. Create / activate virtual environment
cd /opt/pgadmin4
python3 -m venv venv
@rubinhozzz
rubinhozzz / fetch_async.js
Last active February 20, 2019 08:49
Sends a request through fetch using async / await.
/**
* Sends a request through fetch using async / await.
* @param {Object} request
*/
async function makeRequestCall(request) {
const response = await fetch(request);
const json = await response.json();
if (!response.ok) {
let error = new Error(response.statusText);
error.response = response;
@rubinhozzz
rubinhozzz / install_pgadmin4
Last active August 19, 2023 16:41
Install pgAdmin4 (Python wheel)
1. Download last version of Python wheel: https://www.pgadmin.org/download/pgadmin-4-python-wheel/
2. Install wheel
mkdir ~/pgadmin4
cd ~/pgadmin4
python3.X -m venv venv
. venv/bin/activate
pip install pgadmin4-X.X-py2.py3-none-any.whl
@rubinhozzz
rubinhozzz / search_form_django_bootstrap
Last active March 5, 2019 15:40
Form html structure when searching
{% load widget_tweaks %}
<form class="form-inline">
{% for field in form.visible_fields %}
{% render_field field class='form-control mb-2 mr-sm-2' placeholder=field.label %}
{% endfor %}
<button type="submit" class="btn btn-primary mb-2">{% trans 'Search' %}</button>
</form>
Forms
-----
- Double points at the end of labels.
- By preference use form horizontal.
- Use (*) and bold style for mandatory fields.
- "Save" button must have primary color and be on the very right side.
- "Close" button must have secondary color and be left side of "Save".
- "Delete" button must have danger color and be left side of the whole window.
Tables
{% load widget_tweaks %}
{% load common_tags %}
<form id="form_page" method="POST" action="">
{% csrf_token %}
{% for field in form.hidden_fields %}
{{ field }}
{% endfor %}
{% for field in form.visible_fields %}
{% if field|is_checkbox %}
<div class="form-check">
@rubinhozzz
rubinhozzz / ajax.js
Last active January 9, 2018 09:42
AJAX call example
function makeAjaxCall(url, methodType, callback){
return $.ajax({
url : url,
method : methodType,
dataType : "json"
})
}
let data = serializeForm(document.getElementById('form_pv'));
makeAjaxCall(urlCreatePV, data, 'POST').then(function(respJson){
if (respJson.ok == false)