Skip to content

Instantly share code, notes, and snippets.

Avatar

Thada Wangthammang mildronize

View GitHub Profile
@mildronize
mildronize / README.md
Last active Nov 18, 2020
Git cheat sheet
View README.md

Deleting local branches

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

git branch -d test
@mildronize
mildronize / README.md
Created Nov 9, 2020
Typescript Design pattern
View README.md
@mildronize
mildronize / README.md
Created Nov 9, 2020
Check if an Object is a Promise in JavaScript
View README.md
View global-store.ts
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 Nov 6, 2020
Example usage of ReflectiveInjector in `injection-js` ( Angular 4 API) read more: https://v4.angular.io/api/core/ReflectiveInjector ( @Injectable should separate file)
View ReflectiveInjector.ts
import 'reflect-metadata';
import { ReflectiveInjector, Injectable, Injector } from 'injection-js';
class Service {
get() {
return "my service";
}
}
class Service2 {
@mildronize
mildronize / instance-loader.ts
Created Nov 2, 2020
Creating TypeScript Classes Dynamically - Totally based on Steve Fenton solution (Type Safe)
View instance-loader.ts
// 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 {
View logger.ts
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 });
});
View d3-force-graph.html
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v4.min.js" > </script>
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<style>
body {
overflow:hidden;
You can’t perform that action at this time.