Skip to content

Instantly share code, notes, and snippets.

View minhntm's full-sized avatar
:octocat:

Nguyễn Trí Minh minhntm

:octocat:
  • Tokyo
  • 06:53 (UTC +09:00)
View GitHub Profile
@Injectable()
export class AuthzService {
constructor(
@InjectRepository(UserRepository)
private userRepository: UserRepository,
) {}
async findAllPermissionsOfUser(user: User): Promise<Permission[]> {
return await this.userRepository.findAllPermissions(user);
}
}
@minhntm
minhntm / install.sh
Last active September 10, 2021 03:42
Extensible and secure authorization with Nestjs and CASL
$ yarn add @casl/ability
$ nest g module authz
@minhntm
minhntm / keybindings.json
Created May 13, 2021 01:30
vscode settings
// Place your key bindings in this file to overwrite the defaults
[
//terminal
{
"key": "cmd+k",
"command": "workbench.action.focusActiveEditorGroup",
"when": "terminalFocus"
},
{
"key": "cmd+j",
@minhntm
minhntm / Book.vue
Last active December 30, 2020 08:14
How to use Vue's slot
<template>
<div class="book">
<slot name="title"
:bookTitle="bookTitle"
/>
</div>
</template>
<script>
export default {
function uppercase( target: any, name: string, desc: PropertyDescriptor ) {
return {
get: function (): string {
return desc.get?.call( this ).toUpperCase();
},
set: function ( name: string ) {
desc.set?.call( this, name.split(' ') );
}
};
}
@minhntm
minhntm / minesweeper.py
Last active February 16, 2020 13:51
Minesweeper
class Solution:
def updateBoard(self, board: List[List[str]], click: List[int]) -> List[List[str]]:
y = click[0]
x = click[1]
if board[y][x] == 'M':
board[y][x] = 'X'
return board
adjacent_mines = 0
class Solution:
def isSubsequence(self, s: str, t: str) -> bool:
for c in s:
i = t.find(c)
if i == -1:
return False
else:
t = t[i+1:]
return True
@minhntm
minhntm / roman2integer.py
Last active February 16, 2020 10:19
Convert Roman number to Integer number
class Solution:
def romanToInt(self, s: str) -> int:
cv_map = {
'I': 1,
'V': 5,
'X': 10,
'L': 50,
'C': 100,
'D': 500,
'M': 1000
@minhntm
minhntm / .gitattributes
Created November 29, 2019 07:52
Resolving Git line ending issues in containers.
* text=auto eol=lf
*.{cmd,[cC][mM][dD]} text eol=crlf
*.{bat,[bB][aA][tT]} text eol=crlf
@minhntm
minhntm / replace_git_commiter_info.sh
Created August 27, 2019 06:06
Replaces the committer info for all commits in a branch.
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="[email protected]"
CORRECT_NAME="Nguyen Tri Minh"
CORRECT_EMAIL="[email protected]"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then