Spaces:
Sleeping
Sleeping
| 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; | |
| } | |
| """ | |
| ) |