Skip to content

Instantly share code, notes, and snippets.

View syrusakbary's full-sized avatar
💪
Building @wasmerio

Syrus Akbary syrusakbary

💪
Building @wasmerio
View GitHub Profile
# 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)
@syrusakbary
syrusakbary / schema_query.py
Last active October 9, 2015 18:06
ObjectType Fields order
from graphql.core import graphql
from graphql.core.type import (
GraphQLObjectType,
GraphQLField,
GraphQLString,
GraphQLSchema,
GraphQLNonNull,
)
humanType = GraphQLObjectType(
@syrusakbary
syrusakbary / graphene_gevent.py
Created January 8, 2016 23:41
Gevent executor example with Graphene
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()
from gdom.cmd import parse
QUERY = '''{
# Whatever you want to query
}'''
print parse(QUERY, None, None)
import graphene
from graphene import relay
from graphene.core.classtypes import UnionType
schema = graphene.Schema(name='Starwars Relay Schema')
class Adjective(relay.Node):
@syrusakbary
syrusakbary / Prepareable.py
Created September 9, 2016 04:36
Prepareable
import sys
import inspect
from functools import wraps
import six
class Prepareable(type):
if not six.PY3:
def __new__(cls, name, bases, attributes):
import graphene
from graphene import relay
from graphene_sqlalchemy import SQLAlchemyObjectType, SQLAlchemyConnectionField
class Employee(SQLAlchemyObjectType):
class Meta:
model = EmployeeModel
interfaces = (relay.Node, )
@syrusakbary
syrusakbary / README.md
Last active June 15, 2017 23:35
Async/Await examples

This is a comparison of the different async/await strategies.

Python is the only language that doesn't execute the coroutines/tasks until you await for them.

@syrusakbary
syrusakbary / main.rs
Created January 21, 2019 21:27 — forked from lachlansneff/main.rs
Wasmer Rust Embedder App Example
extern crate wasmer_clif_backend;
extern crate wasmer_runtime;
use std::{
fs::File,
io::prelude::*,
str,
};
use wasmer_clif_backend::CraneliftCompiler;
@syrusakbary
syrusakbary / wasmer_cache.rs
Last active February 14, 2019 20:13
Wasmer cache example
// This is an example on how a cache system could work.
// It enforces a very useful pattern for caching:
// - serializing (cache.save)
// - deserializing (cache.load)
// This abstracts the responsibility on how to load or how to save
// outside, so it can be a FileSystem, a HashMap in memory, ...
// We get the hash from the binary
let hash: WasmHash = get_wasm_hash(&wasm_binary);