Skip to content

Instantly share code, notes, and snippets.

View ekaone's full-sized avatar
🎯
Focusing

Eka Prasetia ekaone

🎯
Focusing
View GitHub Profile
@ekaone
ekaone / proximity-prefetch.tsx
Created April 6, 2025 13:31 — forked from pontusab/proximity-prefetch.tsx
Next.js Proximity Prefetch (PPF)
"use client";
import { useRouter } from "next/navigation";
import type { ReactNode } from "react";
import { useCallback, useEffect, useState } from "react";
interface ProximityPrefetchProps {
children: ReactNode;
threshold?: number;
predictionInterval?: number;

Next.js Starters

A list of CLI generators, starter kits / boilerplates and toolkits to kick start your Next.js apps.

  • What is included in this list:
    • Has ~1K+ Github stars
    • Actively maintained / up to date
    • Includes a style / css solution or UI Framework
    • Includes a database
  • Includes authentication / authorization
import ollama
import time
def read_file(file_path):
"""
Reads the content of a file and decodes it using the 'latin-1' encoding.
Args:
file_path (str): The path to the file to be read.
@ekaone
ekaone / options.oak
Created July 7, 2023 04:57 — forked from thesephist/options.oak
Collection of useful Stable Diffusion prompt modifiers
{ name: 'Lighting', options: [
'golden hour, warm glow'
'blue hour, twilight, ISO12000'
'midday, direct lighting, overhead sunlight'
'overcast, whitebox, flat lighting, diffuse'
'dreamlike diffuse ethereal lighting'
'dramatic lighting, dramatic shadows, illumination'
'studio lighting, professional lighting, well-lit'
'flash photography'
'low-key lighting, dimly lit'
@ekaone
ekaone / route.ts
Created May 31, 2023 04:58 — forked from m1guelpf/route.ts
Next.js App Route for getting the current playing song on Spotify (or a cached version)
import redis from '@/lib/redis'
import { tap } from '@/lib/utils'
import { NextResponse } from 'next/server'
import { NowPlaying } from '@/types/activities'
import { base64_encode, use } from '@/lib/utils'
type SpotifyResponse = {
is_playing: boolean
progress_ms: number
item: {
@ekaone
ekaone / title-from-url.ts
Created March 28, 2023 07:15 — forked from steven-tey/title-from-url.ts
Get Title from URL
// Note: this gist is a part of this OSS project that I'm currently working on: https://github.com/steven-tey/dub
export default async function getTitleFromUrl (url: string) {
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 2000); // timeout if it takes longer than 2 seconds
const title = await fetch(url, { signal: controller.signal })
.then((res) => {
clearTimeout(timeoutId);
return res.text();
})
@ekaone
ekaone / 00-README-NEXT-SPA.md
Created March 18, 2023 04:46 — forked from gaearon/00-README-NEXT-SPA.md
Next.js SPA example with dynamic client-only routing and static hosting

Next.js client-only SPA example

Made this example to show how to use Next.js router for a 100% SPA (no JS server) app.

You use Next.js router like normally, but don't define getStaticProps and such. Instead you do client-only fetching with swr, react-query, or similar methods.

You can generate HTML fallback for the page if there's something meaningful to show before you "know" the params. (Remember, HTML is static, so it can't respond to dynamic query. But it can be different per route.)

Building

@ekaone
ekaone / README.md
Created July 28, 2021 03:23 — forked from JonasWanke/README.md
GitHub Actions Cheat Sheet
@ekaone
ekaone / hyper.js
Created June 25, 2021 02:55 — forked from coco-napky/hyper.js
Hyper config for git bash in Windows
module.exports = {
config: {
// default font size in pixels for all tabs
fontSize: 12,
// font family with optional fallbacks
fontFamily: 'Menlo, "DejaVu Sans Mono", Consolas, "Lucida Console", monospace',
// terminal cursor background color and opacity (hex, rgb, hsl, hsv, hwb or cmyk)
cursorColor: 'rgba(248,28,229,0.8)',
@ekaone
ekaone / App.js
Created March 9, 2021 05:32 — forked from skolhustick/App.js
ChakraUI - Login Form with ColorMode
import React from 'react'
import {
ThemeProvider,
theme,
ColorModeProvider,
CSSReset,
Box,
Flex,
IconButton,
useColorMode,