Skip to content

Instantly share code, notes, and snippets.

View longtth's full-sized avatar

Long NguyenX longtth

View GitHub Profile
@longtth
longtth / concat.vb
Last active October 18, 2016 08:19
Function concat(useThis As Range, Optional delim As String) As String
' this function will concatenate a range of cells and return one string
' useful when you have a rather large range of cells that you need to add up
Dim retVal, dlm As String
retVal = ""
If delim = Null Then
dlm = ""
Else
dlm = delim
End If
@longtth
longtth / vertical_scroll.ahk
Created January 2, 2017 09:37
Cuộn ngang
#IfWinActive, ahk_class ahk_class XLMAIN
LShift & WheelUp::ComObjActive("Excel.Application").ActiveWindow.SmallScroll(0,0,0,1) ; Scroll left.
LShift & WheelDown::ComObjActive("Excel.Application").ActiveWindow.SmallScroll(0,0,1) ; Scroll right.
#IfWinActive
~LShift & WheelUp:: ; Scroll left.
ControlGetFocus, fcontrol, A
Loop 2 ; <-- Increase this value to scroll faster.
SendMessage, 0x114, 0, 0, %fcontrol%, A ; 0x114 is WM_HSCROLL and the 0 after it is SB_LINERIGHT.
return
@longtth
longtth / remote_control.bat
Last active March 11, 2017 10:17
remote control with saved password
@echo off
cmdkey /generic:123.456.789.012 /user:MyDummyID /pass:MyDummyPw
mstsc /v:123.456.789.012
@longtth
longtth / create_TOC.bas
Created September 13, 2017 14:42
Tạo sheet Mục lục trong excel với mỗi link là 1 sheet
Sub CreateTableOfContents()
'Step 1: Declare Variables
Dim i As Long
'Step 2: Delete Previous TOC worksheet if Exists
On Error Resume Next
With Application
.DisplayAlerts = False
.ScreenUpdating = False
End With
Sheets("TOC").Delete
@longtth
longtth / count_file.bat
Created September 15, 2017 15:20
Đếm số lượng file trong các sub-folder và output ra dạng bảng
@echo off
FOR /D %%G in ("*") DO (
PUSHD "%%G"
FOR /F "delims=" %%H in ('dir /a-d /b * ^|find /C /V ""') DO echo %%G %%H>>"..\count.txt"
POPD
)
' rng: Cell chứa chuỗi cần cắt
' c : chuỗi con dùng làm delimiter
' n : vị trí chuỗi con cần lấy (bắt đầu từ 0)
Function TokenizeAt(rng As Range, c As String, n As Integer)
Dim ret As String
If (rng.Cells.Count > 1) Then
ret = "Only allow 1 cell"
End If
using System;
using System.Windows.Forms;
using Project1;
namespace MainForm
{
public partial class MainForm : Form
{
public MainForm()
{
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
NETSH interface set interface name="Ethernet" admin=ENABLE
NETSH interface set interface name="Wi-Fi" admin=DISABLED
REG add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 1 /f
@longtth
longtth / code.cs
Last active February 10, 2018 15:21
private void btnMerge_Click(object sender, EventArgs e)
{
for (int i = 0; i < totalFile; i++)
{
toolStripStatusLabel1.Text = "Processing (" + Convert.ToString(i + 1) + "/" + totalFile + "): " + Path.GetFileName(allLandmark[i]) +"...";
// do something
}
toolStripStatusLabel1.Text = "Processed ("+ totalFile + "/" + totalFile + ")";
MessageBox.Show("Done");