This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { useState, useEffect } from "react"; | |
| type Breakpoint = "xs" | "sm" | "md" | "lg" | "xl"; | |
| function convertQueryToBreakpoint(breakpoint: Breakpoint): string { | |
| switch (breakpoint) { | |
| case "xs": | |
| return "(min-width: 0px)"; | |
| case "sm": | |
| return "(min-width: 600px)"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { FC } from "react"; | |
| // $ComponentName$ is a variable which can be set to fileNameWithoutExtension() | |
| type $ComponentName$Props = { | |
| }; | |
| export const $ComponentName$: FC<$ComponentName$Props> = () => { | |
| return ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import axios from "axios"; | |
| // define the fetcher once, export it and use it every where you use useSWR | |
| export const fetcher = (url: string) => axios.get(url).then(res => res.data) | |
| const YOUR_API_ENDPOINT = ''; | |
| const { data, isLoading, error} = useSWR(`${YOUR_API_ENDPOINT}`, fetcher) | |
| if (isLoading) return <div><p>loading</p></div> | |
| if (error) return <div><p>error</p></div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { FC } from "react"; | |
| import useSWR from "swr"; | |
| import Image from "next/image"; | |
| type Post = { | |
| media_type: "CAROUSEL_ALBUM" | "IMAGE" | "VIDEO" | |
| permalink: string; | |
| media_url: string; | |
| caption: string; | |
| id: string; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import DateDiff from "date-diff"; | |
| export function getFormattedDateDifference(dateAdded: string) { | |
| const diff = new DateDiff(new Date(), new Date(dateAdded)) | |
| if (diff.minutes() < 60) { | |
| if (Math.round(diff.minutes()) === 1) { | |
| return `${Math.round(diff.minutes())} minute ago` | |
| } | |
| return `${Math.round(diff.minutes())} minutes ago` | |
| } | |
| if (diff.hours() < 24) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export const countries = [ | |
| "Afghanistan", | |
| "Åland-Inseln", | |
| "Albanien", | |
| "Algerien", | |
| "Amerikanisch-Samoa", | |
| "Andorra", | |
| "Angola", | |
| "Anguilla", | |
| "Antarktis", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export const cantons = [ | |
| {title: "Aargau", code: "AG"}, | |
| {title: "Appenzell Ausserrhoden", code: "AR"}, | |
| {title: "Appenzell Innerrhoden", code: "AI"}, | |
| {title: "Basel-Landschaft", code: "BL"}, | |
| {title: "Basel-Stadt", code: "BS"}, | |
| {title: "Bern", code: "BE"}, | |
| {title: "Fribourg", code: "FR"}, | |
| {title: "Genève", code: "GE"}, | |
| {title: "Glarus", code: "GL"}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { NextApiResponse } from "next"; | |
| export interface PaginationResult<T> { | |
| success: boolean; | |
| data: T[]; | |
| pagination: { | |
| page: number; | |
| limit: number; | |
| totalPages: number; | |
| totalCount: number; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import requests | |
| import random | |
| # GitHub Configuration | |
| GITHUB_TOKEN = "YOUR_GITHUB" | |
| REPO_OWNER = "" | |
| REPO_NAME = "" | |
| API_URL = f"https://api.github.com/repos/{REPO_OWNER}/{REPO_NAME}" | |
| HEADERS = {"Authorization": f"token {GITHUB_TOKEN}"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import requests | |
| import webbrowser # Import webbrowser to open links | |
| import time | |
| # GitHub username | |
| USERNAME = "" | |
| # Replace 'None' with your GitHub Personal Access Token | |
| GITHUB_TOKEN= None |
OlderNewer