Skip to content

Instantly share code, notes, and snippets.

View sametcn99's full-sized avatar
🎧
Focusing

sametcn99

🎧
Focusing
View GitHub Profile
@sametcn99
sametcn99 / get-dates.ts
Created December 4, 2023 01:36
This function appears to be designed to process post data and generate information about the count of posts for each month, along with corresponding date ranges and formatted strings.
// Importing the getSortedPostsData function from the specified module
import { getSortedPostsData } from "@/app/lib/posts";
// Default function that retrieves and processes data to get dates, counts, and date ranges
export default function GetDates() {
// Get the sorted post data using the imported function
const data = getSortedPostsData();
// Object to store the count of posts for each month
const monthCount: { [key: string]: number } = {};
@sametcn99
sametcn99 / manifest.ts
Created December 4, 2023 01:43
sample manifest file for pwa's
import { MetadataRoute } from "next";
export default function manifest(): MetadataRoute.Manifest {
return {
name: "Your Website Name",
short_name: "ShortName",
dir: "auto",
description: "This is your website description.",
categories: ["test", "sample", "webapp", "pwa"],
theme_color: "#000000",
@sametcn99
sametcn99 / RenameMarkdownFiles.cs
Created December 4, 2023 01:50
This code is a C# program that provides functionality to rename and move Markdown files based on the content of the files.
// Method to rename and move files
private void RenameFiles()
{
// Get the parent folder of the selected folder
string parentFolder = Path.GetDirectoryName(selectedFolderPath);
// Create a new folder for the renamed files
string newFolderPath = Path.Combine(parentFolder, "RenamedFiles");
// Check if the new folder doesn't exist, and if not, create it
@sametcn99
sametcn99 / verify-auth.ts
Last active December 4, 2023 02:03
This code defines a set of functions for handling JSON Web Tokens (JWTs) and verifying the authenticity of a user based on an authentication cookie.
import { cookies } from "next/headers";
import { verifyJwtToken } from "./verify-jwt-token";
// Create an async function called verifyAuth
export default async function verifyAuth() {
// Get the auth cookie
const cookieStore = cookies();
const auth = cookieStore.get("auth");
// If no auth cookie is found, return false
@sametcn99
sametcn99 / providers.tsx
Last active December 6, 2023 02:15
redux-toolkit starter
"use client";
import { Provider } from "react-redux";
import reduxStore from "@/lib/redux/store";
export function Providers({ children }: { children: React.ReactNode }) {
return <Provider store={reduxStore}>{children}</Provider>;
}
@sametcn99
sametcn99 / Redirect.tsx
Created January 4, 2024 00:22
This code appears to be a React component designed for redirection in a Next.js application. Let's break down the main components:
"use client";
import { useRouter } from "next/navigation";
import { useEffect } from "react";
import Loading from "@/app/loading";
type RedirectProps = {
searchParams: { url: string };
};
export default function Redirect({ searchParams }: RedirectProps) {
{
"extends": [
"next",
"next/core-web-vitals",
"eslint:recommended"
]
}
interface Author {
name: string;
url: string;
}
interface Language {
"@type": string;
name: string;
}
@sametcn99
sametcn99 / getRandomColor.ts
Created January 8, 2024 04:27
Function to generate a random color in hexadecimal format
// Function to generate a random color in hexadecimal format
export const getRandomColor = () => {
// Hexadecimal characters used for color representation
const letters = "0123456789ABCDEF";
// Initialize the color variable with the '#' symbol
let color = "#";
// Loop to generate a random 6-digit hexadecimal color code
for (let i = 0; i < 6; i++) {
@sametcn99
sametcn99 / githubContext.tsx
Last active January 10, 2024 18:19
github context
import React, { createContext, ReactNode, useEffect, useState } from "react";
import { GitHubRepo } from "@/types";
import { sortByDateDesc } from "@/utils/utils";
// Define the shape of the context data
interface GithubContextProps {
repos: GitHubRepo[] | null;
gists: GitHubRepo[] | null;
loading: boolean;
}