Skip to content

Instantly share code, notes, and snippets.

View farithadnan's full-sized avatar
:bowtie:
Exorcising

Farith farithadnan

:bowtie:
Exorcising
  • MZM Sdn. Bhd.
  • Malaysia
  • 07:38 (UTC +08:00)
View GitHub Profile
@farithadnan
farithadnan / timezone_kl.cs
Created March 18, 2024 02:06
Get a current datetime for Kuala Lumpur (Malaysia)
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));
@farithadnan
farithadnan / emoji.css
Created December 22, 2023 01:47
Rotating and Shrinking Emoji
.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);
}
@farithadnan
farithadnan / image2text.cs
Last active September 21, 2023 04:50
How to use extract text from multiple image using Tesseract OCR in C#?
/// <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
@farithadnan
farithadnan / gist:cfc963678c329bd9a1342aef7c4615a3
Created January 26, 2022 08:23 — forked from chad3814/gist:2924672
deleting array items in javascript with forEach() and splice()
// 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]
@farithadnan
farithadnan / patchingAsDefault.js
Created December 7, 2021 04:28
Patching form group value into an Array
// 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();
@farithadnan
farithadnan / loop.js
Created October 12, 2021 06:10
Loop for formArray
// 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!');
}
}
@farithadnan
farithadnan / validity.js
Created October 12, 2021 05:55
validate the form validity
// 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);
@farithadnan
farithadnan / NoScrolling.js
Created October 12, 2021 03:29
Preventing scrolling when Input's focus is triggerred
// 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
@farithadnan
farithadnan / blur.css
Created September 30, 2021 04:29
Blur effect on a div element
div.blur {
-webkit-filter: blur(5px);
-moz-filter: blur(5px);
-o-filter: blur(5px);
-ms-filter: blur(5px);
filter: blur(5px);
width: 100px;
height: 100px;
background-color: #ccc;
}
<!--
1. Add button that will be named as Display Details, will toggling secret message on and
off
2. paragraph will display the secret if the secret havent display yet, and
vise versa
3. Will display count of the evertime the button is click (Timestamp stored into an array), and save the timestamp to an array using loop
4. if the content is more than five. index wise, it will give blue background color and white as its font
-->
<div class="container">