Skip to content

Instantly share code, notes, and snippets.

View dpineiden's full-sized avatar

David Pineda dpineiden

View GitHub Profile
@dpineiden
dpineiden / django-image-error
Created May 5, 2018 20:33
Django Image saved with scripting
ruta_img = img_propiedad_tuple[1]
with open(os.path.join(path,ruta_img),'r+b') as im:
imagen = ImageFile(im)
print("Imagen: %s" %imagen)
print("Imagen: %s" %type(imagen))
print("Image opened: %"%im)
new_img_propiedad.imagen = imagen
new_img_propiedad.etiqueta = img_propiedad_tuple[2]
new_img_propiedad.principal = img_propiedad_tuple[3]
new_img_propiedad.propiedad = Propiedad.objects.get(id = IDs['propiedad'][img_propiedad_tuple[4]])
@dpineiden
dpineiden / deff.py
Created April 22, 2018 09:31
how to define python function with args
def curl(url):
bs4(url)
def curl2(**kwargs):
url = kwargs['url']
bs4(url)
@dpineiden
dpineiden / example_postgres.sql
Created March 12, 2018 14:12
Postgresql Schemma with triggers and procedures
%%Create a tablespace
CREATE SCHEMA IF NOT EXISTS stations AUTHORIZATION david;
\dt stations.*
#DEfault:
SET search_path = stations;
CREATE TABLE IF NOT EXISTS stations.equipment(
id bigserial PRIMARY KEY ,
name varchar(50),
model varchar(50),
import argparse
parser=argparse.ArgumentParser(description="Obtener parámetros de operación")
parser.add_argument('--group',
type=int,
help="Select the group of stations {0,1,2,3}",
choices=[0,1,2,3])
;; -*- mode: emacs-lisp -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Configuration Layers declaration.
You should not put any user code in this function besides modifying the variable
values."
(setq-default
;; Base distribution to use. This is a layer contained in the directory
;; -*- mode: emacs-lisp -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Configuration Layers declaration.
You should not put any user code in this function besides modifying the variable
values."
(setq-default
;; Base distribution to use. This is a layer contained in the directory
@dpineiden
dpineiden / pyqt_dbus.py
Last active November 20, 2022 02:54
PyQt example with Dbus, asyncio and multiprocessing. Send data using DBus standar
"""
Example with Signal-Slot system from QT
When generate data, sends and load on the Gui's text widget
"""
import sys
from PyQt5.QtCore import QObject, pyqtSignal, QSharedMemory
from PyQt5.QtWidgets import QApplication
from PyQt5.QtWidgets import QMainWindow
$('.place.modal')
.modal({
allowMultiple: true
})
;
$('.second.modal')
.modal('attach events', '.first.modal #btn_new_localization')
;
@dpineiden
dpineiden / nginx django channels
Created November 14, 2017 14:39
nginx django channels
# Enable upgrading of connection (and websocket proxying) depending on the
# presence of the upgrade field in the client request header
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream wscada {
# fail_timeout=0 means we always retry an upstream even if it failed
# to return a good HTTP response (in case the Unicorn master nukes a
@dpineiden
dpineiden / gist:bb4b8dc7e231d0bbdda036c3fa14c72c
Created July 11, 2017 16:20
d3_graph_tree_example.json
{'children': [{'children': [{'children': ['g'], 'name': 'f'}, {'children': [], 'name': 'h'}], 'name': 'e'}, {'children': [{'children': [{'children': [{'children': [], 'name': 'l'}, {'children': [], 'name': 'm'}], 'name': 'k'}], 'name': 'j'}], 'name': 'i'}, {'children': [{'children': [{'children': [], 'name': 'c'}, {'children': [], 'name': 'd'}], 'name': 'b'}], 'name': 'a'}], 'name': 'PIGRO'}