Skip to content

Instantly share code, notes, and snippets.

View kerrypnx's full-sized avatar
🎯
Focusing

Ke Rui kerrypnx

🎯
Focusing
View GitHub Profile
@kerrypnx
kerrypnx / SAPOpenSessionFromLogon.bas
Created April 26, 2020 02:41
SAPOpenSessionFromLogon
Sub SAPOpenSessionFromLogon()
Dim SapGui
Dim Applic
Dim connection
Dim session
Dim Path
Path = "'C:\Program Files (x86)\SAP\FrontEnd\SAPgui\saplogon.exe' /LSXML_File='C:\sap\SAPUILandscape.xml'"
SAPPath = Replace(Path, "'", Chr(34))
Shell (SAPPath)
Set SapGui = GetObject("SAPGUI")
@kerrypnx
kerrypnx / Bulk rename file
Created April 22, 2020 04:02
Powershell bulk rename file
Get-ChildItem *.xml | Rename-Item -NewName { $_.Name -replace '\.xml','.tmp' }
@kerrypnx
kerrypnx / hosts
Created April 22, 2020 02:29
Hosts Setting
192.30.253.112 github.com
2.192.30.253.113 github.com
3.151.101.184.133 assets-cdn.github.com
4.151.101.185.194 github.global.ssl.fastly.net
192.30.253.118 gist.github.com
@kerrypnx
kerrypnx / TriggerMacroToTunAfterNewMailIsReceived.vbs
Last active April 22, 2020 02:27
Trigger a macro to run after a new mail is received in Outlook
Option Explicit
Private WithEvents inboxItems As Outlook.Items
Private Sub Application_Startup()
Dim outlookApp As Outlook.Application
Dim objectNS As Outlook.NameSpace
Set outlookApp = Outlook.Application
Set objectNS = outlookApp.GetNamespace("MAPI")
Set inboxItems = objectNS.GetDefaultFolder(olFolderInbox).Items
'Find the last non-blank cell in column A(1)
lRow = Cells(Rows.Count, 1).End(xlUp).Row
'Find the last non-blank cell in row 1
lCol = Cells(1, Columns.Count).End(xlToLeft).Column
bColumnCount = Cells(Rows.Count, 2).End(xlUp).Row
ActiveSheet.Range("B40 : B" & CStr(bColumnCount)).Select
itemsArr = ActiveSheet.Range("B40 : B" & CStr(bColumnCount))
MsgBox itemsArr(1, 1)
@kerrypnx
kerrypnx / s
Created November 21, 2019 09:40
iRowCov = Sheet2.UsedRange.Rows.Count
iColCov = Sheet2.UsedRange.Columns.Count
Sheet2.Range("A2").Resize(iRowCov, iColCov).ClearContents
// TeXworksScript
// Title: Search and Replace
// Description: search and replace like word (support wildcase)
// Author: KR
// Version: 0.1
// Date: 2019-1-17
// Script-Type: standalone
// Context: TeXDocument
// Shortcut: Ctrl+shift+H
@kerrypnx
kerrypnx / compare
Last active November 21, 2019 01:10
油候插件compare
// ==UserScript==
// @name find highlight
// @namespace http://tampermonkey.net/
// @version 0.1
// @description for compare
// @author ke rui
// @match https://neil.fraser.name/software/diff_match_patch/demos/diff.html
// @grant none
// ==/UserScript==
Sub findsciHub()
With Selection.Find
.ClearFormatting
.text = "sci-hub.tw"
.MatchWildcards = False
Do
.Execute
If .Found Then
Selection.Range.comments.add Selection.Range, "sci-hub.tw is forbidden in paper, please change."
Else