Code reusability

php

JSON File Reading and Decoding

This PHP script reads a JSON file (data.json), decodes its contents using json_decode(), and...

javascript

Prime Number Check and Prime Number Generation in JavaScript

This JavaScript code includes a function isPrime to check if a number is prime and then uses...

python

Filter SQLAlchemy Query for Records Created Between Specific Dates

This code snippet uses a SQLAlchemy query on the Model table to retrieve all records where the...

javascript

Leap Year Checker

This JavaScript code defines a function isLeapYear that checks whether a given year is a leap...

python

Filtering and Selecting Elements in NumPy Array

Use NumPy’s boolean indexing to filter arrays by conditions and integer indexing to pick...

python

Python Logging Snippet

This snippet sets up a logger that writes log messages to both the console and a file, with...

javascript

Parse JSON String to Object

This JavaScript code demonstrates how to parse a JSON string into a JavaScript object using the...

javascript

Promise-based Execution of Python Code with jsPython

This code snippet uses a jsPython() object to run Python code from JavaScript. The evaluate()...