Skip to content

Instantly share code, notes, and snippets.

View nietzscheson's full-sized avatar

Cristian Angulo nietzscheson

View GitHub Profile
nietzscheson /
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"]
class UserType:
id: strawberry.ID = strawberry.federation.field
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
nietzscheson /
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 / gitlab-locally.txt
Created July 8, 2022 18:22
Gitlab Locally Test Runner
View gitlab-locally.txt
### .gitlab-ci.yml
image: alpine
- 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 /
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 /
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'
View mutation.ts
login(username: "" password: "admin"){
View user.service.ts
import { Injectable, NotFoundException } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { User } from './user.entity';
import { Repository } from 'typeorm';
import { Args } from '@nestjs/graphql';
import { UsersArgs } from './dto/users.args';
import { ResourceArgs } from '../common/dto/resource.args';
import { UserArgs } from './dto/user.args';
import { AuthArgs } from '../auth/dto/auth.args';