Skip to content

Instantly share code, notes, and snippets.

View bgarcial's full-sized avatar

Bernardo García bgarcial

  • Amsterdam, Nederland
  • 08:27 (UTC +02:00)
  • LinkedIn in/bgarcial
View GitHub Profile
from django.test import TestCase
from .models import Categoria,Enlace
from django.contrib.auth.models import User
# Create your tests here.
class SimpleTest(TestCase):
def test_es_popular(self):
categoria = Categoria.objects.create(titulo='Categoria de prueba')
course)bgarcial@el-pug:~/python_Devel/course/proyecto_clase2$ python manage.py test app
Creating test database for alias 'default'...
E
======================================================================
ERROR: proyecto_clase2.app.tests (unittest.loader.ModuleImportFailure)
----------------------------------------------------------------------
ImportError: Failed to import test module: proyecto_clase2.app.tests
Traceback (most recent call last):
File "/usr/lib/python2.7/unittest/loader.py", line 252, in _find_tests
module = self._get_module_from_name(name)
@bgarcial
bgarcial / turn_char_to_float.cpp
Last active October 2, 2018 16:47
Turn char to float with overrided stof function
void SerialDriver::draw(const core::visual::VisualParams* vparam)
{
vparam = NULL;
draw();
}
float stof(const char* s){
float rez = 0, fact = 1;
if (*s == '-'){
s++;
@bgarcial
bgarcial / views.py
Last active October 2, 2018 16:56
Using Mixin and Q objects with get_context_data
class SearchView(UserProfileDataMixin, ListView):
template_name = 'search.html'
model = get_user_model()
def get_context_data(self, **kwargs):
query = self.request.GET.get("q")
qs = None
if query:
qs = User.objects.filter(
Q(username__icontains=query) |
from __future__ import unicode_literals
# Importing the libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from sklearn.cluster import KMeans
# Using the elbow method to find the optimal number of clusters to apply to my Sioma data
########### Leemos nuestro datasets SIOMA con todas las variables normalizadas ##########
@bgarcial
bgarcial / sofa_node_peers.py
Created October 2, 2018 16:59
Estableciendo parámetros en un socket ZMQ_SUB creado para reunir cumplimiento de requisitos no funcionales de eficiencia y seguridad en el manejo de conexiones ZMQQ
zmq_VERSION = zmq.zmq_version_info()
anAgentsIDENTITY = whateverHashOrHumanReadableSTRING
notMINE = anAgentsIDENTITY
if zmq_VERSION[0] < 4:
print "ZMQ{0:} ver < than expected, will exit".format( zmq_VERSION )
aCTX = zmq.Context( 2 ) # if performance boosting is needed
#SUB ---------------------------------------------------------------------------
aSUB = aCTX.socket( zmq.SUB )
@bgarcial
bgarcial / sofa_network_manager.py
Created October 2, 2018 17:04
Estableciendo parámetros en sockets ZMQ_PUB y ZMQ_PULL creados para reunir cumplimiento de requisitos no funcionales de eficiencia y seguridad en el manejo de conexiones ZMQQ
pass; zmq_VERSION = zmq.zmq_version_info()
if zmq_VERSION[0] < 4:
print "ZMQ{0:} ver < than expected, will exit".format( zmq_VERSION )
aCTX = zmq.Context( 2 ) # if performance boosting is needed
#PUB ---------------------------------------------------------------------------
aPUB = aCTX.socket( zmq.PUB )
aPUB.setsockopt( zmq.LINGER, 0 ) # protect your server
aPUB.setsockopt( zmq.MAXMSGSIZE, m ) # protect your server from DoS

Keybase proof

I hereby claim:

  • I am bgarcial on github.
  • I am bgarcial (https://keybase.io/bgarcial) on keybase.
  • I have a public key ASBFqlQwD143alNWnAA7qAZxSJkITHPzw9Ny0WclEXowIAo

To claim this, I am signing this object:

@bgarcial
bgarcial / kongwithingress.yaml
Last active January 10, 2024 10:36
Installing kong to work ingress on Kubernetes
apiVersion: v1
kind: Namespace
metadata:
name: kong
---
apiVersion: v1
kind: Secret
metadata:
@bgarcial
bgarcial / README.md
Created March 5, 2019 15:35
How to install cert-manager and start to work with kong

Using cert-manager to work with kong and ingress

cert-manager is a native Kubernetes certificate management controller. It can help with issuing certificates from a variety of sources, such as Let’s Encrypt, HashiCorp Vault, a simple signing keypair, or self signed.

We are going to use Let's Encrypt to issue our zcrm365 certificate