Skip to content

Instantly share code, notes, and snippets.

View thambaru's full-sized avatar

Thambaru Wijesekara thambaru

View GitHub Profile
@thambaru
thambaru / App.tsx
Created September 4, 2025 14:10
A simple ReactJS To-Do List app with functionality to add tasks, remove tasks, and reorder them.
import React, { useRef, useState, useReducer } from "react";
const todoReducer = (state, action) => {
const { type, payload } = action;
switch (action.type) {
case "add":
return [...state, { text: payload, completed: false }];
case "toggle":
state[payload].completed = !state[payload].completed;
return [...state];
@thambaru
thambaru / areaByRadius.py
Created December 28, 2023 15:19
Python program that calculates the area of a circle based on the radius entered by the user.
# Python exercise: https://www.w3resource.com/python-exercises/python-basic-exercises.php
#
# 4. Write a Python program that calculates the area of a circle based on the radius entered by the user.
#
# Some online compilers do not allow importing sys.
# Remove the following line in such case, and set sysIsAvailable to False.
from sys import exit
isSysAvailable = True
from math import pi
@thambaru
thambaru / twinkleTwinkle.py
Created December 27, 2023 04:42
Python program to print "Twinkle Twinkle Little Star" in a specific format
# Python exercise: https://www.w3resource.com/python-exercises/python-basic-exercises.php
#
# Write a Python program to print the following string in a specific format (see the output).
# Sample String : "Twinkle, twinkle, little star, How I wonder what you are! Up above the world so high, Like a diamond in the sky. Twinkle, twinkle, little star, How I wonder what you are"
# Output :
#
# Twinkle, twinkle, little star,
# How I wonder what you are!
# Up above the world so high,
# Like a diamond in the sky.