Skip to content

Instantly share code, notes, and snippets.

@khanhkhuu
khanhkhuu / printSelectedRange.js
Last active April 26, 2023 04:25
printSelectedRange.js
const PRINT_OPTIONS = {
'size': 7, // paper size. 0=letter, 1=tabloid, 2=Legal, 3=statement, 4=executive, 5=folio, 6=A3, 7=A4, 8=A5, 9=B4, 10=B
'fzr': false, // repeat row headers
'portrait': true, // false=landscape
'fitw': true, // fit window or actual size
'gridlines': false, // show gridlines
'printtitle': false,
'sheetnames': false,
'pagenum': 'UNDEFINED', // CENTER = show page numbers / UNDEFINED = do not show
'attachment': false
@khanhkhuu
khanhkhuu / Chat-card.json
Last active April 6, 2023 07:53
Chat-card.json
{
"cardsV2":[
{
"card":{
"header":{
"title":"Title",
"subtitle":"Sub title",
"imageUrl":"https://img.hoidap247.com/picture/question/20210207/large_1612697826664.jpg",
"imageType":"CIRCLE"
},
@khanhkhuu
khanhkhuu / Domo.js
Created March 29, 2023 10:07
Domo.js
class Domo {
constructor(client_id, client_secret) {
this.client_id = client_id;
this.client_secret = client_secret;
}
__get_oauth_token() {
const token = Utilities.base64Encode(`${this.client_id}:${this.client_secret}`);
const headers = { 'Authorization' : 'Basic ' + token };
const res = UrlFetchApp.fetch("https://api.domo.com/oauth/token?grant_type=client_credentials&scope=data", {
@khanhkhuu
khanhkhuu / thaiDateConvert.js
Last active February 17, 2023 09:54
Convert Thai date to International format
// For example: 4 ต.ค. 65
// Or: 9 กุมภาพันธ์ 2566
function convertToIntDate(thaiDate) {
const dateFormat = 'dd-MM-yyyy';
if (thaiDate instanceof Date) {
const newDate = new Date(
thaiDate.getFullYear() + 57,
thaiDate.getMonth(),
thaiDate.getDate()
Dim SapGuiAuto
Dim objGui As GuiApplication
Dim objConn As GuiConnection
Dim session As GuiSession
Public Sub DoSomethingWithSAP()
' Create SAP Instance
ConnectionString = "Asia: (R/3 Test) CAI"
Set SapGuiAuto = CreateObject("Sapgui.ScriptingCtrl.1")
' Show SAP Instance or not
Sub Check_Stock()
Dim sap As New SapClient
sap.ConnectionString = "CONNECTION STRING GO HERE"
sap.HideGui = True
sap.OpenSAP
Dim stock As String
sap.session.StartTransaction "md04"
sap.session.FindById("wnd[0]/usr/tabsTAB300/tabpF01/ssubINCLUDE300:SAPMM61R:0301/ctxtRM61R-MATNR").Text = "E105ACXXXXX"
sap.session.FindById("wnd[0]/usr/tabsTAB300/tabpF01/ssubINCLUDE300:SAPMM61R:0301/ctxtRM61R-WERKS").Text = "VN11"
Private SapGuiAuto
Private objGui As GuiApplication
Private objConn As GuiConnection
Private win As GuiFrameWindow
Public ConnectionString As String
Public HideGui As Boolean
Public session As GuiSession
Public Sub OpenSAP()
Set SapGuiAuto = CreateObject("Sapgui.ScriptingCtrl.1")
[""VN11/OCTB/INJE/CL13"",""VN11/OCTB/INJE/CL04"",""VN11/OCTB/INJE/CL16"",""VN11/OCTB/INJE/CL12"",""VN11/OCTB/INJE/CL08"",""VN11/OCTB/INJE/CL14"",""VN11/OCTB/INJE/CL07"",""VN11/OCTB/INJE/CL17"",""VN11/OCTB/INJE/CL15"",""VN11/OCTB/INJE/MOLD/EC13"",""VN11/OCTB/INJE/MOLD/CAPS"",""VN11/OCTB/INJE/MOLD/TA"",""VN11/OCTB/INJE/MOLD/PK"",""VN11/OCTB/INJE/MOLD/KID2"",""VN11/OCTB/INJE/MOLD/PC14"",""VN11/OCTB/INJE/MOLD/TF13/FH"",""VN11/OCTB/INJE/MOLD/TF13/CH"",""VN11/OCTB/INJE/MOLD/AC"",""VN11/OCTB/INJE/MOLD/AFH"",""VN11/OCTB/INJE/MOLD/TWH"",""VN11/OCTB/INJE/MOLD/SF"",""VN11/OCTB/INJE/MOLD/NEO"",""VN11/OCTB/INJE/MOLD/GC"",""VN11/OCTB/INJE/MOLD/KID5"",""VN11/OCTB/INJE/MOLD/TIE2"",""VN11/OCTB/INJE/MOLD/EC11"",""VN11/OCTB/INJE/MOLD/ZZTC"",""VN11/OCTB/INJE/MOLD/TFUH"",""VN11/OCTB/INJE/MOLD/DACT"",""VN11/OCTB/INJE/MOLD/TIE3"",""VN11/OCTB/INJE/MOLD/ZZ20"",""VN11/OCTB/INJE/MOLD/DAHH"",""VN11/OCTB/INJE/CL01"",""VN11/OCTB/INJE/MIX-"",""VN11/OCTB/INJE/CL11"",""VN11/OCTB/INJE/CL03"",""VN11/OCTB/INJE/CL06"",""VN11/OCTB/INJE/CL09"",""V
Dim ScriptHost : ScriptHost = Mid(WScript.FullName, InStrRev(WScript.FullName, "\") + 1, Len(WScript.FullName))
Dim oWs : Set oWs = CreateObject("WScript.Shell")
Dim oProcEnv : Set oProcEnv = oWs.Environment("Process")
If InStr(LCase(WScript.FullName), LCase(oProcEnv("windir") & "\System32\")) And oProcEnv("PROCESSOR_ARCHITECTURE") = "AMD64" Then
If Not WScript.Arguments.Count = 0 Then
Dim sArg, Arg
sArg = ""
For Each Arg In Wscript.Arguments
sArg = sArg & " " & """" & Arg & """"
# Cài Python 32Bit để chạy được script này
# Link: https://repo.anaconda.com/archive/Anaconda3-2021.05-Windows-x86.exe
import win32com.client
import ctypes
def main():
connectionString = "Asia: (R/3 Test) CAI"
hidden = True
application = win32com.client.Dispatch("Sapgui.ScriptingCtrl.1")