Skip to content

Instantly share code, notes, and snippets.

View ahamed's full-sized avatar
🎯
Focusing on open source.

Sajeeb Ahamed ahamed

🎯
Focusing on open source.
View GitHub Profile
@ahamed
ahamed / leap-year.js
Last active August 11, 2022 14:02
Check if a year is a Leap Year or not.
/**
* Find a year is a leap year or not.
* The logic is simple, create an instance of a date
* with the date 29 of the february of the given year.
* If the date 29 exists in that year that means the
* year is a leap year, otherwise it's not.
* What a brilliant idea.
*
* @author 📩 Sajeeb Ahamed <sajeeb07ahamed@gmail.com>
@ahamed
ahamed / trie.js
Created October 31, 2021 07:15
Implement the Trie data structure for storing worlds in an efficient way.
function Node(character) {
this.value = character;
this.endOfWord = false;
this.children = {};
}
class Trie {
constructor() {
this.root = new Node(null);
}
[
{
"id": 1,
"name": "Putin FM",
"frequency": "66,6",
"image": "./assets/images/stations.planet-01.jpeg"
},
{
"id": 2,
"name": "Dribble FM",
@ahamed
ahamed / getRange.js
Created July 26, 2021 06:34
Get a range within two given numbers (inclusive).
const range = (min, max) => {
// If max value is smaller than the min value then swap it.
if (max < min) [min, max] = [max, min];
const _range = (max + 1) - min;
return Array.from({length: _range}, (_, i) => min + i);
}
console.log(range(1, 5)); // 1, 2, 3, 4, 5
console.log(range(10, 5)); // 5, 6, 7, 8, 9, 10
@ahamed
ahamed / neon-button.css
Created July 14, 2021 14:05
Make neon glowing button with CSS only.
/* <button class="neon-button">Neon Button</button> */
:root {
--clr-neon: hsl(317 100% 54%);
--clr-bg: hsl(323 21% 16%);
}
*::before,
*::after {
box-sizing:border-box;
@ahamed
ahamed / iterm2-solarized.md
Created June 30, 2021 10:12 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k

@ahamed
ahamed / phptable.php
Created June 4, 2021 15:28
PHP table from array.
<?php
/**
* @package Ahamed\JsPhp
* @author Sajeeb Ahamed <sajeeb07ahamed@gmail.com>
* @copyright (c) Sajeeb Ahamed 2021
* @see https://github.com/ahamed/jsphp
*/
$book = [
'id' => [1, 2, 3, 4, 5],
'title' => ['Master PHP', 'Python In Action', 'Advance engllish for learners', 'Maths for kids', 'Color theory'],
@ahamed
ahamed / array_unique_jsphp.php
Created May 16, 2021 21:52
Make an array unique using filter and indexOf.
<?php
/**
* @package Ahamed\JsPhp
* @author Sajeeb Ahamed <sajeeb07ahamed@gmail.com>
* @copyright Copyright (c) 2021 Sajeeb Ahamed
* @see https://github.com/ahamed/jsphp
*/
use Ahamed\JsPhp\JsArray;
@ahamed
ahamed / getEdgeValue.js
Created February 2, 2021 17:06
Get the edge value of an array i.e. the max or min value w.r.t the condition.
/**
* Get edge value of an array using user defined function. The edge value means either max or min value.
*
* @author Sajeeb Ahamed <sajeeb07ahamed@gmail.com>
*/
Array.prototype.findEdge = function(callback) {
// If no value exists to the array then return undefined
if (this.length === 0) return undefined;
let edge = this[0];
@ahamed
ahamed / runAsync.js
Created February 2, 2021 16:38
Run Async function and get result and error without try catch.
/**
* Run Async function and get the result and the error without using try catch.
*
* @author Sajeeb Ahamed <sajeeb07ahamed@gmail.com>
*/
const runAsync = (func) => func.then((data) => [data, undefined]).catch((error) => Promise.resolve([undefined, error]));
// A function which will return a promise and throw error
const getData = () => {
return new Promise((_, reject) => {