Skip to content

Instantly share code, notes, and snippets.

View dyazincahya's full-sized avatar
🔥
plus ultra

Kang Cahya dyazincahya

🔥
plus ultra
View GitHub Profile
@dyazincahya
dyazincahya / README.md
Created January 13, 2026 07:15
Tutorial CI/CD Shared Hosting: Deploy React Otomatis dengan GitHub Actions
@dyazincahya
dyazincahya / i18n.js
Created July 2, 2025 02:04
An alternative to @nativescript/localize for implementing multiple languages in NativeScript using i18next
import { ApplicationSettings, Device, Frame } from "@nativescript/core";
import i18next from "i18next";
// Import your translation files
import en from "../i18n/en.json";
import id from "../i18n/id.json";
/**
* Main translation function. We export it so it can be accessed from anywhere.
* 'L' is a common abbreviation for 'Localize' or 'Language'.
@dyazincahya
dyazincahya / xyz-mask-input.directive.ts
Last active June 25, 2025 14:43
Angular Directive for masking input on HTML input elements. Support (Time, Date, Phone, Credit Card or General)
/**
* Angular Directive for masking input on HTML input elements.
*
* Supports several mask types:
* - 'time' : Time format (HH:MM)
* - 'date' : Date format (DD/MM/YYYY)
* - 'phone' : Indonesian phone number format (08XX-XXXX-XXXX)
* - 'credit-card' : Credit card format (XXXX-XXXX-XXXX-XXXX)
* - 'general' : General/custom masking according to the pattern provided in `maskPattern`
*
@dyazincahya
dyazincahya / time-mask.directive.ts
Created March 26, 2025 08:27
Time Mask Input Directive for Angular
import { Directive, ElementRef, HostListener, forwardRef } from '@angular/core';
import { NG_VALUE_ACCESSOR, ControlValueAccessor } from '@angular/forms';
@Directive({
selector: '[timeMask]',
providers: [
{
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => timeMaskDirective),
multi: true,
@dyazincahya
dyazincahya / getCountryByTimezone.js
Created November 30, 2024 08:25
This is a sample code to Get Country Name by Time (zone) in Browser using Javascript or Typescript. This can also be an alternative to get country name other than using GPS location
// Pemetaan zona waktu ke nama negara
const timezoneCountryMap = {
"Asia/Jakarta": "Indonesia",
"Asia/Kolkata": "India",
"Europe/London": "United Kingdom",
"America/New_York": "United States",
"Europe/Paris": "France",
"Asia/Tokyo": "Japan",
"Europe/Berlin": "Germany",
"Asia/Sydney": "Australia",
@dyazincahya
dyazincahya / disable-autofill-input.directive.ts
Created November 12, 2024 13:56
Angular directive to disable browser autofill on input forms (Tested Angular 18)
import {
Directive,
Renderer2,
ElementRef,
HostListener,
AfterViewInit,
} from '@angular/core';
@Directive({
selector: '[DisableAutofillInput]',
@dyazincahya
dyazincahya / readme.md
Last active June 14, 2024 11:59
Save Contact to Phonebook Utils for Nativescript 8 (core JS) (Android or IOS)

Dependency

You need Utils, isAndroid, isIOS from @nativescript/core. This util does not require contact permissions, because the way this util works is only sending data to the default contact app.

Usage

Import

import { saveToPhoneBook } from "~/util_phonebook";
@dyazincahya
dyazincahya / readme.md
Created June 10, 2024 06:06
Audio Player Utils for Nativescript 8 (core JS) (Android)

Dependency

Before using this Utils, yout must add native depedencies in App_Resources/Android/app.gradle

implementation 'com.google.android.exoplayer:exoplayer:2.19.1'

Usage

TS Import

@dyazincahya
dyazincahya / file_get_contents_helper.php
Created February 11, 2024 10:25
Simple Helper file_get_contents PHP for access API with method GET POST PUT and DELETE
<?php
function makeApiRequest($url, $params = [], $method = 'GET') {
$options = [
'http' => [
'method' => $method,
'header' => 'Content-Type: application/x-www-form-urlencoded',
'content' => http_build_query($params),
],
];
@dyazincahya
dyazincahya / cURL_helper.php
Last active February 11, 2024 08:21
Simple Helper cURL PHP for access API with method GET POST PUT and DELETE
<?php
function makeApiRequest($url, $params = [], $method = 'GET') {
// Initialize cURL session
$ch = curl_init($url);
// Set common cURL options
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Return the response as a string instead of outputting it
// Set method-specific cURL options
if ($method === 'POST') {