Skip to content

Instantly share code, notes, and snippets.

View longtth's full-sized avatar

Long Nguyen longtth

View GitHub Profile
@longtth
longtth / ExcelCleanNonAlphaNumeric.bas
Last active June 4, 2019 14:50
Loại bỏ các kí tự không phải chữ & số (non-alpha-numeric) trong Excel
Function CleanCode(Rng As Range)
Dim strTemp As String
Dim n As Long
For n = 1 To Len(Rng)
Select Case Asc(Mid(UCase(Rng), n, 1))
Case 48 To 57, 65 To 90
strTemp = strTemp & Mid(UCase(Rng), n, 1)
End Select
Next
@longtth
longtth / touch.cmd
Created February 28, 2019 04:00
windows "equivalent" for linux's touch, nhớ add cái này vào trong PATH
@echo off
setlocal enableextensions disabledelayedexpansion
(for %%a in (%*) do if exist "%%~a" (
pushd "%%~dpa" && ( copy /b "%%~nxa"+,, & popd )
) else (
type nul > "%%~fa"
)) >nul 2>&1
@longtth
longtth / open-wsl-terminal-here.js
Created February 20, 2019 16:23
để thêm menu Open WSL-Terminal Here vào context menu
var WshShell = new ActiveXObject("WScript.Shell");
WshShell.CurrentDirectory = "..";
WshShell.RegWrite("HKCU\\Software\\Classes\\Directory\\shell\\open-wsl\\", "Open wsl-terminal Here", "REG_SZ");
WshShell.RegWrite("HKCU\\Software\\Classes\\Directory\\shell\\open-wsl\\Icon", "\"" + WshShell.CurrentDirectory + "\\open-wsl.exe\"", "REG_SZ");
WshShell.RegWrite("HKCU\\Software\\Classes\\Directory\\shell\\open-wsl\\command\\"
, "\"" + WshShell.CurrentDirectory + "\\open-wsl.exe\" -W \"%V\"", "REG_SZ");
WshShell.RegWrite("HKCU\\Software\\Classes\\Directory\\Background\\shell\\open-wsl\\", "Open wsl-terminal Here", "REG_SZ");
WshShell.RegWrite("HKCU\\Software\\Classes\\Directory\\Background\\shell\\open-wsl\\Icon", "\"" + WshShell.CurrentDirectory + "\\open-wsl.exe\"", "REG_SZ");
WshShell.RegWrite("HKCU\\Software\\Classes\\Directory\\Background\\shell\\open-wsl\\command\\"
longwsl@DESKTOP-3NGNNKU:~$ sudo apt-get install p7zip-full
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package p7zip-full is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'p7zip-full' has no installation candidate
@longtth
longtth / deploy-aspnet-web-using-WebDeploy-in-VisualStudio.md
Last active January 29, 2019 16:51
deploy-aspnet-web-using-WebDeploy-in-VisualStudio

Deploy asp.net website bằng WebDeploy trong Visual Studio 2017

Bên đội dev web bằng PHP (Wordpress) các thứ thì thường dùng FTP (FTPS/SFTP) để deploy web, asp.net web cũng có thể deploy bằng FTP được, tuy nhiên, với truyền thống eat your own s* của mình, các bạn Microsoft vẫn chế cho Visual Studio 1 phương thức "chính thống" để deploy web đó là Web Deploy, ngoài việc deploy bằng cách "chép file" như các trình deploy trên nền FTP, WebDeploy còn hỗ trợ deploy trực tiếp lên SQL Server trong 1 click, tham khảo link này để biết thêm chi tiết.

Trong bài này mình sẽ hướng dẫn cách deploy cái web đơn giản không có SQL Server trước,

Nguyên liệu

  1. Dev environment:
    1. Visual studio 2017
    2. Code của 1 cái asp.net website đã chạy được :)
  2. Nếu bạn làm việc ở công ty thì cần: Quyền remote, kết nối được qua port 80, 443, và remote (3389) đến server, nếu làm ở web server cá nhân (thường mở full port) thì không cần care.
@longtth
longtth / symlink-in-windows.md
Created January 21, 2019 02:03
Tạo symlink trong windows
## Client log
--------------------------------------------------------------------------------
Status: Connecting to 10.89.252.76:990...
Status: Connection established, initializing TLS...
Status: Verifying certificate...
Status: TLS connection established, waiting for welcome message...
Status: Logged in
Status: Retrieving directory listing...
Status: Disconnected from server
Command: PWD
@longtth
longtth / CloneObject.cs
Created December 27, 2018 04:19
để làm được như này ```cs MyObject myObj = new MyObject(); // Create and fill a new object MyObject newObj = CloneObject(myObj); ```
public static object CloneObject(object o)
{
Type t = o.GetType();
PropertyInfo[] properties = t.GetProperties();
Object p = t.InvokeMember("", System.Reflection.BindingFlags.CreateInstance,
null, o, null);
foreach (PropertyInfo pi in properties)
{
@longtth
longtth / migrate.bat
Created December 13, 2018 01:01
migrate file
robocopy <SOURCE> <DESTINATION> /E /ZB /Sec:all /dcopy:T /W:3 /R:5 /LOG:c:\robocopy.log /TEE /V
@longtth
longtth / robo-copy.ps1
Created October 10, 2018 08:57
Đồng bộ 2 folder sử dụng robocopy
robocopy \\SourceServer\Share \\DestinationServer\Share /MIR /FFT /Z /XA:H /W:5