Skip to content

Instantly share code, notes, and snippets.

View tarasowski's full-sized avatar
:electron:

Dimitri (Dimi) Tarasowski tarasowski

:electron:
View GitHub Profile
@tarasowski
tarasowski / dates.js
Last active November 24, 2018 19:28
Filter by date
const makeYMD = d =>
d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate()
const getYesterday = d =>
makeYMD(new Date(d.setDate(d.getDate() - 1)))
const dates = [
{id: 1, date: makeYMD(new Date())},
{id: 2, date: getYesterday(new Date())},
{id: 3, date: makeYMD(new Date())}
@tarasowski
tarasowski / fp-curry.js
Last active November 6, 2018 09:55
Make it beautiful with strict rules!
/* Rules:
1. No If Statements (only ternary operators are allowed)
2. Function has 0 or 1 Argument
3. Function is a Single Return (can be as big as you like)
4. No Assignments in Function
5. No Side-Effects
6. No Shared Variables
*/
// version #1
@tarasowski
tarasowski / git-tag-delete-local-and-remote.sh
Created October 24, 2018 13:08 — forked from mobilemind/git-tag-delete-local-and-remote.sh
how to delete a git tag locally and remote
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName
@tarasowski
tarasowski / example-swagger-cognito-auth.yaml
Created October 16, 2018 09:15
Cognito swagger example
ShopTokenApi:
Type: AWS::Serverless::Api
Properties:
StageName: prod
DefinitionBody:
swagger: 2.0
info:
title: !Sub ${AWS::StackName}
securityDefinitions:
custom-authorizer:
@tarasowski
tarasowski / generator.js
Created October 16, 2018 06:11
Example for refactoring
const alphabetArray = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('')
const generateLetterSequence = (start, end, alphabet) => {
const positionStart = alphabet.indexOf(start)
const positionEnd = alphabet.indexOf(end) + 1
return alphabet.slice(positionStart, positionEnd)
}
const generateNumberSequence = (start, end) => {
const numberArray = []
@tarasowski
tarasowski / tutorial.md
Created August 15, 2018 13:33 — forked from swalkinshaw/tutorial.md
Designing a GraphQL API

Tutorial: Designing a GraphQL API

This tutorial was created by Shopify for internal purposes. We've created a public version of it since we think it's useful to anyone creating a GraphQL API.

It's based on lessons learned from creating and evolving production schemas at Shopify over almost 3 years. The tutorial has evolved and will continue to change in the future so nothing is set in stone.

@tarasowski
tarasowski / curl.bash
Last active August 14, 2018 14:45
#curl GET request
curl -i -X GET -H "Content-Type:application/json" http://localhost:3000/ -d '{
"userId": "jan001",
"locationId": "001",
"sortNumber": 100000,
"sortNumberIncrement": 10,
"warehouseStart": "a",
"warehouseEnd": "b",
"shelfNumberStart": 1,
"shelfNumberEnd": 4,
"shelfRowStart": "a",
@tarasowski
tarasowski / architecture.js
Last active August 11, 2018 05:43
#Lambda - Clean Architecture
// dynamodb-adapter.js
module.export.save = () => {
// some code here
return dynamodb.putItem(params).promise()
}
// lambda handler
const save = require('./dynamo-adapter').save
const parseUserIdentity = require('./parse-user')
@tarasowski
tarasowski / lambda.js
Last active August 7, 2018 06:01
#Lambda - Boilerplate Lambda Async Testing
////********************************Async Version**********************************************////
// lambda function
let response
module.exports.handler = async(event) => {
try {
response = await Promise.resolve('Works')
} catch (err) {
console.log(err)
@tarasowski
tarasowski / copy-local-to-remote.bash
Created July 19, 2018 15:59
#S3 - Copy Local to Remote
aws s3 cp <local-file-path> s3://<remote-s3-address>