nishchaie-roblox's picture
Upload folder using huggingface_hub
9e3b673 verified
import gradio as gr
import random
import time
from datetime import datetime
# Vibe coding quotes for inspiration
VIBE_QUOTES = [
"✨ Code like nobody's watching ✨",
"πŸŒ™ Late night coding sessions",
"🎧 Focus mode: ON",
"πŸš€ Build something beautiful today",
"πŸ’‘ Ideas flow better with good vibes",
"🌈 Every bug is just a feature in disguise",
"β˜• Code, sip, repeat",
"🎨 Paint your thoughts in code",
"πŸ”₯ Make it work, make it vibe",
"🌟 You're doing amazing, sweetie",
]
# Focus playlists/moods
MOODS = {
"πŸ”₯ Lo-Fi Beats": {"color": "#ff6b6b", "emoji": "🎧", "description": "Chill lo-fi hip hop for coding"},
"πŸŒ™ Deep Focus": {"color": "#4a69bd", "emoji": "🧠", "description": "Alpha waves for deep concentration"},
"β˜€οΈ Upbeat Energy": {"color": "#f6b93b", "emoji": "⚑", "description": "High tempo for quick tasks"},
"🌊 Chill Wave": {"color": "#0a3d62", "emoji": "🌊", "description": "Ocean sounds for relaxation"},
"🎡 Classical Flow": {"color": "#6c5ce7", "emoji": "🎻", "description": "Classical for complex problems"},
}
# Productivity tips
PRODUCTIVITY_TIPS = [
"πŸ’‘ Take a 5-minute break every 25 minutes (Pomodoro technique)",
"πŸ’‘ Keep your workspace clean - clear desk, clear mind",
"πŸ’‘ Drink water! Stay hydrated while you code",
"πŸ’‘ Use keyboard shortcuts to speed up your workflow",
"πŸ’‘ Comment your code - future you will thank present you",
"πŸ’‘ Git commit often - small commits are happy commits",
"πŸ’‘ Don't forget to stretch! Your body will thank you",
"πŸ’‘ Play ambient sounds if silence is too loud",
]
def get_quote():
"""Get a random vibe quote"""
return random.choice(VIBE_QUOTES)
def get_mood_info(mood):
"""Get mood information"""
if mood in MOODS:
return MOODS[mood]
return MOODS["πŸ”₯ Lo-Fi Beats"]
def create_focus_playlist(mood):
"""Generate a focus playlist recommendation"""
mood_info = get_mood_info(mood)
playlists = {
"πŸ”₯ Lo-Fi Beats": ["Lofi Girl", "Chillhop Music", "Nujabes Station"],
"πŸŒ™ Deep Focus": ["Brain Food", "Deep Focus", "Ambient Sounds"],
"β˜€οΈ Upbeat Energy": ["Power Gaming", "Synthwave Mix", "Upbeat Coding"],
"🌊 Chill Wave": ["Ocean Waves", "Rain Sounds", "White Noise"],
"🎡 Classical Flow": ["Classical Essentials", "Piano Focus", "Movie Scores"],
}
return random.choice(playlists.get(mood, playlists["πŸ”₯ Lo-Fi Beats"]))
def generate_coding_idea():
"""Generate a random coding project idea"""
project_types = [
"A personal portfolio website",
"A weather dashboard",
"A habit tracker app",
"A simple game",
"A recipe manager",
"A budget tracker",
"A music player",
"A chat application",
"A quiz app",
"A task manager",
]
tech_stack = [
"React + Node.js",
"Python + Flask",
"Vue.js",
"Django",
"Svelte",
"Next.js",
"Vanilla JavaScript",
"Ruby on Rails",
"Go",
"Rust",
]
features = [
"with dark mode",
"with animations",
"with offline support",
"with animations",
"with drag and drop",
"with search functionality",
"with export features",
"with keyboard shortcuts",
"with a beautiful UI",
"with local storage",
]
idea = f"Build {random.choice(project_types)} using {random.choice(tech_stack)} {random.choice(features)}!"
return idea
def track_session(session_type, duration):
"""Track coding session"""
return f"βœ… Session logged: {session_type} for {duration} minutes"
def get_time_greeting():
"""Get time-based greeting"""
hour = datetime.now().hour
if 5 <= hour < 12:
return "πŸŒ… Good morning! Ready to code?"
elif 12 <= hour < 17:
return "β˜€οΈ Good afternoon! Keep the momentum going!"
elif 17 <= hour < 21:
return "πŸŒ† Good evening! Wrap up those tasks!"
else:
return "πŸŒ™ Good night! Time for some late-night coding!"
def pomodoro_timer(minutes):
"""Start a Pomodoro timer simulation"""
return f"πŸ… Timer set for {minutes} minutes! Stay focused!"
def get_random_tip():
"""Get a random productivity tip"""
return random.choice(PRODUCTIVITY_TIPS)
# Gradio 6 App
with gr.Blocks() as demo:
# Header with "Built with anycoder"
gr.Markdown("""
<div style="text-align: center; padding: 20px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); border-radius: 15px; margin-bottom: 20px;">
<h1 style="color: white; margin: 0;">🎧 Vibe Coding App</h1>
<p style="color: white; margin: 10px 0;">Code with the perfect vibes ✨</p>
<a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" style="color: white; text-decoration: none; font-size: 14px; background: rgba(255,255,255,0.2); padding: 8px 16px; border-radius: 20px;">
Built with anycoder πŸš€
</a>
</div>
""")
# Time-based greeting
greeting = gr.Textbox(
label="πŸ‘‹ Greeting",
value=get_time_greeting(),
interactive=False,
elem_classes=["greeting"]
)
# Vibe quote of the moment
with gr.Row():
with gr.Column(scale=2):
quote_display = gr.Textbox(
label="πŸ’« Vibe Quote",
value=get_quote(),
interactive=False,
lines=2
)
with gr.Column(scale=1):
new_quote_btn = gr.Button("🎲 New Quote", variant="secondary", size="sm")
# Main features section
with gr.Tabs():
with gr.TabItem("🎡 Vibe Mode"):
with gr.Row():
with gr.Column():
mood_selector = gr.Dropdown(
choices=list(MOODS.keys()),
value="πŸ”₯ Lo-Fi Beats",
label="🎧 Select Your Vibe",
info="Choose the mood that matches your coding style"
)
mood_emoji = gr.Textbox(
label="Current Vibe",
value="🎧",
interactive=False
)
playlist_rec = gr.Textbox(
label="🎢 Recommended Playlist",
value=create_focus_playlist("πŸ”₯ Lo-Fi Beats"),
interactive=False
)
mood_selector.change(
create_focus_playlist,
inputs=[mood_selector],
outputs=[playlist_rec]
)
mood_selector.change(
lambda m: get_mood_info(m)["emoji"],
inputs=[mood_selector],
outputs=[mood_emoji]
)
with gr.TabItem("πŸ’‘ Project Ideas"):
with gr.Column():
idea_output = gr.Textbox(
label="✨ Your Next Project",
value=generate_coding_idea(),
interactive=False,
lines=3
)
new_idea_btn = gr.Button("🎲 Generate New Idea", variant="primary", size="lg")
new_idea_btn.click(generate_coding_idea, outputs=idea_output)
with gr.TabItem("πŸ… Focus Timer"):
with gr.Column():
gr.Markdown("### ⏱️ Pomodoro Timer")
timer_duration = gr.Slider(
minimum=5,
maximum=60,
value=25,
step=5,
label="Session Duration (minutes)"
)
timer_display = gr.Textbox(
label="Timer Status",
value="πŸ… Ready to start?",
interactive=False
)
start_timer_btn = gr.Button("▢️ Start Focus Session", variant="primary", size="lg")
start_timer_btn.click(
pomodoro_timer,
inputs=[timer_duration],
outputs=[timer_display]
)
with gr.TabItem("πŸ“Š Session Tracker"):
with gr.Column():
session_type = gr.Radio(
choices=["Deep Work", "Quick Task", "Learning", "Debugging", "Planning"],
label="What are you working on?",
value="Deep Work"
)
session_duration = gr.Slider(
minimum=15,
maximum=180,
value=60,
step=15,
label="Duration (minutes)"
)
log_session_btn = gr.Button("πŸ“ Log Session", variant="secondary")
session_log = gr.Textbox(
label="Session Log",
interactive=False,
lines=3
)
log_session_btn.click(
track_session,
inputs=[session_type, session_duration],
outputs=[session_log]
)
with gr.TabItem("πŸ’¬ Productivity Tips"):
with gr.Column():
tip_display = gr.Textbox(
label="🌟 Productivity Tip",
value=get_random_tip(),
interactive=False,
lines=2
)
new_tip_btn = gr.Button("πŸ”„ New Tip", variant="secondary")
new_tip_btn.click(get_random_tip, outputs=tip_display)
# Quick actions footer
with gr.Row():
new_quote_btn.click(get_quote, outputs=quote_display)
# Footer with links
gr.Markdown("""
<div style="text-align: center; padding: 20px; margin-top: 20px; background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); border-radius: 15px;">
<p style="color: white; margin: 0;">πŸŽ‰ Happy Vibe Coding! Remember: code is poetry, vibes are mandatory 🌈</p>
<p style="color: white; margin: 10px 0 0 0; font-size: 12px;">
<a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" style="color: white;">Built with anycoder</a> β€’
<a href="https://huggingface.co/spaces" target="_blank" style="color: white;">Hugging Face Spaces</a>
</p>
</div>
""")
# Gradio 6 - theme and app parameters go in launch()
demo.launch(
theme=gr.themes.Soft(
primary_hue="purple",
secondary_hue="pink",
neutral_hue="slate",
text_size="lg",
spacing_size="lg",
radius_size="md"
).set(
button_primary_background_fill="*primary_600",
button_primary_background_fill_hover="*primary_700",
block_title_text_weight="600",
),
footer_links=[
{"label": "anycoder", "url": "https://huggingface.co/spaces/akhaliq/anycoder"},
{"label": "Hugging Face", "url": "https://huggingface.co"},
],
css="""
.greeting textarea {
font-size: 1.2em !important;
text-align: center;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
color: white !important;
border: none !important;
}
"""
)