Skip to content

Instantly share code, notes, and snippets.

View praveen001's full-sized avatar
🎯
Focusing

Praveen Raj praveen001

🎯
Focusing
View GitHub Profile
@praveen001
praveen001 / settings.json
Created December 27, 2019 15:00
VSCode Setup - Theme
{
"editor.multiCursorModifier": "ctrlCmd",
"editor.snippetSuggestions": "bottom",
"window.zoomLevel": 0,
"workbench.colorCustomizations": {
"statusBar.background": "#000",
"statusBar.border": "#222",
"statusBar.foreground": "#02bb7d",
"sideBar.background": "#081014",
@praveen001
praveen001 / sameple6.ts
Created January 9, 2020 19:43
Undo/Redo with Immer in Redux
import { ADD_TODO, REMOVE_TODO } from '../actions/todos';
const changes = {};
let currentVersion = -1;
const noOfVersionsSupported = 100;
const undoableActions = [ADD_TODO, REMOVE_TODO];
export default function(state = initialState, action) {
return produce(state, draft => {
// ... code removed for brevity
@praveen001
praveen001 / App1.js
Created January 10, 2020 11:32
Authentication in Serverless React Application using AWS Amplify
import { withAuthenticator } from 'aws-amplify-react';
function App() {
return (
...
)
}
export default withAuthenticator(App, {
includeGreetings: true
@praveen001
praveen001 / .prettierrc
Last active July 15, 2021 23:57
React Clean Architecture
{
"semi": true,
"singleQuote": true,
"trailingComma": "none",
"tabWidth": 2,
"useTabs": false,
"bracketSpacing": true
}
@praveen001
praveen001 / App.tsx
Created January 11, 2020 02:52
Building React App using Material UI with Support for Multiple Switchable Themes
import React, { useContext } from 'react';
import { Button } from '@material-ui/core';
import { ThemeContext} from './ThemeProvider';
const App: React.FC = () => {
// Get the setter function from context
const setThemeName = useContext(ThemeContext)
return (
<div className="App">
@praveen001
praveen001 / controllers.go
Last active August 27, 2021 16:38
How to Pass Database Connection into Controllers in Golang
package controllers
import (
"fmt"
"net/http"
"github.com/techinscribed/repository-db/models"
)
// BaseHandler will hold everything that controller needs
@praveen001
praveen001 / aws-amplify-configure.js
Last active August 12, 2023 07:49
Passwordless Phone number authentication using AWS Amplify and Cognito
import Amplify, { Auth } from 'aws-amplify';
Amplify.configure({
Auth: {
region: 'us-east-1',
userPoolId: '**********',
userPoolWebClientId: '******************',
}
});
@praveen001
praveen001 / authorizer.go
Last active September 17, 2024 01:27
Serverless WebSockets with API Gateway and Golang Lambda
// Authorizer custom api authorizer
func Authorizer(request APIGatewayWebsocketProxyRequest) (events.APIGatewayCustomAuthorizerResponse, error) {
token := request.QueryStringParameters["token"]
// Fetch all keys
jwkSet, err := jwk.Fetch("https://cognito-idp.ap-south-1.amazonaws.com/ap-south-1_vvx4f42sK/.well-known/jwks.json")
if err != nil {
log.Fatalln("Unable to fetch keys")
}
@praveen001
praveen001 / authorizer.go
Last active January 26, 2020 14:38
Serverless WebSockets with API Gateway and Golang Lambda
// Authorizer custom api authorizer
func Authorizer(request APIGatewayWebsocketProxyRequest) (events.APIGatewayCustomAuthorizerResponse, error) {
token := request.QueryStringParameters["token"]
// Fetch all keys
jwkSet, err := jwk.Fetch("https://cognito-idp.us-east-1.amazonaws.com/us-east-1_vvx4f42sK/.well-known/jwks.json")
if err != nil {
log.Fatalln("Unable to fetch keys")
}
@praveen001
praveen001 / connect.go
Last active January 26, 2020 14:40
Serverless WebSockets with API Gateway and Golang Lambda
// Connect will receive the $connect request
// It will handle the authorization also
func Connect(request APIGatewayWebsocketProxyRequest) (interface{}, error) {
if request.RequestContext.Authorizer == nil {
return Authorizer(request)
}
id := request.RequestContext.Authorizer.(map[string]interface{})["cognito:username"].(string)
connectionID := request.RequestContext.ConnectionID
StoreSocket(id, connectionID)