Skip to content

Instantly share code, notes, and snippets.

View sametcn99's full-sized avatar
🎧
Focusing

samet sametcn99

🎧
Focusing
View GitHub Profile
@sametcn99
sametcn99 / hello_world.json
Created November 23, 2023 01:01
"Hello, World!" is a traditional and iconic phrase used in the programming world to mark the beginning of a programmer's journey with a new programming language or environment. This JSON file contains a multilingual greeting, "Hello World," translated into various languages. Each translation is associated with its respective language and region.…
{
"hello_world": {
"English (United Kingdom, United States, various English-speaking countries)": "Hello World",
"Spanish (Spain, Latin America)": "Hola Mundo",
"French (France, Belgium, Canada, Switzerland, various other countries)": "Bonjour le Monde",
"German (Germany, Austria, Switzerland, other German-speaking regions)": "Hallo Welt",
"Chinese (China, Taiwan, Singapore, various Chinese-speaking regions)": "你好,世界",
"Japanese (Japan)": "こんにちは、世界",
"Korean (South Korea, North Korea)": "안녕하세요, 세계",
"Russian (Russia, Belarus, Kazakhstan, various former Soviet countries)": "Привет, мир",
@sametcn99
sametcn99 / readme.md
Created November 23, 2023 17:27
This Gist contains a Next.js API route implemented in TypeScript for interacting with the GitHub API using the Octokit library. The primary purpose of this API route is to retrieve information about repositories belonging to a specific GitHub user.

GitHub Profile Next.js API with Octokit

This Gist contains a Next.js API route implemented in TypeScript for interacting with the GitHub API using the Octokit library. The primary purpose of this API route is to retrieve information about repositories belonging to a specific GitHub user.

Features:

  1. Endpoint: The API exposes an endpoint at /api/repos for handling HTTP GET requests.
  2. Parameter: Expects a username parameter in the query string to identify the target GitHub user. Example usage: http://localhost:3000/api/repos?username=sametcn99.
  3. Error Handling: Includes robust error handling for scenarios such as missing parameters or failed GitHub API requests.
  4. GitHub Authentication: Utilizes a GitHub token obtained from environment variables (process.env.GH_TOKEN) for authentication.
@sametcn99
sametcn99 / styles.css
Created November 23, 2023 21:49
This CSS file is intended to style HTML generated from an MDX file. It defines styles for headings, paragraphs, emphasis, bold text, links, visited links, link hover effects, lists, and blockquotes in the generated HTML, assuming it is structured under the .article class.
/* Heading Styles for article */
.article h1 {
font-size: 2.25rem;
font-weight: bold;
}
.article h2 {
font-size: 1.5rem;
font-weight: bold;
}
@sametcn99
sametcn99 / ScrollToTop.tsx
Created November 23, 2023 22:08
This React component creates a "scroll to top" button that becomes visible when the user scrolls down the page. It includes a smooth scroll effect when clicked.
"use client";
import React, { useState, useEffect } from "react";
const UpArrowIcon = () => (
<svg
enable-background="new 0 0 32 32"
height="32px"
id="Layer_1"
version="1.1"
viewBox="0 0 32 32"
@sametcn99
sametcn99 / loading.tsx
Last active November 24, 2023 05:30
loading animation component https://1672842.playcode.io/
export default function Loading() {
return (
<div className="flex h-full w-full animate-pulse items-center justify-center">
<div className="h-12 w-12 animate-spin rounded-full border-8 border-t-4 border-dashed light:border-black dark:border-white"></div>
</div>
);
}
// Demo: https://1672842.playcode.io/
@sametcn99
sametcn99 / text-regex.ts
Created November 29, 2023 02:08
This code defines a JavaScript function named TextRegex that takes a string (text) as input and performs a series of string manipulations. The purpose of the function seems to be to convert a given string into a format suitable for filenames, potentially for use in web applications or file systems.
// This function takes a string as input and converts Turkish characters to their English equivalents.
export default function TextRegex(text: string) {
Turkish characters to their English equivalents
let convertedString = text
.replace(/ğ/g, "g")
.replace(/Ğ/g, "G")
.replace(/ş/g, "s")
.replace(/Ş/g, "S")
.replace(/ı/g, "i")
@sametcn99
sametcn99 / ThemeSwitcher.tsx
Created November 29, 2023 02:23
This code defines a React component called ThemeSwitcher that provides a switch for toggling between light and dark themes using the Next.js theme provider. The component uses the useTheme hook to access the current theme and the function to set the theme. It utilizes the Switch component from the @nextui-org/react library and includes icons fo…
"use client";
import { useTheme } from "next-themes";
import { useEffect, useState } from "react";
import React from "react";
import { Switch } from "@nextui-org/react";
import { MoonIcon } from "@/public/MoonIcon";
import { SunIcon } from "@/public/SunIcon";
// Define the ThemeSwitcher component
export function ThemeSwitcher() {
@sametcn99
sametcn99 / dateRangeSlice.ts
Created November 29, 2023 02:28
This code defines a Redux slice for managing a date range state. The state includes a start date and an end date, both initially set to null. The slice provides action creators (setStartDate and setEndDate) and a reducer function to update the corresponding dates in the state based on the payload from dispatched actions. The slice is named "dat…
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
// Create a slice of the Redux store for managing date range state
interface DateRangeState {
startDate: Date | null;
endDate: Date | null;
}
const dateRangeSlice = createSlice({
name: "dateRange", // The name of the slice in the Redux store
@sametcn99
sametcn99 / getSiteUrl.ts
Last active January 21, 2024 09:37
This function determines the base URL of the site based on the current environment.
// This function, getSiteUrl, is designed to return the appropriate base URL for the current environment.
// It is defined as a constant export, indicating that it can be imported and used in other parts of the codebase.
// The function has no parameters and returns a string, which is the determined base URL.
export const getSiteUrl = (): string => {
// Determine whether the current environment is production by checking the NODE_ENV environment variable.
const isProduction: boolean = process.env.NODE_ENV === "production";
@sametcn99
sametcn99 / getFormattedDate.ts
Created December 4, 2023 01:29
The provided TypeScript function, getFormattedDate, takes a date string as input and returns a formatted date string.
/**
* Converts a given date string to a formatted date string.
*
* @param {string} dateString - The input date string to be formatted.
* @returns {string} - The formatted date string.
*/
export default function getFormattedDate(dateString: string): string {
// Step 1: Create a new Date object from the input date string.
const date = new Date(dateString);