This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import graphene | |
| from graphene import relay | |
| from graphene_sqlalchemy import SQLAlchemyObjectType, SQLAlchemyConnectionField | |
| class Employee(SQLAlchemyObjectType): | |
| class Meta: | |
| model = EmployeeModel | |
| interfaces = (relay.Node, ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| import inspect | |
| from functools import wraps | |
| import six | |
| class Prepareable(type): | |
| if not six.PY3: | |
| def __new__(cls, name, bases, attributes): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import graphene | |
| from graphene import relay | |
| from graphene.core.classtypes import UnionType | |
| schema = graphene.Schema(name='Starwars Relay Schema') | |
| class Adjective(relay.Node): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from gdom.cmd import parse | |
| QUERY = '''{ | |
| # Whatever you want to query | |
| }''' | |
| print parse(QUERY, None, None) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from collections import OrderedDict | |
| from graphql.core.execution.executor import Executor | |
| from graphql.core.execution.middlewares.gevent import GeventExecutionMiddleware, run_in_greenlet | |
| import graphene | |
| class Patron(graphene.ObjectType): | |
| id = graphene.ID() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from graphql.core import graphql | |
| from graphql.core.type import ( | |
| GraphQLObjectType, | |
| GraphQLField, | |
| GraphQLString, | |
| GraphQLSchema, | |
| GraphQLNonNull, | |
| ) | |
| humanType = GraphQLObjectType( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Enter your code here. Read input from STDIN. Print output to STDOUT | |
| n, m = raw_input().split(" ") | |
| n = int(n) | |
| m = int(m) | |
| tickets = map(lambda x: int(x), raw_input().split(" ")) | |
| # n, m = 2, 4 | |
| # tickets = [5, 2] | |
| sorted_tickets = sorted(tickets, reverse=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| canAutoPlay = null | |
| do -> | |
| mp3 = 'data:audio/mpeg;base64,/+MYxAAAAANIAUAAAASEEB/jwOFM/0MM/90b/+RhST//w4NFwOjf///PZu////9lns5GFDv//l9GlUIEEIAAAgIg8Ir/JGq3/+MYxDsLIj5QMYcoAP0dv9HIjUcH//yYSg+CIbkGP//8w0bLVjUP///3Z0x5QCAv/yLjwtGKTEFNRTMuOTeqqqqqqqqqqqqq/+MYxEkNmdJkUYc4AKqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq'; | |
| wav = 'data:audio/wav;base64,UklGRsYAAABXQVZFZm10IBAAAAABAAEAQB8AAIA+AAACABAAZGF0YaIAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAA='; | |
| audio = new Audio() | |
| canAutoPlay = false | |
| src = if !!audio.canPlayType('audio/wav') then wav else mp3 | |
| audio.autoplay = true | |
| audio.volume = 0 | |
| audio.onplay = -> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var AUTOPLAY = false; | |
| var mp3 = 'data:audio/mpeg;base64,/+MYxAAAAANIAUAAAASEEB/jwOFM/0MM/90b/+RhST//w4NFwOjf///PZu////9lns5GFDv//l9GlUIEEIAAAgIg8Ir/JGq3/+MYxDsLIj5QMYcoAP0dv9HIjUcH//yYSg+CIbkGP//8w0bLVjUP///3Z0x5QCAv/yLjwtGKTEFNRTMuOTeqqqqqqqqqqqqq/+MYxEkNmdJkUYc4AKqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq'; | |
| var wav = 'data:audio/wav;base64,UklGRsYAAABXQVZFZm10IBAAAAABAAEAQB8AAIA+AAACABAAZGF0YaIAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAA='; | |
| try { | |
| var audio = new Audio(); | |
| var src = audio.canPlayType('audio/wav') ? wav : mp3; | |
| audio.autoplay = true; | |
| audio.volume = 0; | |
| audio.onplay = function() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import gc | |
| def queryset_iterator(queryset, chunksize=1000): | |
| ''''' | |
| Iterate over a Django Queryset ordered by the primary key | |
| This method loads a maximum of chunksize (default: 1000) rows in it's | |
| memory at the same time while django normally would load all rows in it's | |
| memory. Using the iterator() method only causes it to not preload all the | |
| classes. |