This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function nabegheParseIniString(iniString, processSections = true, scannerMode = 'raw', pairSeparator = '=') { | |
| if (typeof iniString === 'string') { | |
| iniString = iniString.trim().split(/\r?\n/).filter(line => line.trim()); | |
| } | |
| const result = {}; | |
| let category = null; | |
| iniString.forEach(line => { | |
| line = line.trim(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Function RndInt(Min, Max) | |
| RndInt = Int((Max - Min) * Rnd + Min) | |
| End Function |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| UBound(arr) - LBound(arr) + 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Dim Arr() As Variant | |
| Arr = Array(1, 2, 3, 4, 5) | |
| Dim Length As Integer | |
| Length = UBound(Arr) - LBound(Arr) + 1 | |
| MsgBox (Arr(Int((Length - 1) * Rnd))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ' go to Tools->References and tick the box for 'Microsoft Scripting Runtime' | |
| Set dict = CreateObject("Scripting.Dictionary") | |
| ' OR Dim dict As New Scripting.Dictionary | |
| ' Check Exists Then Add | |
| If Not dict.Exists(key) Then | |
| dict.Add key, value | |
| End If |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Dim HashTable As Object | |
| Set HashTable = CreateObject("System.Collections.HashTable") | |
| HashTable.Add "Key1", 1 | |
| HashTable.Add "Key2", 2 | |
| HashTable.Add "Key3", 3 | |
| HashTable.Add "Key4", 5 | |
| HashTable.Add "Key5", 6 | |
| ' Read: | |
| MsgBox (HashTable("Key15")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Dim collection1 As Collection | |
| Set collection1 = New Collection | |
| collection1.Add "Value1", "Key1" | |
| collection1.Add "Value2", "Key2" | |
| collection1.Add "Value3", "Key3" | |
| ' Read: | |
| Range("A1").Value = collection1.Item("Key2") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * @param {string} s | |
| * @return {number} | |
| */ | |
| var lengthOfLastWord = function(s) { | |
| const words = s.trim().split(' ') | |
| return words[words.length - 1].length | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * @param {string[]} strs | |
| * @return {string} | |
| */ | |
| var longestCommonPrefix = function(strs) { | |
| let target = 0 | |
| let targetLength = 0 | |
| for (let i = 0; i < strs.length; i++) { | |
| if (strs[i].length === 0) return "" | |
| if (strs[i].length < targetLength || target === 0) target = i |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * @param {number} x | |
| * @return {boolean} | |
| */ | |
| var isPalindrome = function(x) { | |
| const x1 = x.toString() | |
| const x2 = [...x1].reverse().join('') | |
| return x1 === x2 | |
| }; |
NewerOlder