Skip to content

Instantly share code, notes, and snippets.

View sakiraykurt's full-sized avatar
🎯
Focusing

Şakir Aykurt sakiraykurt

🎯
Focusing
View GitHub Profile
@sakiraykurt
sakiraykurt / main.dart
Last active September 25, 2022 13:20
Flutter animating route pages - PageSwitcherBuilder
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
static const String _title = 'Flutter Code Sample';
@override
@sakiraykurt
sakiraykurt / random.js
Created March 8, 2022 21:50
JavaScript random class which is 'Lehmer RNG' formula based.
// See: https://en.wikipedia.org/wiki/Linear_congruential_generator
// See: https://en.wikipedia.org/wiki/Lehmer_random_number_generator
// Original Lehmer RNG construction
const m = 65537 // (2 ^ 16) + 1, a fermat prime
const a = 75 // a primitive root modulo
const x0 = 65536 // a seed number, greater than '0', less than 'm'
const md = m - 1 // a floating-point devider
// Lehmer random number generator formula
function rng(x) {
@sakiraykurt
sakiraykurt / Random.cs
Created March 8, 2022 19:19
C# random class which is 'Lehmer RNG' formula based.
//See: https://en.wikipedia.org/wiki/Linear_congruential_generator
//See: https://en.wikipedia.org/wiki/Lehmer_random_number_generator
public class Random
{
private const int m = 65537; // (2 ^ 16) + 1, a Fermat prime
private const int a = 75; // a Primitive root modulo
private const int x0 = 65536; // Number, greater than '0', less than 'm'
private static int ox, cx; // Original seed, Current seed
private static readonly float md; // floating-point devider
@sakiraykurt
sakiraykurt / promise.js
Last active March 8, 2022 18:37
Run/Call multiple async/promise functions with parameters in parallel
/**
* Run multiple async/promise functions with parameters in parallel
* @param {[[Promise, ...any]]} promises
* @returns {Promise<any[]>} values | errors
*/
function promiseAll(...promises) {
return new Promise((resolve, reject) => {
let values = []; let errors = [];
function check() {
if (values.length + errors.length === promises.length) {
@sakiraykurt
sakiraykurt / random.lua
Last active February 24, 2023 12:49
Lua random class which is 'Lehmer RNG' formula based.
-- See: https://en.wikipedia.org/wiki/Linear_congruential_generator
-- See: https://en.wikipedia.org/wiki/Lehmer_random_number_generator
-- Original Lehmer RNG construction
local m = 65537 -- (2 ^ 16) + 1, a fermat prime
local a = 75 -- a primitive root modulo
local x0 = 65536 -- a seed number, greater than '0', less than 'm'
local md = m - 1 -- a floating-point devider
-- Lehmer random number generator formula
local function rng(x)