Skip to content

Instantly share code, notes, and snippets.

View mahdikhashan's full-sized avatar
🏃‍♂️

Mahdi Khashan mahdikhashan

🏃‍♂️
View GitHub Profile
@mahdikhashan
mahdikhashan / time_step_decorator.py
Created May 28, 2025 12:15
Metaflow `@time_step` Decorator — Track and store execution time of each `@step` in your flow using `flow.step_timings`. Handy for lightweight performance profiling.
import time
import functools
def time_step(func):
"""
A Metaflow-specific decorator to measure and log the execution time of a @step.
This decorator is intended to be used on Metaflow step functions only.
It stores the step's execution duration (in seconds) in the `step_timings`
@mahdikhashan
mahdikhashan / release.config.js
Created April 18, 2023 09:57 — forked from yyynnn/release.config.js
release.config.js
/* eslint-disable no-template-curly-in-string */
const gitlabUrl = 'https://gitlab.com'
const gitlabApiPathPrefix = '/api/v4'
const assets = [
{ path: 'index.js', label: 'JS distribution' }
]
const verifyConditions = [
['@semantic-release/changelog'],
@mahdikhashan
mahdikhashan / DateTimeFormatMock.js
Created March 28, 2023 12:15
Vitest Mock Timezone
it("should get the client timezone as a string", () => {
const DateTimeFormat = Intl.DateTimeFormat;
vi.spyOn(global.Intl, "DateTimeFormat").mockImplementation(
(locale, options) =>
new DateTimeFormat(locale, { ...options, timeZone: "Asia/Tehran" })
);
const date: MyDate = new MyDate("2023-03-28T11:06:48+00:00");
expect(date.getClientTZ()).toEqual("Asia/Tehran");
@mahdikhashan
mahdikhashan / mutableSource.tsx
Created March 21, 2023 00:05 — forked from Aslemammad/mutableSource.tsx
Consistent version of useMutableSource.
// Consistent version of `useMutableSource`, Inspired by https://github.com/pmndrs/valtio/blob/master/src/useMutableSource.ts
import { useEffect, useRef, useState } from 'react';
const TARGET = Symbol('target');
const GET_VERSION = Symbol('getVersion');
export type Source<TargetType extends any, VersionType extends any> = {
[TARGET]: TargetType;
[GET_VERSION]: (target: TargetType) => VersionType;
};