Snippets

Code Snippets | MaxonCodes

Code Snippets

20+ professional code snippets with syntax highlighting. Click "Copy Code" to instantly use in your projects.

JavaScript
Python
CSS
HTML
Tools

Toggle Dark Mode

Quick JS snippet to toggle dark/light theme.


const toggle = document.querySelector('#themeToggle');
toggle.addEventListener('click', ()=>{
  document.body.classList.toggle('dark-mode');
});
  

Debounce Function

Optimized function to reduce frequent calls.


function debounce(fn, delay){
  let timeout;
  return function(...args){
    clearTimeout(timeout);
    timeout = setTimeout(()=>fn.apply(this,args), delay);
  }
}
  

Fibonacci Sequence

Generate Fibonacci numbers in Python.


def fibonacci(n):
    a, b = 0, 1
    for _ in range(n):
        print(a)
        a, b = b, a+b

fibonacci(10)
  

Gradient Button

CSS gradient hover button snippet.


.button {
  background: linear-gradient(90deg,#ff7a18,#af002d 70%);
  padding:10px 20px;
  border-radius:6px;
  color:#fff;
  cursor:pointer;
}
.button:hover {opacity:0.9;}
  

Responsive Image

HTML snippet for responsive images.


Description
  

Git Init

Initialize Git repository in terminal.


git init
git add .
git commit -m "Initial commit"
  

© 2025 MaxonCodes | Colorful, syntax-highlighted code snippets crafted with ❤️

Post a Comment