Skip to content

Instantly share code, notes, and snippets.

View menjaraz's full-sized avatar

Menjanahary menjaraz

View GitHub Profile
unit AsyncThread;
interface
uses
{Delphi}
System.SysUtils
{Project}
;
@menjaraz
menjaraz / collatz.py
Last active October 7, 2024 08:09
Python Collatz Generator function
def generate_collatz(n):
"""
Generator function to generate the Collatz sequence.
Args:
n (int): The starting number for the sequence.
Yields:
int: The next number in the sequence.
"""
@menjaraz
menjaraz / main.dart
Created September 28, 2024 17:49
OEIS A014445 - Even Fibonacci numbers; or, Fibonacci(3*n).
/// OEIS A014445 - Even Fibonacci numbers; or, Fibonacci(3*n).
/// https://oeis.org/A014445
/// https://oeis.org/A014445/list
void main() => print(evenFibonacci().take(26));
Iterable<int> evenFibonacci() sync* {
int a = 0, b = 2;
while (true) {
@menjaraz
menjaraz / main.dart
Last active September 28, 2024 17:33
Project Euler Problem 10 - Summation of Primes
// Summation of Primes
// https://projecteuler.net/problem=10
void main() {
final timer = Stopwatch()..start();
final answer = summationOfPrimesBelow(2000000);
timer.stop();
@menjaraz
menjaraz / app.d
Created September 28, 2024 17:20
Prime Generator in Dlang
import std.stdio;
import std.range;
import std.algorithm;
auto primeGenerator() {
int num = 2;
return generate(() {
while (true) {
if (isPrime(num)) {
@menjaraz
menjaraz / gf_gen.py
Last active September 22, 2024 06:02
Simple Python script utilizing power series expansion of the ordinary generating function to compute the sequence terms.
import sympy as sp
def generate_sequence(gen_func, num_terms):
"""
Generates a sequence up to num_terms terms using the given generating function.
Args:
gen_func: The generating function as a SymPy expression.
num_terms (int): The number of terms in the sequence.

Install PostgreSQL on Windows by scoop

Follow the below steps to install the latest version of PostgreSQL on Windows by scoop package manager.

Install PostgreSQL

scoop install postgresql -g

Configure PostgreSQL as a Windows Service

Install MySQL on Windows by scoop

Install latest version of MySQL via scoop package manager on Windows. If you want to install specific version of MySQL, just replace "mysql" with "mysql@version". For example: "[email protected]".

Install MySQL

scoop install mysql -g

Configure MySQL as a Windows Service

@menjaraz
menjaraz / app.d
Created July 18, 2024 08:26
ProjectEuler: Summation of Primes
import std.stdio : writefln;
void main() {
"%,3?d".writefln('_', 2_000_000.sumOfPrimesBelow);
}
ulong sumOfPrimesBelow(ulong num) {
// Create a dynamic array of booleans initialized to true
bool[] primes = new bool[num];
primes[] = true;
@menjaraz
menjaraz / app.d
Created May 27, 2024 18:46 — forked from KoRiGaN/app.d
Vibe.d REST API
import vibe.d;
import vibe.web.rest;
import std.array;
shared static this()
{
auto router = new URLRouter;
router.get("/", serveStaticFiles("./../client/index.html"))
.get("*", serveStaticFiles("./../client/"));