Skip to content

Instantly share code, notes, and snippets.

View ferminhg's full-sized avatar
🐙
WFH

fermin ferminhg

🐙
WFH
View GitHub Profile
@ferminhg
ferminhg / Dockerfile
Created June 18, 2020 20:07
Run django-orchesta in docker
FROM python:3.6
RUN apt-get -y update && apt-get install -y curl sudo
RUN pip3 install wheel
RUN pip3 install https://github.com/ribaguifi/django-orchestra/tarball/dev/api-docs-swagger#egg=django-orchestra-dev
#RUN export TERM=xterm; curl -L http://git.io/orchestra-admin | bash -s install_requirements
RUN apt-get -y install python3-dev
RUN pip3 install -r https://raw.githubusercontent.com/ribaguifi/django-orchestra/dev/api-docs-swagger/requirements.txt
RUN apt-get clean
@ferminhg
ferminhg / error_docker
Last active June 17, 2020 15:25
Error building docker image
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/libxml2 -I/tmp/pip-install-4tdwv157/lxml/src/lxml/includes -I/usr/include/python3.7m -c src/lxml/lxml.etree.c -o build/temp.linux-x86_64-3.7/src/lxml/lxml.etree.o -w
src/lxml/lxml.etree.c: In function ‘__Pyx_ExceptionSave’:
src/lxml/lxml.etree.c:196371:21: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’?
*type = tstate->exc_type;
^~~~~~~~
curexc_type
src/lxml/lxml.etree.c:196372:22: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_value’; did you mean ‘curexc_value’?
*value = tstate->exc_value;
^~~~~~~~~
curexc_value
> python3 panel/manage.py migrate
Traceback (most recent call last):
File "panel/manage.py", line 13, in <module>
execute_from_command_line(sys.argv)
File "/Users/fermin/projects/ribaguifi/env-django-orchestra/lib/python3.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/Users/fermin/projects/ribaguifi/env-django-orchestra/lib/python3.7/site-packages/django/core/management/__init__.py", line 341, in execute
django.setup()
File "/Users/fermin/projects/ribaguifi/env-django-orchestra/lib/python3.7/site-packages/django/__init__.py", line 27, in setup
#!/bin/bash
set -u
set -e
bold=$(tput -T ${TERM:-xterm} bold)
normal=$(tput -T ${TERM:-xterm} sgr0)
PYTHON_BIN='python3'
@ferminhg
ferminhg / cart_example_v1.py
Last active June 10, 2020 16:59
Builder and Factory example
class Cart:
def __init__(self, user=None):
self.user = user
self.elements = {}
self.discounts = {}
# this is a factory
@staticmethod
def create(user):
#clean architecture layers
# https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html
# ^^you can read read here the beneficts of use this patterns to write better code
# The dependency rule (->): dependencies can only point inwards
# Infrastructure -> Application -> Domain
# Summary: my business logic (domain) don't know infra or apliccation layers
# Use case summary
# Given a slug
console.log("\t\tPair programming Lucia Fermin")
var cities = {
alicante: 96,
valencia: 93,
castellon: 91,
murcia: 68,
teruel: 70,
granada: 88,
gijon: 60,
barcelona: 12,
puts "Enter your first name"
first_name = gets.chomp
puts "Enter your last name"
last_name = gets.chomp
full_name = "#{first_name} #{last_name}"
puts "Your full name si #{full_name}"
puts "Your full name si #{full_name.reverse}"
full_name_len = full_name.gsub(" ", "").length
puts "Your name has #{full_name_len} character in it"
@ferminhg
ferminhg / temperatura.js
Created March 28, 2020 18:56
Ejemplo de funciones
console.clear();
console.log("Welcome to the function jungle 🦌🌳🌲");
// calcular la temperatura actual del salon
// ✅ Obtener un numero aleatorio entre 24-32
// - Obtener random entre el 0-8 y sumarle 24
// ✅ Imprimir "Temperatura: XXºC" donde XX es la temperatura anterior
// ✅ Hacer una funcion que calcule la temperatura_interior y devuela el valor
function obtener_temperatura_interior() {
# "is" vs "=="
>>> a = [1, 2, 3]
>>> b = a
>>> a is b
True
>>> a == b
True