DeveloperBreeze

Date Manipulation and Sum Calculation

// Import required modules
const moment = require('moment');
const _ = require('lodash');

// Get the current date and time using Moment.js
const now = moment();

// Example array of numbers
const numbers = [1, 2, 3, 4, 5];

// Calculate the sum of the array using Lodash
const sum = _.sum(numbers);

Continue Reading

Discover more amazing content handpicked just for you

Tutorial

Build a Custom Rate Limiter in Node.js with Redis

  • Atomic operations with Redis
  • Manual request tracking logic
  • Flexibility to customize based on business rules

You’re no longer blindly relying on a package—you understand and control the system.

Apr 04, 2025
Read More
Cheatsheet
javascript

JavaScript Utility Libraries Cheatsheet

Ramda is a functional programming library for JavaScript developers, designed for better code composition and function handling.

<table>
  <tr>
    <th>Function</th>
    <th>Description</th>
    <th>Example</th>
  </tr>
  <tr>
    <td><code>R.compose(...functions)
    Composes functions from right to left.
    R.compose(Math.abs, R.add(1))(-5) => 4
  
  
    R.curry(fn)
    Returns a curried version of the provided function.
    R.curry((a, b) => a + b)(1)(2) => 3
  
  
    R.filter(predicate, list)
    Returns a new list containing only the elements that satisfy the predicate.
    R.filter(x => x % 2 === 0, [1, 2, 3, 4]) => [2, 4]
  
  
    R.map(fn, list)
    Applies the function to each element of the list.
    R.map(x => x * 2, [1, 2, 3]) => [2, 4, 6]
  
  
    R.reduce(reducer, initialValue, list)
    Reduces the list to a single value using the reducer function.
    R.reduce(R.add, 0, [1, 2, 3]) => 6
  

Aug 21, 2024
Read More
Tutorial
javascript css +1

Building a Real-Time Chat Application with WebSockets in Node.js

http://localhost:3000/

In this tutorial, we built a real-time chat application using Node.js and WebSockets. We used Socket.io to establish a persistent connection between the client and server, allowing for real-time message exchange. This foundational knowledge can be extended to build more complex applications that require real-time communication, such as collaborative tools, online gaming, and live updates.

Aug 03, 2024
Read More
Code
php

JWT Token Creation and Verification in Node.js using 'jsonwebtoken'

No preview available for this content.

Jan 26, 2024
Read More
Code
javascript

Simple HTTP Server in Node.js

No preview available for this content.

Jan 26, 2024
Read More
Code
javascript

Read and Write Files in Node.js using 'fs' module

No preview available for this content.

Jan 26, 2024
Read More
Code
javascript

Simple RESTful API in Node.js using Express

No preview available for this content.

Jan 26, 2024
Read More
Code
javascript

Access Command-line Arguments

No preview available for this content.

Jan 26, 2024
Read More
Code
javascript

Set and Access Environment Variable

No preview available for this content.

Jan 26, 2024
Read More
Code
javascript

Event Emitter using 'events' module

No preview available for this content.

Jan 26, 2024
Read More
Code
javascript

Construct File Path using 'path' module

No preview available for this content.

Jan 26, 2024
Read More
Code
javascript

Basic Authentication using 'express-basic-auth' middleware

// Import required modules
const express = require('express');
const app = express();
const basicAuth = require('express-basic-auth');

// Define a user for basic authentication
const users = { 'username': 'password' };

// Use express-basic-auth middleware for authentication
app.use(basicAuth({ users }));

// Define a route accessible only to authenticated users
app.get('/secure', (req, res) => {
  res.send('Authenticated route');
});

Jan 26, 2024
Read More
Code
javascript

Create and Print Buffer

No preview available for this content.

Jan 26, 2024
Read More
Code
javascript

Hashing Password with SHA-256 using 'crypto' module

No preview available for this content.

Jan 26, 2024
Read More
Code
javascript

Parse URL and Query Parameters

No preview available for this content.

Jan 26, 2024
Read More
Code
javascript

Execute Shell Command using 'child_process' module

No preview available for this content.

Jan 26, 2024
Read More
Code
javascript

File Stream Copy using 'fs' module

No preview available for this content.

Jan 26, 2024
Read More
Code
javascript

Simple WebSocket Server using 'ws' library

No preview available for this content.

Jan 26, 2024
Read More
Code
php

Date Formatting for Specific Date ('Y-m-d')

No preview available for this content.

Jan 26, 2024
Read More

Discussion 0

Please sign in to join the discussion.

No comments yet. Start the discussion!