Skip to content

Instantly share code, notes, and snippets.

@ramiror
ramiror / dto.php
Last active December 2, 2020 21:38 — forked from mcsee/dto.php
<?
final class SocialNetworkProfile {
private $userName;
private $friends; // friends is a reference to a large collection
private $feed; // feed references the whole user feed
public __construct($userName , $friends, UserFeed $feed) {
$this->assertUsernameIsValid($userName);
@ramiror
ramiror / boolean.php
Created November 28, 2020 19:12 — forked from mcsee/boolean.php
<?
function processBatch(bool $useLogin, bool $deleteEntries, bool $beforeToday ){
/...
}
@ramiror
ramiror / clever.js
Created November 28, 2020 18:45 — forked from mcsee/clever.js
function primeFactors(n){
var f = [], i = 0, d = 2;
for (i = 0; n >= 2; ) {
if(n % d == 0){
f[i++]=(d);
n /= d;
}
else{
d++;
@ramiror
ramiror / intelligent.js
Last active November 28, 2020 12:36 — forked from mcsee/intelligent.js
function primeFactors(numberToFactor) {
var factors = [],
divisor = 2,
remainder = numberToFactor;
while (remainder >= 2) {
if (remainder % divisor === 0) {
factors.push(divisor);
remainder = remainder / divisor;
}