This file contains hidden or 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 class GreetingDto { | |
static from(input: unknown) { | |
const parsedInput = typeof input === 'string' ? JSON.parse(input) : input; | |
if(!GreetingDto.isValid(parsedInput)) { | |
throw Error('Invalid input type'); | |
} | |
const { greeting } = parsedInput; |
This file contains hidden or 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 { UserDto } from './UserDto'; | |
import { GreetingDto } from './GreetingDto'; | |
export const handler = async (event: any): Promise<GreetingDto> => { | |
const userDto = UserDto.from(event); | |
// safely access user properties | |
const greeting = userDto.isFormal ? | |
`Dear ${userDto.firstName} ${userDto.lastName}, welcome back.` : | |
`Hey ${userDto.firstName} ${userDto.lastName}! Long time no see.`; |
This file contains hidden or 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 { Lambda } from 'aws-sdk'; | |
import { UserDto } from './UserDto'; | |
import { GreetingDto } from './GreetingDto'; | |
const lambda = new Lambda({ | |
apiVersion: '2015-03-31', | |
region: 'us-east-1', | |
}); | |
export const handler = async (event: any) => { |
This file contains hidden or 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 class UserDto { | |
static from(input: unknown) { | |
const parsedInput = typeof input === 'string' ? JSON.parse(input) : input; | |
if(!UserDto.isValid(parsedInput)) { | |
throw Error('Invalid input type'); | |
} | |
// at this point `parsedInput` is guaranteed to match `UserDto` | |
const { firstName, lastName, isFormal } = parsedInput; |
This file contains hidden or 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 { Lambda } from 'aws-sdk' | |
import { GetGreetingRequest, GetGreetingResponse } from './GetGreetingLambda.ts'; | |
(async () => { | |
const lambda = new Lambda({ | |
apiVersion: '2015-03-31', | |
region: 'us-east-1', | |
}); |
This file contains hidden or 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 interface GetGreetingRequest { | |
firstName: string; | |
lastName: string; | |
isFormal: boolean; | |
} | |
export interface GetGreetingResponse { | |
greeting: string; | |
} |
This file contains hidden or 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 node | |
console.log('this is bin!') |
This file contains hidden or 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
# Usage: Place this file in `~/.bash_profile_custom` and append 'source ~/.bash_profile_custom` to `~/.bash_profile` | |
# On macOS terminal, import the profile `solarized_dark_custom.terminal` and on the advanced tab, declare as `xterm-256color` | |
# For other terminals get the theme from: https://ethanschoonover.com/solarized/ | |
#### Custom Prompt #### | |
# Customize ls output | |
alias ls='ls -Fh' | |
# Get last 2 directories |
This file contains hidden or 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
#!/bin/bash | |
# prints colored text | |
print_style () { | |
if [ "$2" == "info" ] ; then | |
COLOR="96m"; | |
elif [ "$2" == "success" ] ; then | |
COLOR="92m"; | |
elif [ "$2" == "warning" ] ; then |
This file contains hidden or 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
#!/bin/bash | |
echo "====== Current Swap ======" | |
sudo swapon -s | |
echo "====== Turning Off Swap ======" | |
sudo swapoff /swapfile | |
echo "====== Allocating 4GB Swap ======" | |
sudo fallocate -l 4G /swapfile | |
echo "====== Making Swap ======" | |
sudo mkswap /swapfile | |
echo "====== Setting Permissions to Root Only ======" |