This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bytes" | |
"log" | |
"math/rand" | |
"net" | |
"os" | |
"path/filepath" | |
"time" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Student: | |
def __init__(self, name) -> None: | |
self.Name = name | |
def __str__(self) -> str: | |
return f"Student({self.Name})" | |
def change_student(s: Student): | |
s.Name = "AAA" | |
s = Student("New name") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Student struct { | |
Name string | |
} | |
func (s Student) Display(prefix string) { | |
fmt.Printf("[%s] I'm %s\n", prefix, s.Name) | |
} | |
func ChangeStudentV3(s *Student) { | |
// s.Name = "Kane" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// package vn.com.ntqs.demo.ioc2.business | |
// | |
public class CustomerManagement { | |
private ConsoleLogger logger; | |
public CustomerManagement(ConsoleLogger logger) { | |
this.logger = logger; // dependency injection thông qua constructor | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// package vn.com.ntqs.demo.ioc2.business | |
// | |
public class CustomerManagement { | |
private ConsoleLogger logger; | |
public CustomerManagement() { | |
this.logger = new ConsoleLogger(); // đoạn code quản lý (khởi tạo) đối tượng dependency | |
this.logger.setColorful(true); // đoạn code quản lý (config) đối tượng dependency |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Generic part | |
// | |
public abstract class SimpleCalculator { | |
private static PrintStream log = System.out; | |
private static Scanner cs = new Scanner(System.in); | |
protected int num1, num2; | |
protected int result; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package vn.com.ntqs.demo; | |
import java.io.PrintStream; | |
import java.util.Scanner; | |
public class Main { | |
private static PrintStream log = System.out; | |
private static Scanner cs = new Scanner(System.in); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {localeMixin} from '@/utils/locale-mixin' | |
export default { | |
mixins: [localeMixin] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {localeMixin} from '@/utils/locale-mixin' | |
export default { | |
mixins: [localeMixin], | |
computed: { | |
currentLocale () { | |
return this.$i18n.locale.toUpperCase() | |
} | |
}, | |
methods: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import i18n from '@/locale/i18n' | |
import {mapState} from 'vuex' | |
export var localeMixin = { | |
computed: { | |
...mapState(['app_locale']) | |
}, | |
watch: { | |
app_locale (newValue) { | |
this.$i18n.locale = newValue |
NewerOlder