Skip to content

Instantly share code, notes, and snippets.

View boydaihungst's full-sized avatar
💻

boydaihungst boydaihungst

💻
View GitHub Profile
@boydaihungst
boydaihungst / cloudSettings
Last active August 25, 2020 05:01
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-08-25T05:01:19.422Z","extensionVersion":"v3.4.3"}
@boydaihungst
boydaihungst / launch.json And package.json
Last active October 16, 2020 15:00
Debug nuxtjs (Typescript) using VScode
// launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "client: chrome",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}"
@boydaihungst
boydaihungst / launch.json
Last active April 26, 2023 01:24
Debug Nodejs, typescript, nodemon, webpack, vscode
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "WatchDebug",
"port": 9229,
"restart": true,
@boydaihungst
boydaihungst / index.js
Last active December 27, 2019 06:26
Demo request download timeout
const request = require('request');
const progress = require('request-progress');
const fs = require('fs');
function download(url) {
var timeout;
const rq = request
.get(url)
.on('connect', function(req, cltSocket, head) {
// Set timeout khi vừa connect
@boydaihungst
boydaihungst / Main.js
Created March 31, 2020 07:30
fix jquery validate need to click submit twice to submit form
var form = $('form');
if (form.find('[data-val-remote]').length > 0) {
form.find('[type="submit"]').on("click enter", function (evt) {
var interval = setInterval(function () {
// keep check if there are any remote pending then prevent submit button from click
if (Object.keys($('form').validate().pending).length) {
evt.preventDefault();
} else {
// if all remote were response check form valid or not
if (!form.valid()) {
[When(@"create category has name ""(.*)"" and used in document")]
public void CreateCategoryWithDocument(string categoryName)
{
UnitOfWork unitOfWork = (UnitOfWork)dependencyResolver
.GetService(typeof(UnitOfWork));
var randomUser = unitOfWork.User.GetAll().FirstOrDefault();
using (var transaction = unitOfWork.BeginTransaction())
{
try
var randomUser = unitOfWork.User.GetAll().Where(x => x.Email == "abc").FirstOrDefault();
randomUser.EmailFe = "";
unitOfWork.SaveChanges();
{
"compilerOptions": {
"experimentalDecorators": true,
"target": "ES2018",
"module": "CommonJS",
"moduleResolution": "node",
"esModuleInterop": true,
"emitDecoratorMetadata": true,
"resolveJsonModule": true,
"strictNullChecks": false,
export abstract class RepoBase<T> extends Repository<T> {
async customFind(optionsOrConditions?: FindManyOptions<T> | Partial<T>) {
const connection = this.manager.connection;
const metadata = this.metadata;
if (
metadata.deleteDateColumn &&
optionsOrConditions &&
'withDeleted' in optionsOrConditions &&
!optionsOrConditions.withDeleted
) {
router.beforeEach(async (to, from, next) => {
const localeInParams = getLocaleFromParams(to.params); //DIY
const isNewLocale =
localeInParams !== undefined && localeInParams !== currentLocale;
if (isNewLocale) {
const isNewLocaleSupported = SUPPORT_LOCALES.includes(localeInParams);
if (!isNewLocaleSupported) {
return next(redirectToFallbackLocale(currentLocale, to.fullPath));
}
await localeMessageChange(i18n, localeInParams);