Skip to content

Instantly share code, notes, and snippets.

View epalaz's full-sized avatar

Enes Palaz epalaz

  • Amazon
  • Santa Clara
View GitHub Profile
@epalaz
epalaz / question.md
Last active May 12, 2021 15:47
Interview Question 1

Question Statement

There are several cards arranged in a row, and each card has an associated number of points

The points are given in the integer array cardPoints.

In one step, you can take one card from the beginning or from the end of the row. You have to take exactly k cards.

Your score is the sum of the points of the cards you have taken.

@epalaz
epalaz / AlgorithmQuestion.md
Last active April 19, 2021 17:48
Interview Questions

Lowest Common Ancestor in a Binary Tree

How can you find the lowest common ancestor of 2 given nodes in a binary tree data structure.

Sample Tree

Node:

  • val: int
  • right: Node
  • left: Node
@epalaz
epalaz / question.md
Last active April 16, 2021 19:13
Interview Question Explanation

Create a data structure that will implement the below interface.

Plan { planId: string; planType: string; planYear: int; planName: string; }

addPlan(Plan plan)

@epalaz
epalaz / app.js
Created August 13, 2019 07:44
App.js File for Sample Application
import React from 'react';
import logo from './logo.svg';
import './App.css';
import { InMemoryCache } from 'apollo-cache-inmemory'
import { createUploadLink } from 'apollo-upload-client'
import {ApolloClient} from "apollo-client"
import {ApolloProvider, Mutation} from "react-apollo"
import gql from "graphql-tag"
const apolloCache = new InMemoryCache()
@epalaz
epalaz / clientMutations.js
Created August 13, 2019 07:38
Client Mutations
const UPLOAD_FILE = gql`
mutation SingleUpload($file: Upload!) {
singleUpload(file: $file) {
filename
mimetype
encoding
}
}
`;
@epalaz
epalaz / client.js
Created August 13, 2019 07:33
Apollo Client
const apolloCache = new InMemoryCache()
const uploadLink = createUploadLink({
uri: 'http://localhost:4000', // Apollo Server is served from port 4000
headers: {
"keep-alive": "true"
}
})
@epalaz
epalaz / server.js
Created August 13, 2019 06:56
Server File for GraphQL Server with File Upload
const { ApolloServer, gql } = require('apollo-server');
const AWS = require('aws-sdk')
const fs = require('fs')
AWS.config.loadFromPath('./credentials.json');
const s3 = new AWS.S3({apiVersion: '2006-03-01'});
const typeDefs = gql`
type File {
@epalaz
epalaz / resolvers.js
Last active April 28, 2020 15:16
Resolvers for File Upload Mutations
const resolvers = {
Mutation: {
singleUpload: (parent, args) => {
return args.file.then(file => {
const {createReadStream, filename, mimetype} = file
const fileStream = createReadStream()
fileStream.pipe(fs.createWriteStream(`./uploadedFiles/${filename}`))
@epalaz
epalaz / typeDef.js
Last active September 12, 2020 10:19
Type Definitions for File Upload Mutations
const typeDefs = gql`
type File {
filename: String!
mimetype: String!
encoding: String!
}
type Query {