Skip to content

Instantly share code, notes, and snippets.

Avatar
☁️
Working from home

kuba holak khola

☁️
Working from home
View GitHub Profile
View lambda-offload.py
import lambdalayer.mymodule
def lambda_handler(event, context)
mymodule.offloadedcode(event, context)
View responseMapping.vtl
#if($context.result["User"] == $context.identity.claims.get("email"))
$util.toJson($context.result);
#else
$util.unauthorized()
#end
View useQuery.js
import { useEffect, useState } from "react";
import { API, graphqlOperation } from "aws-amplify";
import * as queries from "../queries";
export const useQuery = query => {
const [loading, setLoading] = useState(true);
const [data, setData] = useState(null);
const getFromAPI = async () => {
const users = await API.graphql(graphqlOperation(queries[query]));
View nc-running-bot-lambda.js
import { APIGatewayEvent, Callback, Context, Handler } from "aws-lambda";
import * as AWS from "aws-sdk";
import axios from "axios";
import * as moment from "moment";
import { QuantifiedSelfLib } from "quantified-self-lib";
import { WebClient } from "@slack/client";
const DOMParser = require("xmldom").DOMParser;
AWS.config.update({
region: "eu-west-1"
View snip2
import React, { Component } from "react";
import Amplify, { API, graphqlOperation, Auth } from "aws-amplify";
import { withAuthenticator } from "aws-amplify-react";
import { createMessage } from "./graphql/mutations";
import { listMessages } from "./graphql/queries";
import { onCreateMessage } from "./graphql/subscriptions";
import config from "./aws-exports";
Amplify.configure(config);
class App extends Component {
View snip
import React, { Component } from "react";
class App extends Component {
state = { messages: [], input: "" };
onInput = e => {
this.setState({ input: e.target.value });
};
onSubmit = e => {
e.preventDefault();
//the real submit action code here
View useAPI.js
import { useState, useEffect } from "react";
import { API } from "aws-amplify";
function useAPI(api, endpoint, settings, method = "get") {
const [data, setData] = useState();
const [loading, setLoading] = useState(true);
async function callAPI() {
const response = await API[method](api, endpoint, settings);
setData(response);
View MyTalksArchive.md

Past:

  • I need my data ASAP - real-time serverless - WE ARE DEVELOPERS WORLD CONGRESS BERLIN 2019
  • Scale it the easy way - introduction to micro frontends - 4Developers Warsaw
  • Real time serverless apps on AWS - GDG POZNAŃ, Touch the clouds #1
  • Amplify your JS superpowers - Poznań Serverless Meetup #2
  • Scale it the easy way - introduction to micro frontends - 4Developers Katowice
  • Scale it the easy way - introduction to micro frontends - meet.js summit 2018
  • Scale it the easy way - introduction to micro frontends - 4Developers Kraków
  • Javascript in the cloud, serverless on AWS - 4Developers Wrocław
View accordion.css
input[type="checkbox"]:not(:checked) ~ * {
display: none;
}
View roadmapper.js
componentDidMount() {
Storage.list("roadmaps/")
.then(result =>
this.setState(
{
projects: result
.filter(e => e.size > 0 && e.key.includes("index.md"))
.map(e => e.key.split("/")[1])
.filter(e => e && e.length > 0)
},
You can’t perform that action at this time.