Skip to content

Instantly share code, notes, and snippets.

View tuanna-hsp's full-sized avatar
🏠
Working from home

Nguyễn Anh Tuấn tuanna-hsp

🏠
Working from home
View GitHub Profile
@tuanna-hsp
tuanna-hsp / Internal-design-characteristics.md
Last active September 21, 2016 06:50
From "Code Complete 2nd"

#Minimal complexity The primary goal of design should be to minimize complexity for all the reasons just described. Avoid making “clever” designs. Clever designs are usually hard to understand. Instead make “simple” and “easy-to-understand” designs. If your design doesn’t let you safely ignore most other parts of the program when you’re immersed in one specific part, the design isn’t doing its job.

#Ease of maintenance Ease of maintenance means designing for the maintenance programmer. Continually imagine the questions a maintenance programmer would ask about the code you’re writing. Think of the maintenance programmer as your audience, and then design the system to be self-explanatory.

#Loose coupling Loose coupling means designing so that you hold connections among different parts of a program to a minimum. Use the principles of good abstractions in class interfaces, encapsulation, and information hiding to design classes with as few interconnections as possible. Minimal connectedness minimizes work du

@tuanna-hsp
tuanna-hsp / Unity.gitignore
Created March 22, 2017 14:57
Unity .gitignore template
# =============== #
# Unity generated #
# =============== #
Temp/
Library/
# ===================================== #
# Visual Studio / MonoDevelop generated #
# ===================================== #
ExportedObj/
@tuanna-hsp
tuanna-hsp / RomanToInteger.java
Created February 16, 2020 00:18
Roman to integer
class Solution {
private int symbolValue(char ch) {
switch (ch) {
case 'I':
return 1;
case 'V':
return 5;
case 'X':
return 10;
case 'L':
@tuanna-hsp
tuanna-hsp / IsSubsequence.java
Created February 16, 2020 00:21
Is subsequence
class Solution {
public boolean isSubsequence(String s, String t) {
if (s.isEmpty()) {
return true;
}
int lastBreak = 0;
int sIndex = 0;
int tIndex = 0;
int sLength = s.length();
@tuanna-hsp
tuanna-hsp / Minesweeper.java
Created February 16, 2020 00:22
Minesweeper
class Solution {
int width;
int height;
Queue<Point> q;
HashSet<Integer> h;
class Point {
int x;
<template>
<div>
<form ref="form" class="mt-4" autocomplete="off" @submit.stop.prevent="handleSubmit">
<div v-for="attr in allAttributes" :key="attr">
<form-input-integration
v-model="$v.form[attr].$model"
:attribute-name="attr"
:state="validateForm(attr)"
/>
</div>
<template>
<div>
<form ref="form" class="mt-4" autocomplete="off" @submit.stop.prevent="handleSubmit">
<div v-for="attr in allAttributes" :key="attr">
<form-input-integration
v-model="$v.form[attr].$model"
:attribute-name="attr"
:state="validateForm(attr)"
/>
</div>
<script lang="ts">
import Vue, { PropType } from "vue";
import { requiredIf } from "vuelidate/lib/validators";
export default Vue.extend({
validations() {
const form: { [rule: string]: any } = {};
this.allAttributes.forEach(attr => {
form[attr] = {
required: requiredIf(function(this: any): boolean {
<script lang="ts">
export default Vue.extend({
watch: {
saas: {
immediate: true,
handler(value): void {
if (value) {
// Clear current attr values
this.clearFormAttributes();
// Initialize form attributes for new service, note that we must use $set to preserve Vue reactiviy on `form` object
@tuanna-hsp
tuanna-hsp / factory.example.ts
Last active December 15, 2021 04:13
Factory class example
class AggregationService {
constructor(private readonly clientFactory: AggregationClientFactory) {}
public processRequest(request: AggregationRequest): void {
const client = this.clientFactory.createClient(request.serviceName);
if (request.type === "getAccounts") {
const result = client.getAccounts();
// Save result
}