Skip to content

Instantly share code, notes, and snippets.

View carefree-ladka's full-sized avatar
🏠
Working from home

Pawan Kumar carefree-ladka

🏠
Working from home
View GitHub Profile
@carefree-ladka
carefree-ladka / Masonry Grid Layout.js
Created February 26, 2025 10:42
Masonry Grid Layout
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Masonry Grid Layout</title>
<style>
body {
font-family: Arial, sans-serif;
@carefree-ladka
carefree-ladka / OOPS.py
Created February 25, 2025 07:58
Topic : OOPS in Python
# OOPS (Inheritance, Polymorphism, Encapsulation, Abstraction)
"""
Access Modifiers:
public : We can anything from anywhere
protected : Only inside the class & subclass (_)
private : Only inside the class (__)
"""
# Encapsulation
@carefree-ladka
carefree-ladka / Amazon.js
Last active February 16, 2025 11:47
Amazon.html
30 days
1. Two Sum
54.9%
Easy
146. LRU Cache
44.3%
Med.
200. Number of Islands
@carefree-ladka
carefree-ladka / Blocks.js
Last active February 12, 2025 13:11
Clear Boxes in React
import * as React from 'react'
export default function App() {
const [grid, setGrid] = React.useState(Array.from({ length: 3 }, () => Array.from({ length: 3 }, () => false
)))
const cellsRef = React.useRef([])
const timerRef = React.useRef([])
const handleCellClick = (i, j, check) => {
if (grid[i][j] && check) return
@carefree-ladka
carefree-ladka / JQuery.js
Created February 1, 2025 18:18
JQuery Library using ES6 Class
class MiniQuery {
constructor(selector) {
this.elements = document.querySelectorAll(selector);
}
css(property, value) {
this.elements.forEach(el => el.style[property] = value);
return this; // Enable chaining
}
@carefree-ladka
carefree-ladka / TicTacToe.js
Created February 1, 2025 18:14
TicTacToe Game Based on OOPS
class Board {
constructor() {
this.grid = [
["", "", ""],
["", "", ""],
["", "", ""]
];
}
printBoard() {
@carefree-ladka
carefree-ladka / SnakeGame.js
Created February 1, 2025 18:12
Snake Game Based on OOPS
class Board {
constructor(size) {
this.size = size; // e.g., 20x20 grid
this.food = this.generateFood();
}
generateFood() {
return {
x: Math.floor(Math.random() * this.size),
y: Math.floor(Math.random() * this.size)
@carefree-ladka
carefree-ladka / Ludo.js
Created February 1, 2025 18:10
Ludo Game Based on OOPS
class Dice {
roll() {
return Math.floor(Math.random() * 6) + 1;
}
}
class Token {
constructor(color, id) {
this.color = color;
this.id = id;
@carefree-ladka
carefree-ladka / Chess.js
Created February 1, 2025 18:08
Chess Game Based on OOPS
class Piece {
constructor(color, name) {
this.color = color; // "White" or "Black"
this.name = name;
}
isValidMove(start, end, board) {
return false; // Each piece will override this method
}
}
@carefree-ladka
carefree-ladka / SnakeLadder.js
Created February 1, 2025 18:01
Snake Ladder Game
class Dice {
roll() {
return Math.floor(Math.random() * 6) + 1;
}
}
class Board {
constructor(size, snakes, ladders) {
this.size = size;
this.snakes = new Map(snakes); // {start: end}