This file contains 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
export const newMessage = subscriptionField('newMessage', { | |
type: nonNull('Message'), | |
subscribe(_, __, ctx) { | |
return ctx.sub.subscribe(`message-${ctx.userId}`); | |
}, | |
resolve(obj: NewMessageEvent) { | |
return obj.message; | |
}, | |
}); |
This file contains 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
export const handler = async (event: SQSEvent) => { | |
const body = JSON.parse(event.body); | |
const subscriptions = await subscriptionRepository.getByRoutingKey(body.routingKey); | |
for(subscription of subscriptions) { | |
const document = parse(subscription.subscription); | |
const subscriptionResult = await subscribe({ | |
schema, | |
document, | |
variableValues: subscription.variables, |
This file contains 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
export const handler = async (event: APIGatewayEvent): Promise<APIGatewayResult> => { | |
const body = JSON.parse(event.body); | |
// ... | |
if (body.type === 'subscribe') { | |
const parsed = parse(body.payload.query); | |
const validated = validate(schema, parsed); | |
if (validated.length > 0) | |
await connection.send(event.requestContext.connectionId, { errors: validated }); | |
await subscribe({ |
This file contains 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
headers: { | |
'Connection': 'upgrade', | |
'Upgrade': 'websocket', | |
'Sec-WebSocket-Protocol': 'graphql-transport-ws', | |
'Sec-WebSocket-Accept': base64( | |
sha1( | |
headers['Web-Socket-Key'] + '258EAFA5-E914-47DA-95CA-C5AB0DC85B11' | |
) | |
), | |
}, |
This file contains 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 { parse } from 'graphql/language'; | |
import { execute } from 'graphql/execution'; | |
import { validate } from 'graphql/validation'; | |
import { schema } from '../graphql'; | |
export const handler = async (event: APIGatewayEvent): Promise<ApiGatewayProxyResult> => { | |
try { | |
const body = JSON.parse(event.body || ''); | |
const parsed = parse(body.query); |
This file contains 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
template<typename T> | |
class RAII | |
{ | |
static_assert(std::is_scalar<T>::value, "RAII can handle only scalars"); | |
private: | |
const T _resource; | |
std::function<void(T)> _destroy; | |
public: | |
RAII(std::function<void(T)> destroy, T resource) noexcept : _resource(resource), _destroy(destroy) | |
{} |
This file contains 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
// Example program | |
#include <iostream> | |
#include <string> | |
using namespace std; | |
template<typename T> | |
class A | |
{ | |
public: |
This file contains 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
#!/usr/bin/env python | |
""" | |
:Author Patrik Valkovic | |
:Created 17.04.2019 12:35 | |
:Licence MIT | |
Part of ML | |
""" | |
import math | |
from random import Random |
This file contains 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
#include <iostream> | |
struct true_type {static const bool value = true;}; | |
struct false_type {static const bool value = false;}; | |
template<bool, bool ...Args> | |
struct and_ : false_type {}; |
This file contains 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 org.apache.hadoop.conf.Configuration; | |
import org.apache.hadoop.fs.Path; | |
import org.apache.hadoop.io.DoubleWritable; | |
import org.apache.hadoop.io.Text; | |
import org.apache.hadoop.mapreduce.Job; | |
import org.apache.hadoop.mapreduce.lib.input.TextInputFormat; | |
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; | |
import java.io.IOException; |
NewerOlder