Skip to content

Instantly share code, notes, and snippets.

View upload.controller.ts
import { Body, Controller, HttpException, Post } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { ApiTags } from '@nestjs/swagger';
import AWS from 'aws-sdk';
import { v4 as uuid } from 'uuid';
import { IFileSignedUrl } from './fileSignedUrl.interface';
const s3 = new AWS.S3({ useAccelerateEndpoint: true });
sofyan-ahmad / SignUpBottomSheet.tsx
Created Apr 5, 2020
Animated React Native Sign Up Bottom Sheet
View SignUpBottomSheet.tsx
import {NavigationProp} from '@react-navigation/native';
import {Button, Text} from '@ui-kitten/components';
import React, {useEffect, useState} from 'react';
import {StyleSheet, View} from 'react-native';
import BottomSheet from 'reanimated-bottom-sheet';
export interface ISignUpSheet {
isOpen: boolean;
navigation?: NavigationProp<any, any>;
onClose: (...args: any) => void;
sofyan-ahmad / FadeView.tsx
Last active Apr 1, 2020
React Native Fade View Component using hook
View FadeView.tsx
import React, {useEffect, useRef, useState} from 'react';
import {Animated, StyleProp, ViewStyle} from 'react-native';
export interface IFadeView {
visible: boolean;
children: React.ReactNode;
style?: StyleProp<ViewStyle>;
export function FadeView(props: IFadeView): React.ReactElement {
sofyan-ahmad / Serverless - AWS Calculation.csv
Last active Mar 3, 2020
Serverless, AWS Lambda Calculation
View Serverless - AWS Calculation.csv
Service Rate Cost
Cognito Free $0.00
API Gateway $3.5/M reqs + $0.09/GB transfer $2.20
Lambda Free $0.00
DynamoDB $0.0065/hr 10 write units; $0.0065/hr 50 read units $2.80
S3 $0.023/GB storage; $0.005/K PUT; $0.004/10K GET; $0.0025/M objects $0.24
CloudFront $0.085/GB transfer + $0.01/10K reqs $0.86
Route53 $0.50 per hosted zone + $0.40/M queries $0.50
Certificate Manager Free $0.00
Total $6.10
sofyan-ahmad / lambda.invoker.ts
Created Feb 27, 2020
AWS Lambda Invoker | NestJS | TypeScript
View lambda.invoker.ts
import { HttpException } from '@nestjs/common';
import { Lambda } from 'aws-sdk';
import dotenv = require('dotenv');
import _ from 'lodash';
// Load dot environment
const { parsed } = dotenv.config({
path: process.cwd() + '/.env',
process.env = { ...parsed, ...process.env };
sofyan-ahmad / Git Clone Sub-Directory
Last active Aug 20, 2019
Git Clone Sub-Directory Only
View Git Clone Sub-Directory
 mkdir {{workdir}}
 cd {{workdir}}
 git init 
 git remote add origin {{gitUrl}}
 git config core.sparseCheckout true
 echo "{{clonedSubdir}}/{{clonedSubSubdir}}" >> .git/info/sparse-checkout
 git pull origin
 git checkout {{workingBranch if not master}}
View Install Keycloak

Deploying Keycloak to AWS

The objective of this guide is to deploy Keycloak to EC2 AWS Ubuntu machine.

Mostly this Gist is a distillation of the Keycloak Server Installation guide for a specific use case: to spin up a quick and dirty Keycloak instance for testing and experimenting.


  • Spin up and configure a Ubuntu AMI
  • Install and configure Keycloak with an SSL cert
sofyan-ahmad / AWS Lambda Invoke NestJS Sample
Last active Jun 19, 2019
AWS Lambda Invoke NestJS Sample, main method: private async invoker
View AWS Lambda Invoke NestJS Sample
import { HttpException, Injectable } from '@nestjs/common';
import { Lambda } from 'aws-sdk';
import UserRepresentation from 'keycloak-admin/lib/defs/userRepresentation';
export class AccountService {
private realm: string = process.env.KEYCLOAK_REALM;
private lambda: Lambda = new Lambda({
region: process.env.AWS_REGION,
sofyan-ahmad / keycloak-connect.d.ts
Created Feb 25, 2019
Type definitions for keycloak-connect 4.8.3
View keycloak-connect.d.ts
// Type definitions for keycloak-connect 4.8.3
// Project:,
// Definitions by: Sofyan Hadi Ahmad <>
// Definitions:
// TypeScript Version: 3.2.4
declare module 'keycloak-connect' {
import { RequestHandler, Request, Response } from 'express';
declare class KeycloakConnect {
View gist:f98bd67343faa81cc62fdda3de98eb99
— Step 1: Create CSV table with dummy header column as first row.
CREATE TABLE table_csv_export_data
STORED as textfile
‘id’ as id
,’first_name’ as first_name