Skip to content

Instantly share code, notes, and snippets.

View mildronize's full-sized avatar

Thada Wangthammang mildronize

View GitHub Profile
@mildronize
mildronize / README.md
Last active June 13, 2021 08:28
My VS Code settings & Extensions

Common

  • [Vim]
    • Disable CTRL+C and CTRL+V
    "vim.handleKeys": {
          "<C-c>": false,
          "<C-v>": false
      }
    
@mildronize
mildronize / README.md
Last active November 18, 2020 01:48
Git cheat sheet

Deleting local branches

git branch -a
# *master
#  test
#  remote/origin/master
#  remote/origin/test

git branch -d test
@mildronize
mildronize / README.md
Created November 9, 2020 09:19
Typescript Design pattern
@mildronize
mildronize / README.md
Created November 9, 2020 06:30
Check if an Object is a Promise in JavaScript
@mildronize
mildronize / global-store.ts
Created November 8, 2020 17:33
Global store
export type Dictionary<T> = {
[key: string]: T;
};
export class GlobalStore {
static get(key: string) {
if (getGlobalStore().data === undefined)
getGlobalStore().data = {};
if (getGlobalStore().data[key] === undefined)
@mildronize
mildronize / ReflectiveInjector.ts
Last active November 6, 2020 03:38
Example usage of ReflectiveInjector in `injection-js` ( Angular 4 API) read more: https://v4.angular.io/api/core/ReflectiveInjector ( @Injectable should separate file)
import 'reflect-metadata';
import { ReflectiveInjector, Injectable, Injector } from 'injection-js';
class Service {
get() {
return "my service";
}
}
class Service2 {
@mildronize
mildronize / instance-loader.ts
Created November 2, 2020 16:36
Creating TypeScript Classes Dynamically - Totally based on Steve Fenton solution (Type Safe)
// Credit
// https://www.stevefenton.co.uk/2014/07/creating-typescript-classes-dynamically
// https://gist.github.com/mfdeveloper/c337408608d6033fde967fc2e76b12c4
interface ObjectKeyString {
[key: string]: any;
}
class InstanceLoader {
@mildronize
mildronize / logger.ts
Created October 27, 2020 06:43
Example for using Winston Logger ( Modify from https://github.com/danielfsousa/express-rest-boilerplate)
const winston = require('winston');
const { format } = winston;
const formatConsole = format.printf(( { message, level, timestamp }: any ) => {
return `${timestamp} ${level}: ${message}`;
});
const formatFile = format.printf(( { message, level, timestamp }: any ) => {
return JSON.stringify({ message, level, timestamp });
});