Skip to content

Instantly share code, notes, and snippets.

@Ramynn
Ramynn / md
Created November 2, 2025 09:45
Digiexpress-interview-question-09
# DigiExpress, Debounce (Core JS → React Hook) — #09
## Part A — Implement `debounce`
**Goal:** Write a **pure JavaScript** `debounce(fn, wait, options?)` that delays invoking `fn` until `wait` ms since the last call.
**Signature**
```js
/**
* @param {Function} fn
@Ramynn
Ramynn / gregorian_to_jalali.sql
Last active September 14, 2024 15:20
Mysql: Converts a Gregorian datetime (assumed to be in UTC) to a Jalali date string in Tehran time. If the input has no time component or is at midnight UTC, the function returns only the Jalali date without time.
DELIMITER $$
CREATE FUNCTION gregorian_to_jalali(gregorian_datetime DATETIME)
RETURNS VARCHAR(19)
DETERMINISTIC
BEGIN
-- Variable declarations
DECLARE adjusted_datetime DATETIME;
-- Gregorian date components
@Ramynn
Ramynn / jalali_to_gregorian.sql
Last active September 14, 2024 15:41
Mysql: Converts a Jalali date string (assumed to be in Tehran time) to a Gregorian datetime in UTC.
DELIMITER $$
CREATE FUNCTION jalali_to_gregorian(jalali_datetime VARCHAR(19))
RETURNS VARCHAR(19)
DETERMINISTIC
BEGIN
-- Jalali date and time components
DECLARE jy INT; -- Year
DECLARE jm INT; -- Month
DECLARE jd INT; -- Day
@Ramynn
Ramynn / jalali_to_gregorian.sql
Last active September 14, 2024 16:55
PostgreSQL: Converts a Jalali date string (assumed to be in Tehran time) to a Gregorian TIMESTAMPTZ in UTC.
-- Drop the function if it already exists
DROP FUNCTION IF EXISTS jalali_to_gregorian(jalali_datetime VARCHAR, end_of_day BOOLEAN);
-- Create the jalali_to_gregorian function
CREATE OR REPLACE FUNCTION jalali_to_gregorian(jalali_datetime VARCHAR, end_of_day BOOLEAN)
RETURNS TIMESTAMP WITHOUT TIME ZONE AS
$$
DECLARE
-- Jalali date and time components
jy INT;
@Ramynn
Ramynn / gregorian_to_jalali.sql
Last active September 14, 2024 14:23
PostgreSQL: gregorian_to_jalali: Converts a Gregorian timestamp (UTC) to a Jalali date string in Tehran time. If the input has no time component or is at midnight UTC, the function returns only the Jalali date without time.
CREATE OR REPLACE FUNCTION gregorian_to_jalali(gregorian_datetime TIMESTAMPTZ)
RETURNS TEXT AS $$
DECLARE
-- Adjusted datetime in Tehran time (without time zone)
adjusted_datetime TIMESTAMP;
-- Gregorian date components
gy INTEGER; -- Year
gm INTEGER; -- Month
gd INTEGER; -- Day
@Ramynn
Ramynn / Type.ts
Last active October 10, 2019 20:41
JSON:API Typescript Implementation [WIP]
export type Implements<T, U extends T> = {}
type APIBasicDataResponse<Type> = {
type: Type;
id: string;
};
type APILinkObject = {
href: string;
meta: object;