Skip to content

Instantly share code, notes, and snippets.

View hmetgundogdu's full-sized avatar
🌴
On vacation

Ahmet Gündoğdu hmetgundogdu

🌴
On vacation
View GitHub Profile
@hmetgundogdu
hmetgundogdu / NoBorderTabControl.cs
Last active May 14, 2025 07:09
Custom TabControl for Windows Forms with no borders by overriding TCM_ADJUSTRECT. Includes a helper to replace existing tab controls.
public partial class NoBorderTabControl : TabControl
{
/// <summary>
/// Fine-tune adjustments to hide the border more precisely.
/// </summary>
public Padding BorderAdjustments { get; set; } = new()
{
Left = 6,
Right = 6,
Top = 2,
@hmetgundogdu
hmetgundogdu / MountController.tsx
Created October 13, 2022 12:03
This is a idea for debounced component
import React, { ReactNode, useEffect, useState } from 'react';
interface MountControllerProps {
teal?: number;
leading?: number;
mount: boolean;
children: ReactNode;
}
function MountController({ children }: MountControllerProps) {
@hmetgundogdu
hmetgundogdu / ApiResult.cs
Last active May 13, 2022 13:07
Example of a chaining useage
class ApiResult<T>
{
public ApiResult(T data)
{
Data = data;
}
public ApiResult<T> Error(string error)
{
Errors.Add(error);
export type SupportedLanguages =
'tr-TR' |
'ka-GE' |
'en-US' |
'ar-EG' |
'ru-RU';
;
function useDateLocalizers() {
// Hooks
import { formatISO, parseISO } from "date-fns";
import { CacheKey, Deserializer, Serializer } from "json-object-mapper";
@CacheKey("DateSerializerDeserializer")
class DateSerializerDeserializer implements Deserializer, Serializer {
deserialize = (value: string): Date => {
return parseISO(value);
}
serialize = (value: Date): string => {
export const INITIAL_STATE = {
init: false,
network: false,
errors: [] as Error[],
};
export type AppState = typeof INITIAL_STATE;
interface INIT_STATE_TYPE { type: 'INIT_STATE' };
interface NETWORK_DOWN { type: 'NETWORK_DOWN' };
@hmetgundogdu
hmetgundogdu / BaseFormModel.ts
Last active January 8, 2022 12:22
Thats how i handle form data lifecycle with react hook form
export interface IBaseCustomMapper {
fromDto(dto: any): any | Promise<any>;
toDto(model: any): any | Promise<any>;
}
export interface BaseFormModel {
getMapper(): IBaseCustomMapper;
getDefaults(): BaseFormModel | Promise<BaseFormModel>;
}
@hmetgundogdu
hmetgundogdu / CustomerService.ts
Last active December 23, 2024 08:10
Basically dependency injection in typescript
import ICustomerService from './ICustomerService';
class CustomerService implements ICustomerService {
getCustomers(): { username: string; email: string; }[] {
throw new Error("Method not implemented.");
}
};
export default CustomerService;
const TimeType = { Day: 1, Week: 2, Mounth: 3, Year: 4 }
/**
* Adds time as defined a type day, week, mounth and year to given date
* @param {TimeType} Time type will add
* @param {Date} How many adds times to value
* @param {boolean | undefined} if it is true, time will add as negative way.
* @returns {Date} New value
*/
function addTimeToDate(timeType, times, date, negative = false) {
const newDate = new Date(date)
@hmetgundogdu
hmetgundogdu / kingoftheclicks.com.js
Created February 1, 2021 23:50
kingoftheclicks.com auto click
(async function (opt) {
const buttons = new Array(document.querySelector(opt.postiveButtonSelector),
document.querySelector(opt.negativeButtonSelector));
const repetitionInterval = opt.repetitionInterval;
const sleep = async (millisecond) => new Promise((resolve) => setTimeout(resolve, millisecond));
const randomNumber = (min, max) => Math.random() * (max - min) + min;
while (true)
for (const btn of buttons) {