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 / anime.tsx
Created October 24, 2024 02:23
Animated Text likes streaming-text on AI
// Dependencies: npm i framer-motion
// Hooks
"use client";
import { animate } from "framer-motion";
import { useEffect, useState } from "react";
const delimiter = ""; // or " " to split by word
@ekaone
ekaone / card.js
Created October 21, 2024 11:45
Center element on Card with Tailwind CSS
<div class="max-w-sm mx-auto bg-white shadow-lg rounded-lg overflow-hidden">
<div class="p-5">
<h2 class="text-xl font-bold mb-2">Card Title</h2>
<p class="text-gray-700">This is some descriptive text inside the card. It gives more information about the content.</p>
   </div>
</div>
@ekaone
ekaone / scoreboard.tsx
Created October 18, 2024 03:09
Simple player scoreboard
import { useState, useEffect, useRef } from 'react'
import { Play, Square, RotateCcw, Pencil } from 'lucide-react'
export default function FullScreenScoreboard() {
const [time, setTime] = useState(0)
const [isRunning, setIsRunning] = useState(false)
const [scores, setScores] = useState({ player1: 2, player2: 1 })
const [playerNames, setPlayerNames] = useState({ player1: 'Player 1', player2: 'Player 2' })
const [editingPlayer, setEditingPlayer] = useState<'player1' | 'player2' | null>(null)
const editInputRef = useRef<HTMLInputElement>(null)
@ekaone
ekaone / sentiment.tsx
Created October 18, 2024 02:16
Simple UI Sentiment analysis input field
'use client'
import { useState } from 'react'
import { Button } from "@/components/ui/button"
import { Textarea } from "@/components/ui/textarea"
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
import { ThumbsUp, ThumbsDown, Loader2 } from "lucide-react"
export default function SentimentAnalysis() {
const [text, setText] = useState('')
@ekaone
ekaone / toggle-mode.tsx
Created October 15, 2024 02:04
Simple toggle Dark and Light modes
import { useState, useEffect } from 'react';
import { MoonIcon, SunIcon } from '@heroicons/react/24/solid';
export default function Home() {
const [count, setCount] = useState(0);
const [darkMode, setDarkMode] = useState(false);
useEffect(() => {
// Check for saved theme preference or use system preference
const savedTheme = localStorage.getItem('theme');
@ekaone
ekaone / SQL_Twitter_Clone.sql
Created October 11, 2024 03:15
Simple schema twitter clone
create table users (
id bigint primary key generated always as identity,
username text unique not null,
email text unique not null,
password text not null,
created_at timestamptz default now()
);
create table tweets (
id bigint primary key generated always as identity,
@ekaone
ekaone / seed.ts
Created October 3, 2024 03:45
Database seeder with DrizzleORM and Faker.js
import { db } from "@/db";
import { faker } from "@faker-js/faker";
import { workspaces, users } from "@/db/schemas";
async function seedDatabase() {
const workspaceId = faker.string.uuid();
const workspaceData = {
id: workspaceId,
name: faker.company.name(),
@ekaone
ekaone / tts.jsx
Created September 28, 2024 05:10
Text to speech
'use client'
import { useState } from 'react'
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
import { Textarea } from "@/components/ui/textarea"
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"
import { Slider } from "@/components/ui/slider"

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
@ekaone
ekaone / Dockerfile
Created September 24, 2024 01:14
Docker for Nextjs project
FROM node:18-alpine AS base
# Install dependencies only when needed
FROM base AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app
# Install dependencies based on the preferred package manager
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./