This file contains 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 numToEng(num) { | |
if (num < 1 || num > 999) { | |
throw new Error("Number must be between 1 and 999"); | |
} | |
let ones = ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]; | |
let teens = ["eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"]; | |
let tens = ["ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"]; | |
if (num < 10) return ones[num - 1]; |
This file contains 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
pm.test("Check for collection's variables..", function () { | |
let vars = ['client_id', 'client_secret', 'grant_type']; | |
vars.forEach(function (item, index, array) { | |
console.log(item, index); | |
pm.expect(pm.collectionVariables.get(item), item + " variable not set").to.not.be.undefined; | |
pm.expect(pm.collectionVariables.get(item), item + " variable not set").to.not.be.empty; | |
}); | |
if ((!pm.collectionVariables.get("access_token") && pm.collectionVariables.get("IS_TESTING")) | |
|| Date.now() > new Date(pm.collectionVariables.get("expires_in") * 1000)) { |
This file contains 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
namespace test_datetime | |
{ | |
internal class Program | |
{ | |
private static TimeZoneInfo Kuala_Lumpur_Standard_Time = TimeZoneInfo.FindSystemTimeZoneById("Singapore Standard Time"); | |
static void Main(string[] args) | |
{ | |
DateTime datetime_kuala_lumpur = TimeZoneInfo.ConvertTime(DateTime.UtcNow, Kuala_Lumpur_Standard_Time); | |
Console.WriteLine("Kuala Lumpur Now: " + datetime_kuala_lumpur); | |
Console.WriteLine("Kuala Lumpur + 1 Hour: " + datetime_kuala_lumpur.AddHours(1)); |
This file contains 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
.rotating-emoji { | |
display: inline-block; | |
transition: transform 0.3s ease-in-out; | |
} | |
.rotating-emoji:hover { | |
animation: rotateAndShrink 2s ease-in-out infinite; | |
transform: scale(0.8); | |
} |
This file contains 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
/// <summary> | |
/// Method to extract text from an image. | |
/// </summary> | |
/// <param name="imagePaths">A path to entire images.</param> | |
/// <returns>Returns a list of strings.</returns> | |
private static List<List<string>> ExtractTextFromImage(List<string> imagePaths) | |
{ | |
List<List<string>> allTexts = new(); | |
// Initialize the Tesseract engine |
This file contains 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
// This is from my comment here: http://wolfram.kriesing.de/blog/index.php/2008/javascript-remove-element-from-array/comment-page-2#comment-466561 | |
/* | |
* How to delete items from an Array in JavaScript, an exhaustive guide | |
*/ | |
// DON'T use the delete operator, it leaves a hole in the array: | |
var arr = [4, 5, 6]; | |
delete arr[1]; // arr now: [4, undefined, 6] |
This file contains 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
// Patch value to default | |
displayData: string[]; | |
patchCreateAsDefault(mainControl: FormGroup): void { | |
// Check if the formgroup is valid or not first | |
if (mainControl.valid) { | |
// Get raw value of formgroup, for nested form | |
const formObj = mainControl.getRawValue(); |
This file contains 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
// Check whether the serial length is equal with the quantity | |
for (const control of this.productForm.controls) { | |
if (control.get('serialLengthCheck').value !== control.get('quantity').value) { | |
console.log('Total of Serial Must be Equal with Quantity!'); | |
} | |
} |
This file contains 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
// Check Validation status inside FormGroup/FromArray | |
const invalidControls: string[] = []; | |
const recursiveFunc = (form: FormGroup|FormArray) => { | |
Object.keys(form.controls).forEach(field => { | |
const control = form.get(field); | |
if (control.invalid) { invalidControls.push(field); } | |
if (control instanceof FormGroup) { | |
recursiveFunc(control); | |
} else if (control instanceof FormArray) { | |
recursiveFunc(control); |
This file contains 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
// To prevent page scrolling whenever the input's focus is triggered | |
this.productNameInput.nativeElement.focus({ | |
preventScroll: true | |
}); | |
// Souces: https://newbedev.com/focus-to-input-without-scrolling |
NewerOlder