Skip to content

Instantly share code, notes, and snippets.

🎯
Work until you no longer have to represent yourself.!

Đinh Văn Hoàng hoangsetup

🎯
Work until you no longer have to represent yourself.!
Block or report user

Report or block hoangsetup

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View app.js
const express = require('express');
const bodyParser = require('body-parser');
const jwt = require('jsonwebtoken');
const router = express.Router();
const config = require('./config');
const utils = require('./utils');
const tokenList = {};
const app = express();
router.get('/', (req, res) => {
@hoangsetup
hoangsetup / CustomModuleLoader.ts
Created Apr 26, 2019 — forked from deejayy/CustomModuleLoader.ts
Solves the problem with typescript->javascript compilation and module path aliases (compilerOptions.paths).
View CustomModuleLoader.ts
import customModuleLoader = require('module');
export class CustomModuleLoader {
public cOptions: any = require('../tsconfig.json').compilerOptions;
public replacePaths: any = {};
constructor() {
Object.keys(this.cOptions.paths).forEach(alias => {
this.replacePaths[alias.replace(/\*.?/, '(.*)')] = this.cOptions.paths[alias][0].replace(/\*.?/, '$1');
@hoangsetup
hoangsetup / gist:d4f007e088d6e411aee81e004bf037c4
Created Apr 18, 2019 — forked from 480/gist:3b41f449686a089f34edb45d00672f28
MacOS X + oh my zsh + powerline fonts + visual studio code terminal settings
View gist:d4f007e088d6e411aee81e004bf037c4
1. Install oh my zsh
http://ohmyz.sh/
$ sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
1. Install powerline fonts
https://github.com/powerline/fonts
1. download agnoster theme
https://github.com/mbadolato/iTerm2-Color-Schemes/zipball/master
@hoangsetup
hoangsetup / index.ts
Created Apr 15, 2019
Integrate SQS and Lambda
View index.ts
// Consumer
import {
SQSEvent,
SQSHandler, SQSRecord,
} from "aws-lambda";
import * as Lambda from "aws-sdk/clients/lambda";
import { InvocationRequest, InvocationResponse } from "aws-sdk/clients/lambda";
async function invokeWorkerLambda(record: SQSRecord): Promise<InvocationResponse> {
const lambda = new Lambda({region: process.env.AWS_REGION});
View dynamodb-helpers.js
const AWS = require('aws-sdk')
AWS.config.update({ region: 'us-east-1' })
const { DynamoDB } = AWS
const dynamoDB = new DynamoDB.DocumentClient()
module.exports.query = function (attributeName, attributeValue, tableName) {
const params = {
ExpressionAttributeNames: {
[`#${attributeName}`]: attributeName
View install_nodejs_and_yarn_homebrew.md

Install NVM, NodeJS, Yarn via Homebrew

Prerequisites

  • Homebrew should be installed (Command line tools for Xcode are included).

Getting start

Install NVM and NodeJS

  1. Install nvm via Homebrew
@hoangsetup
hoangsetup / destructuring.js
Created Feb 18, 2019 — forked from mikaelbr/destructuring.js
Several demos and usages for ES6 destructuring. Runnable demos and slides about the same topic: http://git.mikaelb.net/presentations/bartjs/destructuring
View destructuring.js
// === Arrays
var [a, b] = [1, 2];
console.log(a, b);
//=> 1 2
// Use from functions, only select from pattern
var foo = () => [1, 2, 3];
View gist:152c18b89fe10e489cc9b5921215ab6d
# first:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following:
# go to /usr/local/lib and delete any node and node_modules
cd /usr/local/lib
sudo rm -rf node*
@hoangsetup
hoangsetup / class_decorator.ts
Created Nov 27, 2018 — forked from remojansen/class_decorator.ts
TypeScript Decorators Examples
View class_decorator.ts
function logClass(target: any) {
// save a reference to the original constructor
var original = target;
// a utility function to generate instances of a class
function construct(constructor, args) {
var c : any = function () {
return constructor.apply(this, args);
}
@hoangsetup
hoangsetup / git-reset-author.sh
Created Oct 24, 2018 — forked from bgromov/git-reset-author.sh
Git: reset author for ALL commits
View git-reset-author.sh
#!/bin/sh
# Credits: http://stackoverflow.com/a/750191
git filter-branch -f --env-filter "
GIT_AUTHOR_NAME='Newname'
GIT_AUTHOR_EMAIL='new@email'
GIT_COMMITTER_NAME='Newname'
GIT_COMMITTER_EMAIL='new@email'
" HEAD
You can’t perform that action at this time.