Skip to content

Instantly share code, notes, and snippets.

View nietzscheson's full-sized avatar

Cristian Angulo nietzscheson

View GitHub Profile
{ pkgs ? import <nixpkgs> {} }:
let
pythonEnv = pkgs.python311.withPackages (ps: [
ps.pip
ps.debugpy
ps.ipython
ps.numpy
ps.setuptools
]);
@nietzscheson
nietzscheson / easy_broker_properties.py
Created May 1, 2023 17:20
Easy Broker Properties Gist
import os
import json
import unittest
from unittest.mock import MagicMock
from urllib.request import urlopen, Request
class EasyBrokerPropertiesResponse:
def easy_broker_properties_response(self):
api_key = os.environ["API_KEY"]
@strawberry.federation.type(keys=["id"])
class UserType:
id: strawberry.ID = strawberry.federation.field
@classmethod
def resolve_reference(cls, id: strawberry.ID):
return UserType(id)
@strawberry.federation.type(keys=["id"], description="User Type definition")
class ProductType:
@strawberry.federation.type(keys=["id"], extend=True)
class UserType:
id: strawberry.ID =
@strawberry.federation.type(keys=["id"], description="User Type definition")
class ProductType:
id: strawberry.ID
name: str
@strawberry.field
@nietzscheson
nietzscheson / potencial.py
Last active December 13, 2022 17:55
Show if a exponentiation sum of numbers is False or True with the same input
import unittest
def potencial(numbers: str):
to_split = int(len(numbers) / 2)
to_sum = (int(numbers[0:to_split]) + int(numbers[to_split::])) ** 2
if to_sum == int(numbers):
return True
@nietzscheson
nietzscheson / gitlab-locally.txt
Created July 8, 2022 18:22
Gitlab Locally Test Runner
### .gitlab-ci.yml
image: alpine
test:
script:
- echo "Hello Gitlab-Runner"
### Pull Gitlab Runner image
docker run -d \
--name gitlab-runner \
from functools import reduce
import logging
logger = logging.getLogger(__name__)
def quote(subtotal, vat, payment_quantity):
###
logger.INFO("Create a Quote")
total = subtotal + (subtotal * vat)
###
@nietzscheson
nietzscheson / test_case.py
Created June 30, 2021 15:11
Override MEDIA_ROOT configuration
import graphene
import json
import tempfile
import shutil
from draphene.factory import PostFactory, UserFactory
from django.test import override_settings
from graphene_django.utils.testing import GraphQLTestCase
MEDIA_ROOT = tempfile.mkdtemp()
@nietzscheson
nietzscheson / cors.sh
Last active June 22, 2021 23:15
Testing CORS OPTIONS request with cURL
curl \
--verbose --request OPTIONS http://localhost:8000/graphql/ \
--header 'Origin: http://localhost:3000' \
--header 'Access-Control-Request-Headers: Origin, Accept, Content-Type' \
--header 'Access-Control-Request-Method: POST'
mutation{
login(username: "admin@admin.com" password: "admin"){
access_token
}
}