Skip to content

Instantly share code, notes, and snippets.

View dpineiden's full-sized avatar

David Pineda dpineiden

View GitHub Profile
@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
$('.place.modal')
.modal({
allowMultiple: true
})
;
$('.second.modal')
.modal('attach events', '.first.modal #btn_new_localization')
;
@dpineiden
dpineiden / pyqt_dbus.py
Last active January 26, 2025 18:42
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
;; -*- 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
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])
@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),
@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 / 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 / random_string.py
Created July 26, 2018 13:55
Random String generator
import uuid
import shlex
import simplejson as json
import datetime
import random
def random_char():
"""
Alphabetic uppercase and number 0 to 9 on a random
selection