Skip to content

Instantly share code, notes, and snippets.

View erenkulaksiz's full-sized avatar
😉
Working from home

Eren Kulaksız erenkulaksiz

😉
Working from home
  • me@eren.one
  • 12:17 (UTC +03:00)
View GitHub Profile
const YEAR_IN_SEC = 31536000;
const MONTH_IN_SEC = 2628000;
const DAY_IN_SEC = 86400;
const HOUR_IN_SEC = 3600;
const MINUTES_IN_SEC = 60;
export function getTimeAgo(value: string, locale: string = "tr") {
const now = new Date().getTime();
const entryTime = Date.parse(value);
import { useEffect, useRef, useState } from "react";
import { AdEventType, InterstitialAd } from "react-native-google-mobile-ads";
import analytics from "@react-native-firebase/analytics";
import adId from "@/utils/adId";
import { useAuthStore } from "@/stores/authStore";
import isPremium from "@/utils/isPremium";
interface IUseInterstitialAd {
onAdLoaded?: (showAd: () => void) => void;
onAdWatched?: () => void;
@erenkulaksiz
erenkulaksiz / withExtraAndroidManifest.js
Created April 22, 2024 07:13
took some time to figure this custom config out.
const defineConfig = (config) => {
const { withAndroidManifest } = require('@expo/config-plugins');
config = withAndroidManifest(config, (config) => {
let androidManifest = config.modResults.manifest;
androidManifest.application = androidManifest.application || [];
androidManifest.application[0]["meta-data"].push({
$: {
"android:name":
"com.dieam.reactnativepushnotification.notification_color",
@erenkulaksiz
erenkulaksiz / SubscriptionTypeEnums.php
Created March 19, 2024 18:16
Google Play Android Sub types
<?php
namespace App\Enums;
/**
* Class SubscriptionTypeEnums
* @package App\Enums
*/
final class SubscriptionTypeEnums
{
@erenkulaksiz
erenkulaksiz / View.tsx
Last active June 12, 2023 06:45
basic conditional render in react
import { Children } from "react";
import type { ViewProps, ViewIfElseProps } from "./View.types";
export default function View({ viewIf, div, children }: ViewProps) {
if (Children.count(children) > 2)
throw new Error(
"View component can only have 2 children, View.If and View.Else"
);
if (viewIf === true) return <>{Children.toArray(children)[0]}</>;
Lorem ipsum dolor sit amet just kidding. Hope you doing well.
@erenkulaksiz
erenkulaksiz / localStorage.ts
Last active July 25, 2022 16:55
Localstorage implementation for NextJS used in Notal
import { isClient } from "@utils/isClient"; // check for Serverside rendering
interface DefaultSettingsTypes {
cookies: boolean;
installedVersion: string;
installedEnv: string;
navbarCollapsed: boolean;
}
const DefaultSettings: DefaultSettingsTypes = {
@erenkulaksiz
erenkulaksiz / buildComponent.ts
Last active June 16, 2022 18:36
typescript version of buildComponent.js used in Notal.
interface BuildComponentTypes {
name?: string;
defaultClasses?: string;
extraClasses?: string;
conditionalClasses?: Array<{
[key: string]: string | boolean | undefined;
}>;
selectedClasses?: Array<string | boolean | undefined>;
}
import {
createContext,
PropsWithChildren,
ReactNode,
useContext,
useEffect,
useState,
} from "react";
import { AnimateSharedLayout, motion } from "framer-motion";
@erenkulaksiz
erenkulaksiz / buildComponent.js
Last active May 2, 2022 12:09
Tailwind React component builder
/**
* BuildComponent function makes it easy to build classes for custom components.
* @param {string} name - Name of the component.
* @param {string} defaultClasses - Default classes for the component.
* @param {string} extraClasses - Extra classes for the component.
* @param {array} conditionalClasses - Array of objects, which is conditional classes for the component.
* @param {array} selectedClasses - Array of strings, which is selected classes for the component.
* @returns {object} data - Object with the following properties:
* @returns {string} data.name - Name of the component.
* @returns {string} data.classes - Classes for the component.