Skip to content

Instantly share code, notes, and snippets.

import { action, observable } from 'mobx';
class LoginStore {
@observable public email = '';
@observable public password = '';
@observable public isValid = false;
@observable public emailError : string | undefined = '';
@observable public passwordError : string | undefined = '';
@action
var path = require('path');
var lodash = require('lodash');
var app = require(path.resolve(__dirname, '../server/server'));
var models = require(path.resolve(
__dirname,
'../server/model-config.local.js'
));
function autoMigrateAll(dataSourceName) {
@sofyan-ahmad
sofyan-ahmad / poi.config.ts
Created July 18, 2018 11:26
poi.config.ts sample !!FOR EXPERIMENTAL ONLY!!
import { Options } from 'poi';
import * as VueLoaderPlugin from 'vue-loader/lib/plugin';
const options: Options = {
entry: './src/main.ts',
html: {
title: 'Vuex with TypeScript example',
template: './index.html',
},
homepage: '.',
@sofyan-ahmad
sofyan-ahmad / 01-yarn.config
Created October 21, 2018 07:45
AWS Elasticbeasnstalk NodeJS 10.x and Yarn
# file: .ebextensions/01-yarn.config
commands:
01_create_npmrc:
# run this command from /tmp directory
cwd: /tmp
command: 'sudo touch /tmp/.npmrc \
| sudo echo \
"//registry.npmjs.org/:_authToken=$(sudo /opt/elasticbeanstalk/bin/get-config environment -k NPM_TOKEN)" \
| sudo tee /tmp/.npmrc'
— Step 1: Create CSV table with dummy header column as first row.
CREATE TABLE table_csv_export_data
ROW FORMAT DELIMITED FIELDS TERMINATED BY ‘,’
LINES TERMINATED BY ‘\n’
STORED as textfile
AS
select
‘id’ as id
,’first_name’ as first_name
@sofyan-ahmad
sofyan-ahmad / keycloak-connect.d.ts
Created February 25, 2019 05:10
Type definitions for keycloak-connect 4.8.3
// Type definitions for keycloak-connect 4.8.3
// Project: https://github.com/keycloak/keycloak-nodejs-connect, http://keycloak.org
// Definitions by: Sofyan Hadi Ahmad <https://github.com/sofyanhadia>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.2.4
declare module 'keycloak-connect' {
import { RequestHandler, Request, Response } from 'express';
declare class KeycloakConnect {
@sofyan-ahmad
sofyan-ahmad / AWS Lambda Invoke NestJS Sample
Last active June 19, 2019 03:38
AWS Lambda Invoke NestJS Sample, main method: private async invoker
import { HttpException, Injectable } from '@nestjs/common';
import { Lambda } from 'aws-sdk';
import UserRepresentation from 'keycloak-admin/lib/defs/userRepresentation';
@Injectable()
export class AccountService {
private realm: string = process.env.KEYCLOAK_REALM;
private lambda: Lambda = new Lambda({
region: process.env.AWS_REGION,

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.

Steps

  • Spin up and configure a Ubuntu AMI
  • Install and configure Keycloak with an SSL cert
@sofyan-ahmad
sofyan-ahmad / Git Clone Sub-Directory Only.md
Last active August 20, 2019 10:43
Git Clone Sub-Directory Only
 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}}
@sofyan-ahmad
sofyan-ahmad / lambda.invoker.ts
Created February 27, 2020 05:52
AWS Lambda Invoker | NestJS | TypeScript
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 };